Class PseudoAuthenticationHandler
- All Implemented Interfaces:
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:
- simple.anonymous.allowed:
true|false, default value isfalse
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringConstant for the configuration property that indicates if anonymous users are allowed.static final StringConstant that identifies the authentication mechanism.Fields inherited from interface org.apache.hadoop.security.authentication.server.AuthenticationHandler
WWW_AUTHENTICATE -
Constructor Summary
ConstructorsConstructorDescriptionCreates a Hadoop pseudo authentication handler with the default auth-token type,simple.Creates a Hadoop pseudo authentication handler with a custom auth-token type. -
Method Summary
Modifier and TypeMethodDescriptionauthenticate(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Authenticates an HTTP client request.voiddestroy()Releases any resources initialized by the authentication handler.protected booleanReturns if the handler is configured to support anonymous users.getType()Returns the authentication type of the authentication handler, 'simple'.voidinit(Properties config) Initializes the authentication handler instance.booleanmanagementOperation(AuthenticationToken token, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) This is an empty implementation, it always returnsTRUE.
-
Field Details
-
TYPE
Constant that identifies the authentication mechanism.- See Also:
-
ANONYMOUS_ALLOWED
Constant for the configuration property that indicates if anonymous users are allowed.- See Also:
-
-
Constructor Details
-
PseudoAuthenticationHandler
public PseudoAuthenticationHandler()Creates a Hadoop pseudo authentication handler with the default auth-token type,simple. -
PseudoAuthenticationHandler
Creates a Hadoop pseudo authentication handler with a custom auth-token type.- Parameters:
type- auth-token type.
-
-
Method Details
-
init
Initializes the authentication handler instance.This method is invoked by the
AuthenticationFilter.init(javax.servlet.FilterConfig)method.- Specified by:
initin interfaceAuthenticationHandler- Parameters:
config- configuration properties to initialize the handler.- Throws:
javax.servlet.ServletException- thrown if the handler could not be initialized.
-
getAcceptAnonymous
protected boolean getAcceptAnonymous()Returns if the handler is configured to support anonymous users.- Returns:
- if the handler is configured to support anonymous users.
-
destroy
public void destroy()Releases any resources initialized by the authentication handler.This implementation does a NOP.
- Specified by:
destroyin interfaceAuthenticationHandler
-
getType
Returns the authentication type of the authentication handler, 'simple'.- Specified by:
getTypein interfaceAuthenticationHandler- Returns:
- the authentication type of the authentication handler, 'simple'.
-
managementOperation
public boolean managementOperation(AuthenticationToken token, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException, AuthenticationException This is an empty implementation, it always returnsTRUE.- Specified by:
managementOperationin interfaceAuthenticationHandler- Parameters:
token- the authentication token if any, otherwiseNULL.request- the HTTP client request.response- the HTTP client response.- Returns:
TRUE- Throws:
IOException- it is never thrown.AuthenticationException- it is never thrown.
-
authenticate
public AuthenticationToken authenticate(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException, AuthenticationException Authenticates an HTTP client request.It extracts the
PseudoAuthenticator.USER_NAMEparameter from the query string and creates anAuthenticationTokenwith it.If the HTTP client request does not contain the
PseudoAuthenticator.USER_NAMEparameter and the handler is configured to allow anonymous users it returns theAuthenticationToken.ANONYMOUStoken.If the HTTP client request does not contain the
PseudoAuthenticator.USER_NAMEparameter and the handler is configured to disallow anonymous users it throws anAuthenticationException.- Specified by:
authenticatein interfaceAuthenticationHandler- Parameters:
request- the HTTP client request.response- the HTTP client response.- Returns:
- an authentication token if the HTTP client request is accepted and credentials are valid.
- Throws:
IOException- thrown if an IO error occurred.AuthenticationException- thrown if HTTP client request was not accepted as an authentication request.
-