Class PolicyBasedAuthenticationManager

  • All Implemented Interfaces:
    org.apereo.cas.authentication.AuthenticationManager

    public class PolicyBasedAuthenticationManager
    extends java.lang.Object
    implements org.apereo.cas.authentication.AuthenticationManager
    This is PolicyBasedAuthenticationManager, which provides common operations around an authentication manager implementation.
    Since:
    5.0.0
    • Field Summary

      • Fields inherited from interface org.apereo.cas.authentication.AuthenticationManager

        AUTHENTICATION_METHOD_ATTRIBUTE
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void addAuthenticationMethodAttribute​(org.apereo.cas.authentication.AuthenticationBuilder builder, org.apereo.cas.authentication.Authentication authentication)
      Add authentication method attribute.
      org.apereo.cas.authentication.Authentication authenticate​(org.apereo.cas.authentication.AuthenticationTransaction transaction)  
      protected void authenticateAndResolvePrincipal​(org.apereo.cas.authentication.AuthenticationBuilder builder, org.apereo.cas.authentication.Credential credential, org.apereo.cas.authentication.principal.PrincipalResolver resolver, org.apereo.cas.authentication.AuthenticationHandler handler)
      Authenticate and resolve principal.
      protected org.apereo.cas.authentication.AuthenticationBuilder authenticateInternal​(org.apereo.cas.authentication.AuthenticationTransaction transaction)
      Authenticate internal authentication builder.
      protected org.apache.commons.lang3.tuple.Pair<java.lang.Boolean,java.util.Set<java.lang.Throwable>> evaluateAuthenticationPolicies​(org.apereo.cas.authentication.Authentication authentication, org.apereo.cas.authentication.AuthenticationTransaction transaction)
      Evaluate authentication policies.
      protected void evaluateFinalAuthentication​(org.apereo.cas.authentication.AuthenticationBuilder builder, org.apereo.cas.authentication.AuthenticationTransaction transaction)
      Evaluate produced authentication context.
      protected java.util.Set<org.apereo.cas.authentication.AuthenticationHandler> getAuthenticationHandlersForThisTransaction​(org.apereo.cas.authentication.AuthenticationTransaction transaction)
      Gets authentication handlers for this transaction.
      protected java.util.Collection<org.apereo.cas.authentication.AuthenticationMetaDataPopulator> getAuthenticationMetadataPopulatorsForTransaction​(org.apereo.cas.authentication.AuthenticationTransaction transaction)
      Gets authentication metadata populators for transaction.
      protected org.apereo.cas.authentication.principal.PrincipalResolver getPrincipalResolverLinkedToHandlerIfAny​(org.apereo.cas.authentication.AuthenticationHandler handler, org.apereo.cas.authentication.AuthenticationTransaction transaction)
      Gets principal resolver linked to the handler if any.
      protected void handleAuthenticationException​(java.lang.Throwable ex, java.lang.String name, org.apereo.cas.authentication.AuthenticationBuilder builder)
      Handle authentication exception.
      protected void invokeAuthenticationPostProcessors​(org.apereo.cas.authentication.AuthenticationBuilder builder, org.apereo.cas.authentication.AuthenticationTransaction transaction)
      Populate authentication metadata attributes.
      protected boolean invokeAuthenticationPreProcessors​(org.apereo.cas.authentication.AuthenticationTransaction transaction)
      Invoke authentication pre processors.
      protected void populateAuthenticationMetadataAttributes​(org.apereo.cas.authentication.AuthenticationBuilder builder, org.apereo.cas.authentication.AuthenticationTransaction transaction)
      Populate authentication metadata attributes.
      protected void publishEvent​(org.springframework.context.ApplicationEvent event)
      Publish event.
      protected org.apereo.cas.authentication.principal.Principal resolvePrincipal​(org.apereo.cas.authentication.AuthenticationHandler handler, org.apereo.cas.authentication.principal.PrincipalResolver resolver, org.apereo.cas.authentication.Credential credential, org.apereo.cas.authentication.principal.Principal principal)
      Resolve principal.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PolicyBasedAuthenticationManager

        public PolicyBasedAuthenticationManager()
    • Method Detail

      • invokeAuthenticationPostProcessors

        protected void invokeAuthenticationPostProcessors​(org.apereo.cas.authentication.AuthenticationBuilder builder,
                                                          org.apereo.cas.authentication.AuthenticationTransaction transaction)
        Populate authentication metadata attributes.
        Parameters:
        builder - the builder
        transaction - the transaction
      • populateAuthenticationMetadataAttributes

        protected void populateAuthenticationMetadataAttributes​(org.apereo.cas.authentication.AuthenticationBuilder builder,
                                                                org.apereo.cas.authentication.AuthenticationTransaction transaction)
        Populate authentication metadata attributes.
        Parameters:
        builder - the builder
        transaction - the transaction
      • addAuthenticationMethodAttribute

        protected void addAuthenticationMethodAttribute​(org.apereo.cas.authentication.AuthenticationBuilder builder,
                                                        org.apereo.cas.authentication.Authentication authentication)
        Add authentication method attribute.
        Parameters:
        builder - the builder
        authentication - the authentication
      • resolvePrincipal

        protected org.apereo.cas.authentication.principal.Principal resolvePrincipal​(org.apereo.cas.authentication.AuthenticationHandler handler,
                                                                                     org.apereo.cas.authentication.principal.PrincipalResolver resolver,
                                                                                     org.apereo.cas.authentication.Credential credential,
                                                                                     org.apereo.cas.authentication.principal.Principal principal)
        Resolve principal.
        Parameters:
        handler - the handler name
        resolver - the resolver
        credential - the credential
        principal - the current authenticated principal from a handler, if any.
        Returns:
        the principal
      • authenticate

        public org.apereo.cas.authentication.Authentication authenticate​(org.apereo.cas.authentication.AuthenticationTransaction transaction)
                                                                  throws org.apereo.cas.authentication.AuthenticationException
        Specified by:
        authenticate in interface org.apereo.cas.authentication.AuthenticationManager
        Throws:
        org.apereo.cas.authentication.AuthenticationException
      • invokeAuthenticationPreProcessors

        protected boolean invokeAuthenticationPreProcessors​(org.apereo.cas.authentication.AuthenticationTransaction transaction)
        Invoke authentication pre processors.
        Parameters:
        transaction - the transaction
        Returns:
        the boolean
      • authenticateAndResolvePrincipal

        protected void authenticateAndResolvePrincipal​(org.apereo.cas.authentication.AuthenticationBuilder builder,
                                                       org.apereo.cas.authentication.Credential credential,
                                                       org.apereo.cas.authentication.principal.PrincipalResolver resolver,
                                                       org.apereo.cas.authentication.AuthenticationHandler handler)
                                                throws java.security.GeneralSecurityException,
                                                       org.apereo.cas.authentication.PreventedException
        Authenticate and resolve principal.
        Parameters:
        builder - the builder
        credential - the credential
        resolver - the resolver
        handler - the handler
        Throws:
        java.security.GeneralSecurityException - the general security exception
        org.apereo.cas.authentication.PreventedException - the prevented exception
      • getAuthenticationHandlersForThisTransaction

        protected java.util.Set<org.apereo.cas.authentication.AuthenticationHandler> getAuthenticationHandlersForThisTransaction​(org.apereo.cas.authentication.AuthenticationTransaction transaction)
        Gets authentication handlers for this transaction.
        Parameters:
        transaction - the transaction
        Returns:
        the authentication handlers for this transaction
      • getPrincipalResolverLinkedToHandlerIfAny

        protected org.apereo.cas.authentication.principal.PrincipalResolver getPrincipalResolverLinkedToHandlerIfAny​(org.apereo.cas.authentication.AuthenticationHandler handler,
                                                                                                                     org.apereo.cas.authentication.AuthenticationTransaction transaction)
        Gets principal resolver linked to the handler if any.
        Parameters:
        handler - the handler
        transaction - the transaction
        Returns:
        the principal resolver linked to handler if any, or null.
      • getAuthenticationMetadataPopulatorsForTransaction

        protected java.util.Collection<org.apereo.cas.authentication.AuthenticationMetaDataPopulator> getAuthenticationMetadataPopulatorsForTransaction​(org.apereo.cas.authentication.AuthenticationTransaction transaction)
        Gets authentication metadata populators for transaction.
        Parameters:
        transaction - the transaction
        Returns:
        the authentication metadata populators for transaction
      • publishEvent

        protected void publishEvent​(org.springframework.context.ApplicationEvent event)
        Publish event.
        Parameters:
        event - the event
      • authenticateInternal

        protected org.apereo.cas.authentication.AuthenticationBuilder authenticateInternal​(org.apereo.cas.authentication.AuthenticationTransaction transaction)
                                                                                    throws org.apereo.cas.authentication.AuthenticationException
        Authenticate internal authentication builder.
        Parameters:
        transaction - the transaction
        Returns:
        the authentication builder
        Throws:
        org.apereo.cas.authentication.AuthenticationException - the authentication exception
      • evaluateFinalAuthentication

        protected void evaluateFinalAuthentication​(org.apereo.cas.authentication.AuthenticationBuilder builder,
                                                   org.apereo.cas.authentication.AuthenticationTransaction transaction)
                                            throws org.apereo.cas.authentication.AuthenticationException
        Evaluate produced authentication context. We apply an implicit security policy of at least one successful authentication. Then, we apply the configured security policy.
        Parameters:
        builder - the builder
        transaction - the transaction
        Throws:
        org.apereo.cas.authentication.AuthenticationException - the authentication exception
      • evaluateAuthenticationPolicies

        protected org.apache.commons.lang3.tuple.Pair<java.lang.Boolean,java.util.Set<java.lang.Throwable>> evaluateAuthenticationPolicies​(org.apereo.cas.authentication.Authentication authentication,
                                                                                                                                           org.apereo.cas.authentication.AuthenticationTransaction transaction)
        Evaluate authentication policies.
        Parameters:
        authentication - the authentication
        transaction - the transaction
        Returns:
        true /false
      • handleAuthenticationException

        protected void handleAuthenticationException​(java.lang.Throwable ex,
                                                     java.lang.String name,
                                                     org.apereo.cas.authentication.AuthenticationBuilder builder)
        Handle authentication exception.
        Parameters:
        ex - the exception
        name - the name
        builder - the builder