Search in sources :

Example 1 with AuthenticatorEnrollments

use of com.okta.idx.sdk.api.model.AuthenticatorEnrollments in project okta-idx-java by okta.

the class IDXAuthenticationWrapper method enrollAuthenticator.

public AuthenticationResponse enrollAuthenticator(ProceedContext proceedContext, String authenticatorId) {
    try {
        AuthenticationResponse authenticationResponse = AuthenticationTransaction.proceed(client, proceedContext, () -> {
            Authenticator authenticator = new Authenticator();
            authenticator.setId(authenticatorId);
            EnrollRequest enrollRequest = EnrollRequestBuilder.builder().withAuthenticator(authenticator).withStateHandle(proceedContext.getStateHandle()).build();
            return client.enroll(enrollRequest, proceedContext.getHref());
        }).asAuthenticationResponse();
        if (authenticationResponse.getWebAuthnParams() != null) {
            AuthenticatorEnrollments authenticatorEnrollments = authenticationResponse.getAuthenticatorEnrollments();
            Optional<AuthenticatorEnrollment> authenticatorEnrollmentOptional = authenticatorEnrollments.stream().filter(x -> "security_key".equals(x.getType())).findAny();
            authenticatorEnrollmentOptional.ifPresent(authenticatorEnrollment -> authenticationResponse.getWebAuthnParams().setWebauthnCredentialId(authenticatorEnrollment.getCredentialId()));
        }
        return authenticationResponse;
    } catch (ProcessingException e) {
        return handleProcessingException(e);
    } catch (IllegalArgumentException e) {
        return handleIllegalArgumentException(e);
    }
}
Also used : DeviceContext(com.okta.idx.sdk.api.model.DeviceContext) Arrays(java.util.Arrays) ChallengeRequestBuilder(com.okta.idx.sdk.api.request.ChallengeRequestBuilder) SkipAuthenticatorEnrollmentRequest(com.okta.idx.sdk.api.request.SkipAuthenticatorEnrollmentRequest) AuthenticationResponse(com.okta.idx.sdk.api.response.AuthenticationResponse) LoggerFactory(org.slf4j.LoggerFactory) IdentifyRequest(com.okta.idx.sdk.api.request.IdentifyRequest) ProcessingException(com.okta.idx.sdk.api.exception.ProcessingException) SkipAuthenticatorEnrollmentRequestBuilder(com.okta.idx.sdk.api.request.SkipAuthenticatorEnrollmentRequestBuilder) ErrorResponse(com.okta.idx.sdk.api.response.ErrorResponse) Recover(com.okta.idx.sdk.api.model.Recover) IDXResponse(com.okta.idx.sdk.api.response.IDXResponse) Map(java.util.Map) ClientUtil(com.okta.idx.sdk.api.util.ClientUtil) EnrollUserProfileUpdateRequestBuilder(com.okta.idx.sdk.api.request.EnrollUserProfileUpdateRequestBuilder) Assert(com.okta.commons.lang.Assert) RemediationOption(com.okta.idx.sdk.api.model.RemediationOption) Set(java.util.Set) AuthenticationStatus(com.okta.idx.sdk.api.model.AuthenticationStatus) Response(com.okta.commons.http.Response) WrapperUtil.handleProcessingException(com.okta.idx.sdk.api.client.WrapperUtil.handleProcessingException) EnrollRequestBuilder(com.okta.idx.sdk.api.request.EnrollRequestBuilder) Collectors(java.util.stream.Collectors) WebAuthnRequest(com.okta.idx.sdk.api.request.WebAuthnRequest) List(java.util.List) Optional(java.util.Optional) AuthenticatorEnrollment(com.okta.idx.sdk.api.model.AuthenticatorEnrollment) AnswerChallengeRequest(com.okta.idx.sdk.api.request.AnswerChallengeRequest) EnrollUserProfileUpdateRequest(com.okta.idx.sdk.api.request.EnrollUserProfileUpdateRequest) UserProfile(com.okta.idx.sdk.api.model.UserProfile) EnrollRequest(com.okta.idx.sdk.api.request.EnrollRequest) TokenType(com.okta.idx.sdk.api.model.TokenType) VerifyChannelDataOptions(com.okta.idx.sdk.api.model.VerifyChannelDataOptions) ChallengeRequest(com.okta.idx.sdk.api.request.ChallengeRequest) Authenticator(com.okta.idx.sdk.api.model.Authenticator) IdentifyRequestBuilder(com.okta.idx.sdk.api.request.IdentifyRequestBuilder) VerifyAuthenticatorOptions(com.okta.idx.sdk.api.model.VerifyAuthenticatorOptions) AnswerChallengeRequestBuilder(com.okta.idx.sdk.api.request.AnswerChallengeRequestBuilder) RecoverRequest(com.okta.idx.sdk.api.request.RecoverRequest) VerifyAuthenticatorAnswer(com.okta.idx.sdk.api.model.VerifyAuthenticatorAnswer) Logger(org.slf4j.Logger) PollRequestBuilder(com.okta.idx.sdk.api.request.PollRequestBuilder) Credentials(com.okta.idx.sdk.api.model.Credentials) FormValue(com.okta.idx.sdk.api.model.FormValue) RemediationType(com.okta.idx.sdk.api.model.RemediationType) WrapperUtil.handleIllegalArgumentException(com.okta.idx.sdk.api.client.WrapperUtil.handleIllegalArgumentException) AuthenticationOptions(com.okta.idx.sdk.api.model.AuthenticationOptions) EmailTokenType(com.okta.idx.sdk.api.model.EmailTokenType) RecoverRequestBuilder(com.okta.idx.sdk.api.request.RecoverRequestBuilder) AuthenticatorEnrollments(com.okta.idx.sdk.api.model.AuthenticatorEnrollments) IDXClientContext(com.okta.idx.sdk.api.model.IDXClientContext) TokenResponse(com.okta.idx.sdk.api.response.TokenResponse) PollRequest(com.okta.idx.sdk.api.request.PollRequest) PollInfo(com.okta.idx.sdk.api.model.PollInfo) AuthenticatorEnrollment(com.okta.idx.sdk.api.model.AuthenticatorEnrollment) EnrollRequest(com.okta.idx.sdk.api.request.EnrollRequest) AuthenticatorEnrollments(com.okta.idx.sdk.api.model.AuthenticatorEnrollments) AuthenticationResponse(com.okta.idx.sdk.api.response.AuthenticationResponse) Authenticator(com.okta.idx.sdk.api.model.Authenticator) 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

