Class LdapAuthenticationHandler
- All Implemented Interfaces:
AuthenticationHandler
LdapAuthenticationHandler implements the BASIC authentication
mechanism for HTTP using LDAP back-end.
The supported configuration properties are:
- ldap.providerurl: The url of the LDAP server. It does not have a default value.
- ldap.basedn: the base distinguished name (DN) to be used with the LDAP server. This value is appended to the provided user id for authentication purpose. It does not have a default value.
- ldap.binddomain: the LDAP bind domain value to be used with the LDAP server. This property is optional and useful only in case of Active Directory server.
- ldap.enablestarttls: A boolean value used to define if the LDAP server supports 'StartTLS' extension.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringConstant for the configuration property that indicates the base distinguished name (DN) to be used with the LDAP server.static final StringConstant for the configuration property that indicates whether the LDAP server supports 'StartTLS' extension.static final StringConstant for the configuration property that indicates the LDAP bind domain value to be used with the LDAP server.static final StringConstant for the configuration property that indicates the url of the LDAP server.static final StringConstant that identifies the authentication mechanism to be used with the LDAP server.static final StringConstant that identifies the authentication mechanism.Fields inherited from interface org.apache.hadoop.security.authentication.server.AuthenticationHandler
WWW_AUTHENTICATE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionauthenticate(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Performs an authentication step for the given HTTP client request.voiddestroy()Destroys the authentication handler instance.getType()Returns the authentication type of the authentication handler.voidinit(Properties config) Initializes the authentication handler instance.booleanmanagementOperation(AuthenticationToken token, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Performs an authentication management operation.voidsetDisableHostNameVerification(Boolean disableHostNameVerification) Configure the Host name verification for this handler.voidsetEnableStartTls(Boolean enableStartTls) Configure StartTLS LDAP extension for this handler.
-
Field Details
-
TYPE
Constant that identifies the authentication mechanism.- See Also:
-
SECURITY_AUTHENTICATION
Constant that identifies the authentication mechanism to be used with the LDAP server.- See Also:
-
PROVIDER_URL
Constant for the configuration property that indicates the url of the LDAP server.- See Also:
-
BASE_DN
Constant for the configuration property that indicates the base distinguished name (DN) to be used with the LDAP server. This value is appended to the provided user id for authentication purpose.- See Also:
-
LDAP_BIND_DOMAIN
Constant for the configuration property that indicates the LDAP bind domain value to be used with the LDAP server.- See Also:
-
ENABLE_START_TLS
Constant for the configuration property that indicates whether the LDAP server supports 'StartTLS' extension.- See Also:
-
-
Constructor Details
-
LdapAuthenticationHandler
public LdapAuthenticationHandler()
-
-
Method Details
-
setEnableStartTls
Configure StartTLS LDAP extension for this handler.- Parameters:
enableStartTls- true If the StartTLS LDAP extension is to be enabled false otherwise
-
setDisableHostNameVerification
Configure the Host name verification for this handler. This method is introduced only for unit testing and should never be used in production.- Parameters:
disableHostNameVerification- true to disable host-name verification false otherwise
-
getType
Description copied from interface:AuthenticationHandlerReturns the authentication type of the authentication handler. This should be a name that uniquely identifies the authentication type. For example 'simple' or 'kerberos'.- Specified by:
getTypein interfaceAuthenticationHandler- Returns:
- the authentication type of the authentication handler.
-
init
Description copied from interface:AuthenticationHandlerInitializes 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.
-
destroy
public void destroy()Description copied from interface:AuthenticationHandlerDestroys the authentication handler instance.This method is invoked by the
AuthenticationFilter.destroy()method.- Specified by:
destroyin interfaceAuthenticationHandler
-
managementOperation
public boolean managementOperation(AuthenticationToken token, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException, AuthenticationException Description copied from interface:AuthenticationHandlerPerforms an authentication management operation.This is useful for handling operations like get/renew/cancel delegation tokens which are being handled as operations of the service end-point.
If the method returns
TRUEthe request will continue normal processing, this means the method has not produced any HTTP response.If the method returns
FALSEthe request will end, this means the method has produced the corresponding HTTP response.- Specified by:
managementOperationin interfaceAuthenticationHandler- Parameters:
token- the authentication token if any, otherwiseNULL.request- the HTTP client request.response- the HTTP client response.- Returns:
TRUEif the request should be processed as a regular request,FALSEotherwise.- Throws:
IOException- thrown if an IO error occurred.AuthenticationException- thrown if an Authentication error occurred.
-
authenticate
public AuthenticationToken authenticate(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException, AuthenticationException Description copied from interface:AuthenticationHandlerPerforms an authentication step for the given HTTP client request.This method is invoked by the
AuthenticationFilteronly if the HTTP client request is not yet authenticated.Depending upon the authentication mechanism being implemented, a particular HTTP client may end up making a sequence of invocations before authentication is successfully established (this is the case of Kerberos SPNEGO).
This method must return an
AuthenticationTokenonly if the the HTTP client request has been successfully and fully authenticated.If the HTTP client request has not been completely authenticated, this method must take over the corresponding HTTP response and it must return
null.- Specified by:
authenticatein interfaceAuthenticationHandler- Parameters:
request- the HTTP client request.response- the HTTP client response.- Returns:
- an
AuthenticationTokenif the HTTP client request has been authenticated,nullotherwise (in this case it must take care of the response). - Throws:
IOException- thrown if an IO error occurred.AuthenticationException- thrown if an Authentication error occurred.
-