public class PseudoAuthenticationHandler extends java.lang.Object implements AuthenticationHandler
PseudoAuthenticationHandler provides a pseudo authentication mechanism that accepts
the user name specified as a query string parameter.
This mimics the model of Hadoop Simple authentication which trust the 'user.name' property provided in the configuration object.
This handler can be configured to support anonymous users.
The only supported configuration property is:
true|false, default value is false| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ANONYMOUS_ALLOWED
Constant for the configuration property that indicates if anonymous users are allowed.
|
static java.lang.String |
TYPE
Constant that identifies the authentication mechanism.
|
JWT_SSO_ENABLED, NON_BROWSER_USER_AGENTS, NON_BROWSER_USER_AGENTS_DEFAULT, WWW_AUTHENTICATE| Constructor and Description |
|---|
PseudoAuthenticationHandler()
Creates a pseudo authentication handler with the default auth-token
type,
simple. |
PseudoAuthenticationHandler(java.lang.String type)
Creates a pseudo authentication handler with a custom auth-token
type.
|
| Modifier and Type | Method and Description |
|---|---|
AuthenticationToken |
authenticate(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Authenticates an HTTP client request.
|
void |
destroy()
Releases any resources initialized by the authentication handler.
|
protected boolean |
getAcceptAnonymous()
Returns if the handler is configured to support anonymous users.
|
java.lang.String |
getType()
Returns the authentication type of the authentication handler, 'simple'.
|
void |
init(java.util.Properties config)
Initializes the authentication handler instance.
|
boolean |
shouldAuthenticate(javax.servlet.http.HttpServletRequest request)
Should the request be authenticated by the handler or not.
|
public static final java.lang.String TYPE
public static final java.lang.String ANONYMOUS_ALLOWED
public PseudoAuthenticationHandler()
simple.public PseudoAuthenticationHandler(java.lang.String type)
type - auth-token type.public void init(java.util.Properties config)
throws javax.servlet.ServletException
This method is invoked by the AuthenticationFilter.init(javax.servlet.FilterConfig) method.
init in interface AuthenticationHandlerconfig - configuration properties to initialize the handler.javax.servlet.ServletException - thrown if the handler could not be initialized.protected boolean getAcceptAnonymous()
public void destroy()
This implementation does a NOP.
destroy in interface AuthenticationHandlerpublic java.lang.String getType()
getType in interface AuthenticationHandlerpublic AuthenticationToken authenticate(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, AuthenticationException
It extracts the PseudoAuthenticator.USER_NAME parameter from the query string and creates
an AuthenticationToken with it.
If the HTTP client request does not contain the PseudoAuthenticator.USER_NAME parameter and
the handler is configured to allow anonymous users it returns the AuthenticationToken.ANONYMOUS
token.
If the HTTP client request does not contain the PseudoAuthenticator.USER_NAME parameter and
the handler is configured to disallow anonymous users it throws an AuthenticationException.
authenticate in interface AuthenticationHandlerrequest - the HTTP client request.response - the HTTP client response.java.io.IOException - thrown if an IO error occurred.AuthenticationException - thrown if HTTP client request was not accepted as an authentication request.public boolean shouldAuthenticate(javax.servlet.http.HttpServletRequest request)
AuthenticationHandlerThis is useful for deciding if a request should be handled by this handler or just forwarded to the next filter in chain. For example, if it's a java client in a long running application then the SSO handler can decide to not authenticate it and pass it on to the next filter
If the method returns TRUE the request will have to go through
this authentication handler
If the method returns FALSE the request is expected to be
passed on to the next filter in the chain
shouldAuthenticate in interface AuthenticationHandlerrequest - the HTTP client request.TRUE if this request should be authenticated by the handler,
FALSE otherwise.