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);
}
}
Aggregations