use of com.okta.idx.sdk.api.exception.ProcessingException in project okta-idx-java by okta.
the class IDXAuthenticationWrapper method register.
/**
* Register new user with the supplied user profile reference.
*
* @param proceedContext the ProceedContext
* @param userProfile the user profile
* @return the Authentication response
*/
public AuthenticationResponse register(ProceedContext proceedContext, UserProfile userProfile) {
try {
AuthenticationTransaction enrollTransaction = AuthenticationTransaction.proceed(client, proceedContext, () -> {
EnrollUserProfileUpdateRequest enrollUserProfileUpdateRequest = EnrollUserProfileUpdateRequestBuilder.builder().withUserProfile(userProfile).withStateHandle(proceedContext.getStateHandle()).build();
return client.enrollUpdateUserProfile(enrollUserProfileUpdateRequest, proceedContext.getHref());
});
// Verify the next remediation is correct.
enrollTransaction.getRemediationOption(RemediationType.SELECT_AUTHENTICATOR_ENROLL);
return enrollTransaction.asAuthenticationResponse(AuthenticationStatus.AWAITING_AUTHENTICATOR_SELECTION);
} catch (ProcessingException e) {
return handleProcessingException(e);
} catch (IllegalArgumentException e) {
return handleIllegalArgumentException(e);
}
}
use of com.okta.idx.sdk.api.exception.ProcessingException in project okta-idx-java by okta.
the class IDXAuthenticationWrapper method verifyWebAuthn.
/**
* Verify Webauthn Authenticator.
*
* @param proceedContext the ProceedContext
* @param webauthnRequest object
* @return the Authentication response
*/
public AuthenticationResponse verifyWebAuthn(ProceedContext proceedContext, WebAuthnRequest webauthnRequest) {
try {
Credentials credentials = new Credentials();
credentials.setClientData(webauthnRequest.getClientData());
if (webauthnRequest.getAttestation() != null)
credentials.setAttestation(webauthnRequest.getAttestation());
if (webauthnRequest.getAuthenticatorData() != null)
credentials.setAuthenticatorData(webauthnRequest.getAuthenticatorData());
if (webauthnRequest.getSignatureData() != null)
credentials.setSignatureData(webauthnRequest.getSignatureData());
AnswerChallengeRequest challengeAuthenticatorRequest = AnswerChallengeRequestBuilder.builder().withStateHandle(proceedContext.getStateHandle()).withCredentials(credentials).build();
return AuthenticationTransaction.proceed(client, proceedContext, () -> client.answerChallenge(challengeAuthenticatorRequest, proceedContext.getHref())).asAuthenticationResponse();
} catch (ProcessingException e) {
return handleProcessingException(e);
} catch (IllegalArgumentException e) {
return handleIllegalArgumentException(e);
}
}
use of com.okta.idx.sdk.api.exception.ProcessingException 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);
}
}
use of com.okta.idx.sdk.api.exception.ProcessingException in project okta-idx-java by okta.
the class IDXAuthenticationWrapper method fetchTokenWithInteractionCode.
/**
* Exchange interaction code for token.
* @deprecated the {@code issuer} param is automatically resolved.
*/
@Deprecated
public AuthenticationResponse fetchTokenWithInteractionCode(String issuer, ProceedContext proceedContext, String interactionCode) {
AuthenticationResponse authenticationResponse = new AuthenticationResponse();
try {
TokenResponse tokenResponse = client.token(ClientUtil.normalizedIssuerUri(issuer, "/v1/token"), "interaction_code", interactionCode, proceedContext.getClientContext());
authenticationResponse.setTokenResponse(tokenResponse);
} catch (ProcessingException e) {
return handleProcessingException(e);
}
return authenticationResponse;
}
use of com.okta.idx.sdk.api.exception.ProcessingException in project okta-idx-java by okta.
the class IDXAuthenticationWrapper method verifyAuthenticator.
/**
* Verify Authenticator with the supplied authenticator options.
*
* @param proceedContext the ProceedContext
* @param verifyAuthenticatorAnswer the verify Authenticator answer
* @return the Authentication response
*/
public AuthenticationResponse verifyAuthenticator(ProceedContext proceedContext, VerifyAuthenticatorAnswer verifyAuthenticatorAnswer) {
try {
Credentials credentials = new Credentials();
credentials.setQuestionKey(verifyAuthenticatorAnswer.getQuestionKey());
credentials.setAnswer(verifyAuthenticatorAnswer.getAnswer().toCharArray());
// build answer password authenticator challenge request
AnswerChallengeRequest challengeAuthenticatorRequest = AnswerChallengeRequestBuilder.builder().withStateHandle(proceedContext.getStateHandle()).withCredentials(credentials).build();
return AuthenticationTransaction.proceed(client, proceedContext, () -> client.answerChallenge(challengeAuthenticatorRequest, proceedContext.getHref())).asAuthenticationResponse(AuthenticationStatus.AWAITING_PASSWORD_RESET);
} catch (ProcessingException e) {
return handleProcessingException(e);
} catch (IllegalArgumentException e) {
return handleIllegalArgumentException(e);
}
}
Aggregations