Search in sources :

Example 11 with ProcessingException

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);
    }
}
Also used : EnrollUserProfileUpdateRequest(com.okta.idx.sdk.api.request.EnrollUserProfileUpdateRequest) 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)

Example 12 with ProcessingException

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);
    }
}
Also used : AnswerChallengeRequest(com.okta.idx.sdk.api.request.AnswerChallengeRequest) 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)

Example 13 with ProcessingException

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

Example 14 with ProcessingException

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;
}
Also used : TokenResponse(com.okta.idx.sdk.api.response.TokenResponse) AuthenticationResponse(com.okta.idx.sdk.api.response.AuthenticationResponse) ProcessingException(com.okta.idx.sdk.api.exception.ProcessingException) WrapperUtil.handleProcessingException(com.okta.idx.sdk.api.client.WrapperUtil.handleProcessingException)

Example 15 with ProcessingException

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);
    }
}
Also used : AnswerChallengeRequest(com.okta.idx.sdk.api.request.AnswerChallengeRequest) 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

ProcessingException (com.okta.idx.sdk.api.exception.ProcessingException)28 AnswerChallengeRequest (com.okta.idx.sdk.api.request.AnswerChallengeRequest)21 IdentifyRequest (com.okta.idx.sdk.api.request.IdentifyRequest)18 EnrollRequest (com.okta.idx.sdk.api.request.EnrollRequest)17 EnrollUserProfileUpdateRequest (com.okta.idx.sdk.api.request.EnrollUserProfileUpdateRequest)17 RecoverRequest (com.okta.idx.sdk.api.request.RecoverRequest)17 ErrorResponse (com.okta.idx.sdk.api.response.ErrorResponse)17 ChallengeRequest (com.okta.idx.sdk.api.request.ChallengeRequest)16 PollRequest (com.okta.idx.sdk.api.request.PollRequest)16 SkipAuthenticatorEnrollmentRequest (com.okta.idx.sdk.api.request.SkipAuthenticatorEnrollmentRequest)16 IDXResponse (com.okta.idx.sdk.api.response.IDXResponse)15 TokenResponse (com.okta.idx.sdk.api.response.TokenResponse)15 DefaultRequest (com.okta.commons.http.DefaultRequest)14 HttpException (com.okta.commons.http.HttpException)14 Request (com.okta.commons.http.Request)14 Response (com.okta.commons.http.Response)14 CancelRequest (com.okta.idx.sdk.api.request.CancelRequest)14 IntrospectRequest (com.okta.idx.sdk.api.request.IntrospectRequest)14 ByteArrayInputStream (java.io.ByteArrayInputStream)14 JsonNode (com.fasterxml.jackson.databind.JsonNode)13