Package org.apereo.cas.authentication
Class LdapAuthenticationHandler
- java.lang.Object
-
- org.apereo.cas.authentication.AbstractAuthenticationHandler
-
- org.apereo.cas.authentication.handler.support.AbstractPreAndPostProcessingAuthenticationHandler
-
- org.apereo.cas.authentication.handler.support.AbstractUsernamePasswordAuthenticationHandler
-
- org.apereo.cas.authentication.LdapAuthenticationHandler
-
- All Implemented Interfaces:
org.apereo.cas.authentication.AuthenticationHandler,org.apereo.cas.authentication.PrePostAuthenticationHandler,org.springframework.beans.factory.DisposableBean,org.springframework.core.Ordered
public class LdapAuthenticationHandler extends org.apereo.cas.authentication.handler.support.AbstractUsernamePasswordAuthenticationHandler implements org.springframework.beans.factory.DisposableBeanLDAP authentication handler that uses the ldaptiveAuthenticatorcomponent underneath. This handler provides simple attribute resolution machinery by reading attributes from the entry corresponding to the DN of the bound user (in the bound security context) upon successful authentication.- Since:
- 4.0.0
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.String,java.lang.Object>principalAttributeMapMapping of LDAP attribute name to principal attribute name.-
Fields inherited from class org.apereo.cas.authentication.handler.support.AbstractUsernamePasswordAuthenticationHandler
passwordPolicyHandlingStrategy
-
Fields inherited from class org.apereo.cas.authentication.AbstractAuthenticationHandler
credentialSelectionPredicate, principalFactory, servicesManager
-
-
Constructor Summary
Constructors Constructor Description LdapAuthenticationHandler(java.lang.String name, org.apereo.cas.services.ServicesManager servicesManager, org.apereo.cas.authentication.principal.PrincipalFactory principalFactory, java.lang.Integer order, org.ldaptive.auth.Authenticator authenticator, org.apereo.cas.authentication.AuthenticationPasswordPolicyHandlingStrategy strategy)Creates a new authentication handler that delegates to the given authenticator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.apereo.cas.authentication.AuthenticationHandlerExecutionResultauthenticateUsernamePasswordInternal(org.apereo.cas.authentication.credential.UsernamePasswordCredential upc, java.lang.String originalPassword)protected java.util.Map<java.lang.String,java.util.List<java.lang.Object>>collectAttributesForLdapEntry(org.ldaptive.LdapEntry ldapEntry, java.lang.String username)Collect attributes for ldap entry.protected org.apereo.cas.authentication.principal.PrincipalcreatePrincipal(java.lang.String username, org.ldaptive.LdapEntry ldapEntry)Creates a CAS principal with attributes if the LDAP entry contains principal attributes.voiddestroy()protected java.lang.StringgetLdapPrincipalIdentifier(java.lang.String username, org.ldaptive.LdapEntry ldapEntry)Gets ldap principal identifier.voidinitialize()Initialize the handler, setup the authentication entry attributes.-
Methods inherited from class org.apereo.cas.authentication.handler.support.AbstractUsernamePasswordAuthenticationHandler
doAuthentication, getPasswordEncoder, getPasswordPolicyConfiguration, getPasswordPolicyHandlingStrategy, getPrincipalNameTransformer, matches, setPasswordEncoder, setPasswordPolicyConfiguration, setPasswordPolicyHandlingStrategy, setPrincipalNameTransformer, supports, supports, transformPassword, transformUsername
-
Methods inherited from class org.apereo.cas.authentication.handler.support.AbstractPreAndPostProcessingAuthenticationHandler
authenticate, createHandlerResult, createHandlerResult
-
Methods inherited from class org.apereo.cas.authentication.AbstractAuthenticationHandler
getCredentialSelectionPredicate, getName, getOrder, getPrincipalFactory, getServicesManager, setCredentialSelectionPredicate
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Constructor Detail
-
LdapAuthenticationHandler
public LdapAuthenticationHandler(java.lang.String name, org.apereo.cas.services.ServicesManager servicesManager, org.apereo.cas.authentication.principal.PrincipalFactory principalFactory, java.lang.Integer order, org.ldaptive.auth.Authenticator authenticator, org.apereo.cas.authentication.AuthenticationPasswordPolicyHandlingStrategy strategy)Creates a new authentication handler that delegates to the given authenticator.- Parameters:
name- the nameservicesManager- the services managerprincipalFactory- the principal factoryorder- the orderauthenticator- Ldaptive authenticator component.strategy- the strategy
-
-
Method Detail
-
destroy
public void destroy()
- Specified by:
destroyin interfaceorg.springframework.beans.factory.DisposableBean
-
authenticateUsernamePasswordInternal
protected org.apereo.cas.authentication.AuthenticationHandlerExecutionResult authenticateUsernamePasswordInternal(org.apereo.cas.authentication.credential.UsernamePasswordCredential upc, java.lang.String originalPassword) throws java.security.GeneralSecurityException, org.apereo.cas.authentication.PreventedException- Specified by:
authenticateUsernamePasswordInternalin classorg.apereo.cas.authentication.handler.support.AbstractUsernamePasswordAuthenticationHandler- Throws:
java.security.GeneralSecurityExceptionorg.apereo.cas.authentication.PreventedException
-
createPrincipal
protected org.apereo.cas.authentication.principal.Principal createPrincipal(java.lang.String username, org.ldaptive.LdapEntry ldapEntry) throws javax.security.auth.login.LoginExceptionCreates a CAS principal with attributes if the LDAP entry contains principal attributes.- Parameters:
username- Username that was successfully authenticated which is used for principal ID when principal id is not specified.ldapEntry- LDAP entry that may contain principal attributes.- Returns:
- Principal if the LDAP entry contains at least a principal ID attribute value, null otherwise.
- Throws:
javax.security.auth.login.LoginException- On security policy errors related to principal creation.
-
collectAttributesForLdapEntry
protected java.util.Map<java.lang.String,java.util.List<java.lang.Object>> collectAttributesForLdapEntry(org.ldaptive.LdapEntry ldapEntry, java.lang.String username)Collect attributes for ldap entry.- Parameters:
ldapEntry- the ldap entryusername- the username- Returns:
- the map
-
getLdapPrincipalIdentifier
protected java.lang.String getLdapPrincipalIdentifier(java.lang.String username, org.ldaptive.LdapEntry ldapEntry) throws javax.security.auth.login.LoginExceptionGets ldap principal identifier. If the principal id attribute is defined, it's retrieved. If no attribute value is found, a warning is generated and the provided username is used instead. If no attribute is defined, username is used instead.- Parameters:
username- the usernameldapEntry- the ldap entry- Returns:
- the ldap principal identifier
- Throws:
javax.security.auth.login.LoginException- in case the principal id cannot be determined.
-
initialize
public void initialize()
Initialize the handler, setup the authentication entry attributes.
-
-