public interface AuthContext
Modifier and Type | Method and Description |
---|---|
void |
configureConnection(java.net.HttpURLConnection connection)
Configures an HTTP connection with required authentication.
|
java.lang.String[] |
getCurlArgs(java.net.URL url,
boolean showSecret)
Returns an array of command-line arguments that could be passed
to curl(1) corresponding to the authentication arrangements
implemented by this context.
|
AuthScheme |
getScheme()
Returns the scheme that yielded this context.
|
boolean |
hasCredentials()
Indicates whether this context is actually believed capable of
authenticating.
|
boolean |
isChallengeDomain(Challenge challenge,
java.net.URL url)
Indicates whether this context is expected to be good for
authenticating against a given challenge.
|
boolean |
isExpired()
Indicates whether this authentication period's validity is known
to have expired.
|
boolean |
isUrlDomain(java.net.URL url)
Indicates whether this context is expected to be good for
authenticating a given URL.
|
AuthScheme getScheme()
boolean hasCredentials()
configureConnection(java.net.HttpURLConnection)
method will normally do nothing.boolean isUrlDomain(java.net.URL url)
If this method unconditionally returns false, and a service has authenticated and anonymous access at the same endpoints, it's generally hard for client code ever to use the authenticated access.
url
- URL for which authentication is requiredboolean isChallengeDomain(Challenge challenge, java.net.URL url)
Note that if this returns true, the authentication information owned by this context may be sent to the supplied URL. It is therefore important to return false if the authentication information might be private from the supplied URL, otherwise a malevolent endpoint might issue a challenge with the parameters of a different service to obtain authentication information under false pretences. As a rule of thumb therefore, true should only be returned if the supplied URL is known to be owned by the same party for which this context was established. However, schemes that include scoping rules preventing such information leakage may not require such restrictions.
challenge
- challengeurl
- URL from which the challenge was receivedboolean isExpired()
void configureConnection(java.net.HttpURLConnection connection) throws java.io.IOException
connect()
has been made)
on entry and on exit.connection
- unopened HTTP connection objectjava.io.IOException
- if authentication could not be configuredjava.lang.String[] getCurlArgs(java.net.URL url, boolean showSecret)
url
- URL to which curl would be connectingshowSecret
- if true, sensitive information such as passwords
may be included;
if false, such items must be omitted