public class LdapAuthenticationHandler
extends org.jasig.cas.authentication.handler.support.AbstractUsernamePasswordAuthenticationHandler
Authenticator component 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.
Principal resolution is controlled by the following properties:
| Modifier and Type | Field and Description |
|---|---|
protected java.util.List<java.lang.String> |
additionalAttributes
List of additional attributes to be fetched but are not principal attributes.
|
protected java.util.Map<java.lang.String,java.lang.String> |
principalAttributeMap
Mapping of LDAP attribute name to principal attribute name.
|
| Constructor and Description |
|---|
LdapAuthenticationHandler(org.ldaptive.auth.Authenticator authenticator)
Creates a new authentication handler that delegates to the given authenticator.
|
| Modifier and Type | Method and Description |
|---|---|
protected org.jasig.cas.authentication.HandlerResult |
authenticateUsernamePasswordInternal(org.jasig.cas.authentication.UsernamePasswordCredential upc) |
protected org.jasig.cas.authentication.principal.Principal |
createPrincipal(java.lang.String username,
org.ldaptive.LdapEntry ldapEntry)
Creates a CAS principal with attributes if the LDAP entry contains principal attributes.
|
java.lang.String |
getName() |
void |
initialize()
Initialize the handler, setup the authentication entry attributes.
|
void |
setAdditionalAttributes(java.util.List<java.lang.String> additionalAttributes)
Sets the list of additional attributes to be fetched from the user entry during authentication.
|
void |
setAllowMultiplePrincipalAttributeValues(boolean allowed)
Sets a flag that determines whether multiple values are allowed for the
principalIdAttribute. |
void |
setName(java.lang.String name)
Sets the component name.
|
void |
setPrincipalAttributeList(java.util.List<java.lang.String> attributeList)
Sets the mapping of additional principal attributes where the key and value is the LDAP attribute
name.
|
void |
setPrincipalAttributeMap(java.util.Map<java.lang.String,java.lang.String> attributeNameMap)
Sets the mapping of additional principal attributes where the key is the LDAP attribute
name and the value is the principal attribute name.
|
void |
setPrincipalIdAttribute(java.lang.String attributeName)
Sets the name of the LDAP principal attribute whose value should be used for the
principal ID.
|
boolean |
supports(org.jasig.cas.authentication.Credential credential)
Handle post authentication processing.
|
doAuthentication, getPasswordEncoder, getPasswordPolicyConfiguration, getPrincipalNameTransformer, setPasswordEncoder, setPasswordPolicyConfiguration, setPrincipalNameTransformerauthenticate, createHandlerResult, postAuthenticate, preAuthenticate@NotNull protected java.util.Map<java.lang.String,java.lang.String> principalAttributeMap
@NotNull protected java.util.List<java.lang.String> additionalAttributes
public LdapAuthenticationHandler(@NotNull
org.ldaptive.auth.Authenticator authenticator)
authenticator - Ldaptive authenticator component.public void setName(java.lang.String name)
setName in class org.jasig.cas.authentication.AbstractAuthenticationHandlername - Authentication handler name.public void setPrincipalIdAttribute(java.lang.String attributeName)
attributeName - LDAP attribute name.public void setAllowMultiplePrincipalAttributeValues(boolean allowed)
principalIdAttribute.
This flag only has an effect if principalIdAttribute is configured. If multiple values are detected
when the flag is false, the first value is used and a warning is logged. If multiple values are detected
when the flag is true, an exception is raised.allowed - True to allow multiple principal ID attribute values, false otherwise.public void setPrincipalAttributeMap(java.util.Map<java.lang.String,java.lang.String> attributeNameMap)
attributeNameMap - Map of LDAP attribute name to principal attribute name.public void setPrincipalAttributeList(java.util.List<java.lang.String> attributeList)
attributeList - List of LDAP attribute namespublic void setAdditionalAttributes(java.util.List<java.lang.String> additionalAttributes)
A common use case for these attributes is to support password policy machinery.
additionalAttributes - List of operational attributes to fetch when resolving an entry.protected org.jasig.cas.authentication.HandlerResult authenticateUsernamePasswordInternal(org.jasig.cas.authentication.UsernamePasswordCredential upc)
throws java.security.GeneralSecurityException,
org.jasig.cas.authentication.PreventedException
authenticateUsernamePasswordInternal in class org.jasig.cas.authentication.handler.support.AbstractUsernamePasswordAuthenticationHandlerjava.security.GeneralSecurityExceptionorg.jasig.cas.authentication.PreventedExceptionpublic boolean supports(org.jasig.cas.authentication.Credential credential)
supports in interface org.jasig.cas.authentication.AuthenticationHandlersupports in class org.jasig.cas.authentication.handler.support.AbstractUsernamePasswordAuthenticationHandlercredential - the credentialpublic java.lang.String getName()
getName in interface org.jasig.cas.authentication.AuthenticationHandlergetName in class org.jasig.cas.authentication.AbstractAuthenticationHandlerprotected org.jasig.cas.authentication.principal.Principal createPrincipal(java.lang.String username,
org.ldaptive.LdapEntry ldapEntry)
throws javax.security.auth.login.LoginException
username - Username that was successfully authenticated which is used for principal ID when
setPrincipalIdAttribute(String) is not specified.ldapEntry - LDAP entry that may contain principal attributes.javax.security.auth.login.LoginException - On security policy errors related to principal creation.@PostConstruct public void initialize()