Class PersonDirectoryPrincipalResolver
- java.lang.Object
-
- org.apereo.cas.authentication.principal.resolvers.PersonDirectoryPrincipalResolver
-
- All Implemented Interfaces:
org.apereo.cas.authentication.principal.PrincipalResolver,org.springframework.core.Ordered
public class PersonDirectoryPrincipalResolver extends java.lang.Object implements org.apereo.cas.authentication.principal.PrincipalResolverResolves principals by querying a data source using the 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
-
-
Constructor Summary
Constructors Constructor Description PersonDirectoryPrincipalResolver()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.apereo.cas.authentication.principal.PrincipalbuildResolvedPrincipal(java.lang.String id, java.util.Map<java.lang.String,java.util.List<java.lang.Object>> attributes, 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)Build resolved principal.protected org.apereo.cas.authentication.principal.resolvers.PersonDirectoryPrincipalResolver.PrincipalResolutionResultconvertPersonAttributesToPrincipal(java.lang.String extractedPrincipalId, java.util.Optional<org.apereo.cas.authentication.principal.Principal> currentPrincipal, 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.services.persondir.IPersonAttributeDaogetAttributeRepository()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, java.util.Optional<org.apereo.cas.authentication.principal.Principal> currentPrincipal, java.util.Map<java.lang.String,java.util.List<java.lang.Object>> queryAttributes)Retrieve person attributes as a map.booleansupports(org.apereo.cas.authentication.Credential credential)
-
-
-
Method Detail
-
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
-
supports
public boolean supports(org.apereo.cas.authentication.Credential credential)
- Specified by:
supportsin interfaceorg.apereo.cas.authentication.principal.PrincipalResolver
-
getAttributeRepository
public org.apereo.services.persondir.IPersonAttributeDao getAttributeRepository()
- Specified by:
getAttributeRepositoryin interfaceorg.apereo.cas.authentication.principal.PrincipalResolver
-
buildResolvedPrincipal
protected org.apereo.cas.authentication.principal.Principal buildResolvedPrincipal(java.lang.String id, java.util.Map<java.lang.String,java.util.List<java.lang.Object>> attributes, 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)Build resolved principal.- Parameters:
id- the idattributes- the attributescredential- the credentialcurrentPrincipal- the current principalhandler- the handler- Returns:
- the principal
-
convertPersonAttributesToPrincipal
protected org.apereo.cas.authentication.principal.resolvers.PersonDirectoryPrincipalResolver.PrincipalResolutionResult convertPersonAttributesToPrincipal(java.lang.String extractedPrincipalId, java.util.Optional<org.apereo.cas.authentication.principal.Principal> currentPrincipal, java.util.Map<java.lang.String,java.util.List<java.lang.Object>> attributes)Convert person attributes to principal pair.- Parameters:
extractedPrincipalId- the extracted principal idcurrentPrincipal- the current principalattributes- 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, java.util.Optional<org.apereo.cas.authentication.principal.Principal> currentPrincipal, java.util.Map<java.lang.String,java.util.List<java.lang.Object>> queryAttributes)Retrieve person attributes as a map.- Parameters:
principalId- the principal idcredential- the credential whose id we have extracted.currentPrincipal- the current principalqueryAttributes- the query attributes- 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.
-
-