@ Nonnull public static AuthIdentificationResult validateLoginCredentialsAndCreateToken ( @ Nonnull final IAuthCredentials aCredentials ) { ValueEnforcer . notNull ( aCredentials , "Credentials" ) ; // validate credentials final ICredentialValidationResult aValidationResult = AuthCredentialValidatorManager . validateCredentials ( aCredentials ) ; if ( aValidationResult . isFailure ( ) ) { if ( LOGGER . isWarnEnabled ( ) ) LOGGER . warn ( "Credentials have been rejected: " + aCredentials ) ; return AuthIdentificationResult . createFailure ( aValidationResult ) ; } if ( LOGGER . isDebugEnabled ( ) ) LOGGER . debug ( "Credentials have been accepted: " + aCredentials ) ; // try to get AuthSubject from passed credentials final IAuthSubject aSubject = AuthCredentialToSubjectResolverManager . getSubjectFromCredentials ( aCredentials ) ; if ( aSubject != null ) { if ( LOGGER . isDebugEnabled ( ) ) LOGGER . debug ( "Credentials " + aCredentials + " correspond to subject " + aSubject ) ; } else { if ( LOGGER . isErrorEnabled ( ) ) LOGGER . error ( "Failed to resolve credentials " + aCredentials + " to an auth subject!" ) ; } // Create the identification element final AuthIdentification aIdentification = new AuthIdentification ( aSubject ) ; // create the token (without expiration seconds) final IAuthToken aNewAuthToken = AuthTokenRegistry . createToken ( aIdentification , IAuthToken . EXPIRATION_SECONDS_INFINITE ) ; return AuthIdentificationResult . createSuccess ( aNewAuthToken ) ; }
Validate the login credentials try to resolve the subject and create a token upon success .