public class PseudoAuthenticationHandler extends 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 String |
ANONYMOUS_ALLOWED
Constant for the configuration property that indicates if anonymous users are allowed.
|
static String |
TYPE
Constant that identifies the authentication mechanism.
|
WWW_AUTHENTICATE
Constructor and Description |
---|
PseudoAuthenticationHandler()
Creates a Hadoop pseudo authentication handler with the default auth-token
type,
simple . |
PseudoAuthenticationHandler(String type)
Creates a Hadoop 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.
|
String |
getType()
Returns the authentication type of the authentication handler, 'simple'.
|
void |
init(Properties config)
Initializes the authentication handler instance.
|
boolean |
managementOperation(AuthenticationToken token,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
This is an empty implementation, it always returns
TRUE . |
public static final String TYPE
public static final String ANONYMOUS_ALLOWED
public PseudoAuthenticationHandler()
simple
.public PseudoAuthenticationHandler(String type)
type
- auth-token type.public void init(Properties config) throws javax.servlet.ServletException
This method is invoked by the AuthenticationFilter.init(javax.servlet.FilterConfig)
method.
init
in interface AuthenticationHandler
config
- 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 AuthenticationHandler
public String getType()
getType
in interface AuthenticationHandler
public boolean managementOperation(AuthenticationToken token, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException, AuthenticationException
TRUE
.managementOperation
in interface AuthenticationHandler
token
- the authentication token if any, otherwise NULL
.request
- the HTTP client request.response
- the HTTP client response.TRUE
IOException
- it is never thrown.AuthenticationException
- it is never thrown.public AuthenticationToken authenticate(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws 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 AuthenticationHandler
request
- the HTTP client request.response
- the HTTP client response.IOException
- thrown if an IO error occurred.AuthenticationException
- thrown if HTTP client request was not accepted as an authentication request.Copyright © 2008–2021 Apache Software Foundation. All rights reserved.