Search in sources :

Example 1 with AnswerChallengeRequestBuilder

use of com.okta.idx.sdk.api.request.AnswerChallengeRequestBuilder in project okta-idx-java by okta.

the class IDXAuthenticationWrapper method verifyAuthenticator.

public AuthenticationResponse verifyAuthenticator(ProceedContext proceedContext, VerifyChannelDataOptions verifyChannelDataOptions) {
    try {
        AnswerChallengeRequestBuilder builder = AnswerChallengeRequestBuilder.builder().withStateHandle(proceedContext.getStateHandle());
        if ("phoneNumber".equals(verifyChannelDataOptions.getChannelName())) {
            builder.withPhoneNumber(verifyChannelDataOptions.getValue());
        }
        if ("email".equals(verifyChannelDataOptions.getChannelName())) {
            builder.withEmail(verifyChannelDataOptions.getValue());
        }
        if ("totp".equals(verifyChannelDataOptions.getChannelName())) {
            Credentials credentials = new Credentials();
            credentials.setTotp(verifyChannelDataOptions.getValue());
            builder.withCredentials(credentials);
        }
        AnswerChallengeRequest challengeAuthenticatorRequest = builder.build();
        return AuthenticationTransaction.proceed(client, proceedContext, () -> client.answerChallenge(challengeAuthenticatorRequest, proceedContext.getHref())).asAuthenticationResponse(AuthenticationStatus.AWAITING_POLL_ENROLLMENT);
    } catch (ProcessingException e) {
        return handleProcessingException(e);
    } catch (IllegalArgumentException e) {
        return handleIllegalArgumentException(e);
    }
}
Also used : AnswerChallengeRequest(com.okta.idx.sdk.api.request.AnswerChallengeRequest) AnswerChallengeRequestBuilder(com.okta.idx.sdk.api.request.AnswerChallengeRequestBuilder) Credentials(com.okta.idx.sdk.api.model.Credentials) WrapperUtil.handleIllegalArgumentException(com.okta.idx.sdk.api.client.WrapperUtil.handleIllegalArgumentException) ProcessingException(com.okta.idx.sdk.api.exception.ProcessingException) WrapperUtil.handleProcessingException(com.okta.idx.sdk.api.client.WrapperUtil.handleProcessingException)

Aggregations

WrapperUtil.handleIllegalArgumentException (com.okta.idx.sdk.api.client.WrapperUtil.handleIllegalArgumentException)1 WrapperUtil.handleProcessingException (com.okta.idx.sdk.api.client.WrapperUtil.handleProcessingException)1 ProcessingException (com.okta.idx.sdk.api.exception.ProcessingException)1 Credentials (com.okta.idx.sdk.api.model.Credentials)1 AnswerChallengeRequest (com.okta.idx.sdk.api.request.AnswerChallengeRequest)1 AnswerChallengeRequestBuilder (com.okta.idx.sdk.api.request.AnswerChallengeRequestBuilder)1