Response (com.okta.commons.http.Response)1 Assert (com.okta.commons.lang.Assert)1 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 AuthenticationOptions (com.okta.idx.sdk.api.model.AuthenticationOptions)1 AuthenticationStatus (com.okta.idx.sdk.api.model.AuthenticationStatus)1 Authenticator (com.okta.idx.sdk.api.model.Authenticator)1 AuthenticatorEnrollment (com.okta.idx.sdk.api.model.AuthenticatorEnrollment)1 AuthenticatorEnrollments (com.okta.idx.sdk.api.model.AuthenticatorEnrollments)1 Credentials (com.okta.idx.sdk.api.model.Credentials)1 DeviceContext (com.okta.idx.sdk.api.model.DeviceContext)1 EmailTokenType (com.okta.idx.sdk.api.model.EmailTokenType)1 FormValue (com.okta.idx.sdk.api.model.FormValue)1 IDXClientContext (com.okta.idx.sdk.api.model.IDXClientContext)1 PollInfo (com.okta.idx.sdk.api.model.PollInfo)1 Recover (com.okta.idx.sdk.api.model.Recover)1 RemediationOption (com.okta.idx.sdk.api.model.RemediationOption)1 RemediationType (com.okta.idx.sdk.api.model.RemediationType)1 TokenType (com.okta.idx.sdk.api.model.TokenType)1