public class DynamicBasicAuthorizationHeader extends java.lang.Object implements HttpURLConnectionAuthenticator
HttpConstants.AUTHORIZATION
(Basic only) from configuration (or metadata).
In some situations it may be preferred to build the HttpConstants.AUTHORIZATION
header rather than relying on the
behaviour of URLConnection
to request a PasswordAuthentication
object when accessing protected resources (this is
what happens if you use UserPassAuthentication
). You can use this class to create a Basic authorization.
In the adapter configuration file this class is aliased as http-dynamic-authorization-header which is the preferred alternative to the fully qualified classname when building your configuration.
Constructor and Description |
---|
DynamicBasicAuthorizationHeader() |
DynamicBasicAuthorizationHeader(java.lang.String username,
java.lang.String password) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Undo whatever global state modifications have been made by this HttpAuthenticator.
|
void |
configureConnection(java.net.HttpURLConnection conn)
Perform whatever actions are required to the HttpURLConnection after it's been opened (setting custom headers, etc).
|
java.lang.String |
getPassword() |
java.lang.String |
getUsername() |
void |
setPassword(java.lang.String pw) |
void |
setup(java.lang.String target,
AdaptrisMessage msg,
ResourceTargetMatcher auth)
Initialize the HttpAuthenticator for a message and return.
|
void |
setUsername(java.lang.String s)
Set the username
|
public DynamicBasicAuthorizationHeader()
public DynamicBasicAuthorizationHeader(java.lang.String username, java.lang.String password)
public void setup(java.lang.String target, AdaptrisMessage msg, ResourceTargetMatcher auth) throws CoreException
HttpAuthenticator
setup
in interface HttpAuthenticator
target
- The URL to set authenticate formsg
- The message to set up forauth
- the ResourceTargetMatcher
to use, if null a default one will be created based on the
ResourceAuthenticator.ResourceTarget.getRequestingURL()
CoreException
public void configureConnection(java.net.HttpURLConnection conn)
HttpURLConnectionAuthenticator
configureConnection
in interface HttpURLConnectionAuthenticator
public void close()
HttpAuthenticator
close
in interface HttpAuthenticator
close
in interface java.lang.AutoCloseable
public java.lang.String getUsername()
public void setUsername(java.lang.String s)
s
- the username, supports metadata resolution via InterlokMessage.resolve(String)
.public java.lang.String getPassword()
public void setPassword(java.lang.String pw)
pw
- the password to set, supports metadata resolution via InterlokMessage.resolve(String)
.