Class 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.PrincipalResolver
    Resolves principals by querying a data source using the Person Directory API. The Principal.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 inherited from interface org.springframework.core.Ordered

        HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
      • Fields inherited from interface org.apereo.cas.authentication.principal.PrincipalResolver

        BEAN_NAME_ATTRIBUTE_REPOSITORY, BEAN_NAME_GLOBAL_PRINCIPAL_ATTRIBUTE_REPOSITORY, BEAN_NAME_PRINCIPAL_RESOLVER
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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.
      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.
      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.
      org.apereo.services.persondir.IPersonAttributeDao getAttributeRepository()  
      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)  
      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.
      boolean supports​(org.apereo.cas.authentication.Credential credential)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface org.apereo.cas.authentication.principal.PrincipalResolver

        getName, getOrder, resolve, resolve
    • Constructor Detail

      • PersonDirectoryPrincipalResolver

        public PersonDirectoryPrincipalResolver()
    • 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:
        resolve in interface org.apereo.cas.authentication.principal.PrincipalResolver
      • supports

        public boolean supports​(org.apereo.cas.authentication.Credential credential)
        Specified by:
        supports in interface org.apereo.cas.authentication.principal.PrincipalResolver
      • getAttributeRepository

        public org.apereo.services.persondir.IPersonAttributeDao getAttributeRepository()
        Specified by:
        getAttributeRepository in interface org.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 id
        attributes - the attributes
        credential - the credential
        currentPrincipal - the current principal
        handler - 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 id
        currentPrincipal - the current principal
        attributes - 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 id
        credential - the credential whose id we have extracted.
        currentPrincipal - the current principal
        queryAttributes - 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.