Search in sources :

Example 21 with BasicCredentialMetaData

use of org.apereo.cas.authentication.metadata.BasicCredentialMetaData in project cas by apereo.

the class TestOneTimePasswordAuthenticationHandler method authenticate.

@Override
public AuthenticationHandlerExecutionResult authenticate(final Credential credential) throws GeneralSecurityException {
    val otp = (OneTimePasswordCredential) credential;
    val valueOnRecord = credentialMap.get(otp.getId());
    if (otp.getPassword().equals(valueOnRecord)) {
        return new DefaultAuthenticationHandlerExecutionResult(this, new BasicCredentialMetaData(otp), getPrincipalFactory().createPrincipal(otp.getId()));
    }
    throw new FailedLoginException();
}
Also used : lombok.val(lombok.val) FailedLoginException(javax.security.auth.login.FailedLoginException) OneTimePasswordCredential(org.apereo.cas.authentication.credential.OneTimePasswordCredential) DefaultAuthenticationHandlerExecutionResult(org.apereo.cas.authentication.DefaultAuthenticationHandlerExecutionResult) BasicCredentialMetaData(org.apereo.cas.authentication.metadata.BasicCredentialMetaData)

Aggregations

lombok.val (lombok.val)21 BasicCredentialMetaData (org.apereo.cas.authentication.metadata.BasicCredentialMetaData)21 DefaultAuthenticationHandlerExecutionResult (org.apereo.cas.authentication.DefaultAuthenticationHandlerExecutionResult)12 UsernamePasswordCredential (org.apereo.cas.authentication.credential.UsernamePasswordCredential)8 SimpleTestUsernamePasswordAuthenticationHandler (org.apereo.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler)7 FailedLoginException (javax.security.auth.login.FailedLoginException)6 Test (org.junit.jupiter.api.Test)6 GeneralSecurityException (java.security.GeneralSecurityException)3 HashMap (java.util.HashMap)3 DefaultAuthenticationBuilder (org.apereo.cas.authentication.DefaultAuthenticationBuilder)3 BasicIdentifiableCredential (org.apereo.cas.authentication.credential.BasicIdentifiableCredential)3 DefaultMessageDescriptor (org.apereo.cas.DefaultMessageDescriptor)2 SpnegoCredential (org.apereo.cas.support.spnego.authentication.principal.SpnegoCredential)2 LinkedHashMap (java.util.LinkedHashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 AccountNotFoundException (javax.security.auth.login.AccountNotFoundException)1 Type1Message (jcifs.ntlmssp.Type1Message)1 Type2Message (jcifs.ntlmssp.Type2Message)1 Type3Message (jcifs.ntlmssp.Type3Message)1 NtlmPasswordAuthentication (jcifs.smb.NtlmPasswordAuthentication)1