public class FormsAuthenticator extends AbstractScopedAuthenticator<FormLogin>
An authenticator capable of making Form based logins and using cookies to maintain authentication state. Different logins may be used for different services as required.
Note that logins are not exclusively scoped to the exact URI rather they are
scoped to any URI derived from the given URI. For example if you declared
logins for http://example.org
they would also apply to
http://example.org/some/path/
. When determining credentials the
longest match applies, so in the previous example you could define different
logins for the two URIs and URIs derived from
http://example.org/some/path/
would prefer the login for that URI
over those for http://example.org
Constructor and Description |
---|
FormsAuthenticator(Map<URI,FormLogin> logins)
Creates a new authenticator with the given logins
|
FormsAuthenticator(URI target,
FormLogin login)
Creates a new authenticator with the given login
|
Modifier and Type | Method and Description |
---|---|
void |
addLogin(URI target,
FormLogin login)
Adds a login to the authenticator preserving any existing cookies associated with the login
|
void |
apply(org.apache.http.impl.client.AbstractHttpClient client,
org.apache.http.protocol.HttpContext httpContext,
URI target)
Applies any necessary authentication methods to the given HTTP Client
|
public FormsAuthenticator(URI target, FormLogin login)
target
- Target URIlogin
- Loginpublic void apply(org.apache.http.impl.client.AbstractHttpClient client, org.apache.http.protocol.HttpContext httpContext, URI target)
HttpAuthenticator
The target
parameter indicates the URI to which the request is
being made and so may be used by an authenticator to determine whether it
actually needs to apply any authentication or to scope authentication
appropriately.
apply
in interface HttpAuthenticator
apply
in class AbstractCredentialsAuthenticator
client
- HTTP ClienthttpContext
- HTTP Contexttarget
- Target URI to which code wants to authenticateLicenced under the Apache License, Version 2.0