Class PersonDirectoryPrincipalResolver
- java.lang.Object
-
- org.apereo.cas.authentication.principal.resolvers.PersonDirectoryPrincipalResolver
-
- All Implemented Interfaces:
org.apereo.cas.authentication.principal.PrincipalResolver
public class PersonDirectoryPrincipalResolver extends java.lang.Object implements org.apereo.cas.authentication.principal.PrincipalResolverResolves principals by querying a data source using the Jasig Person Directory API. ThePrincipal.getAttributes()are populated by the results of the query and the principal ID may optionally be set by proving an attribute whose first non-null value is used; otherwise the credential ID is used for the principal ID.- Since:
- 4.0.0
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apereo.services.persondir.IPersonAttributeDaoattributeRepositoryRepository of principal attributes to be retrieved.protected java.lang.StringprincipalAttributeNameOptional principal attribute name.protected org.apereo.cas.authentication.principal.PrincipalFactoryprincipalFactoryFactory to create the principal type.protected org.apereo.cas.authentication.handler.PrincipalNameTransformerprincipalNameTransformerTransform principal name.protected booleanreturnNullIfNoAttributesreturn null if no attributes are found.protected booleanuseCurrentPrincipalIdUse the current principal id for extraction.
-
Constructor Summary
Constructors Constructor Description PersonDirectoryPrincipalResolver()PersonDirectoryPrincipalResolver(boolean returnNullIfNoAttributes, java.lang.String principalAttributeName)PersonDirectoryPrincipalResolver(org.apereo.services.persondir.IPersonAttributeDao attributeRepository)PersonDirectoryPrincipalResolver(org.apereo.services.persondir.IPersonAttributeDao attributeRepository, java.lang.String principalAttributeName)PersonDirectoryPrincipalResolver(org.apereo.services.persondir.IPersonAttributeDao attributeRepository, org.apereo.cas.authentication.principal.PrincipalFactory principalFactory, boolean returnNullIfNoAttributes, java.lang.String principalAttributeName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.apache.commons.lang3.tuple.Pair<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>>convertPersonAttributesToPrincipal(java.lang.String extractedPrincipalId, java.util.Map<java.lang.String,java.util.List<java.lang.Object>> attributes)Convert person attributes to principal pair.protected java.lang.StringextractPrincipalId(org.apereo.cas.authentication.Credential credential, java.util.Optional<org.apereo.cas.authentication.principal.Principal> currentPrincipal)Extracts the id of the user from the provided credential.org.apereo.cas.authentication.principal.Principalresolve(org.apereo.cas.authentication.Credential credential, java.util.Optional<org.apereo.cas.authentication.principal.Principal> currentPrincipal, java.util.Optional<org.apereo.cas.authentication.AuthenticationHandler> handler)protected java.util.Map<java.lang.String,java.util.List<java.lang.Object>>retrievePersonAttributes(java.lang.String principalId, org.apereo.cas.authentication.Credential credential)Retrieve person attributes map.booleansupports(org.apereo.cas.authentication.Credential credential)
-
-
-
Field Detail
-
attributeRepository
protected final org.apereo.services.persondir.IPersonAttributeDao attributeRepository
Repository of principal attributes to be retrieved.
-
principalFactory
protected final org.apereo.cas.authentication.principal.PrincipalFactory principalFactory
Factory to create the principal type.
-
returnNullIfNoAttributes
protected final boolean returnNullIfNoAttributes
return null if no attributes are found.
-
principalNameTransformer
protected final org.apereo.cas.authentication.handler.PrincipalNameTransformer principalNameTransformer
Transform principal name.
-
principalAttributeName
protected final java.lang.String principalAttributeName
Optional principal attribute name.
-
useCurrentPrincipalId
protected boolean useCurrentPrincipalId
Use the current principal id for extraction.
-
-
Constructor Detail
-
PersonDirectoryPrincipalResolver
public PersonDirectoryPrincipalResolver()
-
PersonDirectoryPrincipalResolver
public PersonDirectoryPrincipalResolver(org.apereo.services.persondir.IPersonAttributeDao attributeRepository, java.lang.String principalAttributeName)
-
PersonDirectoryPrincipalResolver
public PersonDirectoryPrincipalResolver(org.apereo.services.persondir.IPersonAttributeDao attributeRepository)
-
PersonDirectoryPrincipalResolver
public PersonDirectoryPrincipalResolver(boolean returnNullIfNoAttributes, java.lang.String principalAttributeName)
-
PersonDirectoryPrincipalResolver
public PersonDirectoryPrincipalResolver(org.apereo.services.persondir.IPersonAttributeDao attributeRepository, org.apereo.cas.authentication.principal.PrincipalFactory principalFactory, boolean returnNullIfNoAttributes, java.lang.String principalAttributeName)
-
-
Method Detail
-
supports
public boolean supports(org.apereo.cas.authentication.Credential credential)
- Specified by:
supportsin interfaceorg.apereo.cas.authentication.principal.PrincipalResolver
-
resolve
public org.apereo.cas.authentication.principal.Principal resolve(org.apereo.cas.authentication.Credential credential, java.util.Optional<org.apereo.cas.authentication.principal.Principal> currentPrincipal, java.util.Optional<org.apereo.cas.authentication.AuthenticationHandler> handler)- Specified by:
resolvein interfaceorg.apereo.cas.authentication.principal.PrincipalResolver
-
convertPersonAttributesToPrincipal
protected org.apache.commons.lang3.tuple.Pair<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>> convertPersonAttributesToPrincipal(java.lang.String extractedPrincipalId, java.util.Map<java.lang.String,java.util.List<java.lang.Object>> attributes)Convert person attributes to principal pair.- Parameters:
extractedPrincipalId- the extracted principal idattributes- the attributes- Returns:
- the pair
-
retrievePersonAttributes
protected java.util.Map<java.lang.String,java.util.List<java.lang.Object>> retrievePersonAttributes(java.lang.String principalId, org.apereo.cas.authentication.Credential credential)Retrieve person attributes map.- Parameters:
principalId- the principal idcredential- the credential whose id we have extracted. This is passed so that implementations can extract useful bits of authN info such as attributes into the principal.- Returns:
- the map
-
extractPrincipalId
protected java.lang.String extractPrincipalId(org.apereo.cas.authentication.Credential credential, java.util.Optional<org.apereo.cas.authentication.principal.Principal> currentPrincipal)Extracts the id of the user from the provided credential. This method should be overridden by subclasses to achieve more sophisticated strategies for producing a principal ID from a credential.- Parameters:
credential- the credential provided by the user.currentPrincipal- the current principal- Returns:
- the username, or null if it could not be resolved.
-
-