org.apache.jena.atlas.web.auth
Class FormsAuthenticator

java.lang.Object
  extended by org.apache.jena.atlas.web.auth.AbstractCredentialsAuthenticator
      extended by org.apache.jena.atlas.web.auth.AbstractScopedAuthenticator<FormLogin>
          extended by org.apache.jena.atlas.web.auth.FormsAuthenticator
All Implemented Interfaces:
HttpAuthenticator

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.

Login Scope

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 Summary
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
 
Method Summary
 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
 void invalidate()
          Invalidates the authenticator
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FormsAuthenticator

public FormsAuthenticator(URI target,
                          FormLogin login)
Creates a new authenticator with the given login

Parameters:
target - Target URI
login - Login

FormsAuthenticator

public FormsAuthenticator(Map<URI,FormLogin> logins)
Creates a new authenticator with the given logins

Parameters:
logins - Logins
Method Detail

apply

public void apply(org.apache.http.impl.client.AbstractHttpClient client,
                  org.apache.http.protocol.HttpContext httpContext,
                  URI target)
Description copied from interface: HttpAuthenticator
Applies any necessary authentication methods to the given HTTP Client

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.

Specified by:
apply in interface HttpAuthenticator
Overrides:
apply in class AbstractCredentialsAuthenticator
Parameters:
client - HTTP Client
httpContext - HTTP Context
target - Target URI to which code wants to authenticate

invalidate

public void invalidate()
Description copied from interface: HttpAuthenticator
Invalidates the authenticator

Allows code to inform the authenticator that any cached authentication information should be invalidated. This can be useful after an authentication attempt fails or after a certain amount of time is passed. For many authenticators this may actually be a no-op since when using standard HTTP authentication typically you authenticate on every request and there are no cached authentication information. However more complex authentication mechanisms such as Form Based authentication may have cached information that discarding will force subsequent requests to re-authenticate.

Specified by:
invalidate in interface HttpAuthenticator
Overrides:
invalidate in class AbstractCredentialsAuthenticator

addLogin

public void addLogin(URI target,
                     FormLogin login)
Adds a login to the authenticator preserving any existing cookies associated with the login

Parameters:
target - Target URI
login - Login


Licenced under the Apache License, Version 2.0