Search in sources :

Example 1 with PFAuthResult

use of net.phonefactor.pfsdk.PFAuthResult in project cas by apereo.

the class AzureAuthenticatorAuthenticationHandler method doAuthentication.

@Override
protected HandlerResult doAuthentication(final Credential credential) throws GeneralSecurityException, PreventedException {
    try {
        final AzureAuthenticatorTokenCredential c = (AzureAuthenticatorTokenCredential) credential;
        final RequestContext context = RequestContextHolder.getRequestContext();
        final Principal principal = WebUtils.getAuthentication(context).getPrincipal();
        LOGGER.debug("Received principal id [{}]", principal.getId());
        final PFAuthParams params = authenticationRequestBuilder.build(principal, c);
        final PFAuthResult r = azureAuthenticatorInstance.authenticate(params);
        if (r.getAuthenticated()) {
            return createHandlerResult(c, principalFactory.createPrincipal(principal.getId()), null);
        }
        LOGGER.error("Authentication failed. Call status: [{}]-[{}]. Error: [{}]", r.getCallStatus(), r.getCallStatusString(), r.getMessageError());
    } catch (final Exception e) {
        LOGGER.error(e.getMessage(), e);
    }
    throw new FailedLoginException("Failed to authenticate user");
}
Also used : FailedLoginException(javax.security.auth.login.FailedLoginException) PFAuthResult(net.phonefactor.pfsdk.PFAuthResult) RequestContext(org.springframework.webflow.execution.RequestContext) PFAuthParams(net.phonefactor.pfsdk.PFAuthParams) Principal(org.apereo.cas.authentication.principal.Principal) GeneralSecurityException(java.security.GeneralSecurityException) FailedLoginException(javax.security.auth.login.FailedLoginException) PreventedException(org.apereo.cas.authentication.PreventedException)

Aggregations

GeneralSecurityException (java.security.GeneralSecurityException)1 FailedLoginException (javax.security.auth.login.FailedLoginException)1 PFAuthParams (net.phonefactor.pfsdk.PFAuthParams)1 PFAuthResult (net.phonefactor.pfsdk.PFAuthResult)1 PreventedException (org.apereo.cas.authentication.PreventedException)1 Principal (org.apereo.cas.authentication.principal.Principal)1 RequestContext (org.springframework.webflow.execution.RequestContext)1