Class JaasAuthenticationHandler

  • All Implemented Interfaces:
    org.apereo.cas.authentication.AuthenticationHandler, org.apereo.cas.authentication.PrePostAuthenticationHandler, org.springframework.core.Ordered

    public class JaasAuthenticationHandler
    extends AbstractUsernamePasswordAuthenticationHandler
    JAAS Authentication Handler for CAAS. This is a simple bridge from CAS' authentication to JAAS.

    Using the JAAS Authentication Handler requires you to configure the appropriate JAAS modules. You can specify the location of a jass.conf file using the following VM parameter:

     -Djava.security.auth.login.config=$PATH_TO_JAAS_CONF/jaas.conf
     

    This example jaas.conf would try Kerberos based authentication, then try LDAP authentication:

     CAS {
       com.sun.security.auth.module.Krb5LoginModule sufficient
         client=TRUE
         debug=FALSE
         useTicketCache=FALSE;
       edu.uconn.netid.jaas.LDAPLoginModule sufficient
         java.naming.provider.url="ldap://ldapserver.my.edu:389/dc=my,dc=edu"
         java.naming.security.principal="uid=jaasauth,dc=my,dc=edu"
         java.naming.security.credentials="password"
         Attribute="uid"
         startTLS="true";
     };
     
    Since:
    3.0.0
    See Also:
    CallbackHandler, PasswordCallback, NameCallback
    • Constructor Detail

      • JaasAuthenticationHandler

        public JaasAuthenticationHandler​(java.lang.String name,
                                         org.apereo.cas.services.ServicesManager servicesManager,
                                         org.apereo.cas.authentication.principal.PrincipalFactory principalFactory,
                                         java.lang.Integer order)
        Instantiates a new Jaas authentication handler, and attempts to load/verify the configuration.
        Parameters:
        name - the name
        servicesManager - the services manager
        principalFactory - the principal factory
        order - the order
    • Method Detail

      • authenticateUsernamePasswordInternal

        protected org.apereo.cas.authentication.AuthenticationHandlerExecutionResult authenticateUsernamePasswordInternal​(UsernamePasswordCredential credential,
                                                                                                                          java.lang.String originalPassword)
                                                                                                                   throws java.security.GeneralSecurityException
        Description copied from class: AbstractUsernamePasswordAuthenticationHandler
        Authenticates a username/password credential by an arbitrary strategy with extra parameter original credential password before encoding password. Override it if implementation need to use original password for authentication.
        Specified by:
        authenticateUsernamePasswordInternal in class AbstractUsernamePasswordAuthenticationHandler
        Parameters:
        credential - the credential object bearing the transformed username and password.
        originalPassword - original password from credential before password encoding
        Returns:
        AuthenticationHandlerExecutionResult resolved from credential on authentication success or null if no principal could be resolved from the credential.
        Throws:
        java.security.GeneralSecurityException - On authentication failure.
      • authenticateAndGetPrincipal

        protected org.apereo.cas.authentication.principal.Principal authenticateAndGetPrincipal​(UsernamePasswordCredential credential)
                                                                                         throws java.security.GeneralSecurityException
        Authenticate and get principal principal.
        Parameters:
        credential - the credential
        Returns:
        the principal
        Throws:
        java.security.GeneralSecurityException - the general security exception
      • getLoginContext

        protected javax.security.auth.login.LoginContext getLoginContext​(UsernamePasswordCredential credential)
                                                                  throws java.security.GeneralSecurityException
        Gets login context.
        Parameters:
        credential - the credential
        Returns:
        the login context
        Throws:
        java.security.GeneralSecurityException - the general security exception