Search in sources :

Example 1 with IDXResponse

use of com.okta.idx.sdk.api.response.IDXResponse in project okta-idx-java by okta.

the class BaseIDXClient method answerChallenge.

@Override
public IDXResponse answerChallenge(AnswerChallengeRequest answerChallengeRequest, String href) throws ProcessingException {
    IDXResponse idxResponse;
    try {
        Request request = new DefaultRequest(HttpMethod.POST, href, null, getHttpHeaders(false), new ByteArrayInputStream(objectMapper.writeValueAsBytes(answerChallengeRequest)), -1L);
        Response response = requestExecutor.executeRequest(request);
        if (response.getHttpStatus() != 200) {
            handleErrorResponse(request, response);
        }
        JsonNode responseJsonNode = objectMapper.readTree(response.getBody());
        idxResponse = objectMapper.convertValue(responseJsonNode, IDXResponse.class);
    } catch (IOException | HttpException e) {
        throw new ProcessingException(e);
    }
    return idxResponse;
}
Also used : ErrorResponse(com.okta.idx.sdk.api.response.ErrorResponse) IDXResponse(com.okta.idx.sdk.api.response.IDXResponse) InteractResponse(com.okta.idx.sdk.api.response.InteractResponse) Response(com.okta.commons.http.Response) TokenResponse(com.okta.idx.sdk.api.response.TokenResponse) DefaultRequest(com.okta.commons.http.DefaultRequest) ByteArrayInputStream(java.io.ByteArrayInputStream) SkipAuthenticatorEnrollmentRequest(com.okta.idx.sdk.api.request.SkipAuthenticatorEnrollmentRequest) Request(com.okta.commons.http.Request) IdentifyRequest(com.okta.idx.sdk.api.request.IdentifyRequest) EnrollUserProfileUpdateRequest(com.okta.idx.sdk.api.request.EnrollUserProfileUpdateRequest) DefaultRequest(com.okta.commons.http.DefaultRequest) EnrollRequest(com.okta.idx.sdk.api.request.EnrollRequest) ChallengeRequest(com.okta.idx.sdk.api.request.ChallengeRequest) CancelRequest(com.okta.idx.sdk.api.request.CancelRequest) RecoverRequest(com.okta.idx.sdk.api.request.RecoverRequest) IntrospectRequest(com.okta.idx.sdk.api.request.IntrospectRequest) AnswerChallengeRequest(com.okta.idx.sdk.api.request.AnswerChallengeRequest) PollRequest(com.okta.idx.sdk.api.request.PollRequest) JsonNode(com.fasterxml.jackson.databind.JsonNode) HttpException(com.okta.commons.http.HttpException) IOException(java.io.IOException) IDXResponse(com.okta.idx.sdk.api.response.IDXResponse) ProcessingException(com.okta.idx.sdk.api.exception.ProcessingException)

Example 2 with IDXResponse

use of com.okta.idx.sdk.api.response.IDXResponse in project okta-idx-java by okta.

the class BaseIDXClient method cancel.

@Override
public IDXResponse cancel(String stateHandle) throws ProcessingException {
    IDXResponse idxResponse;
    CancelRequest cancelRequest = CancelRequestBuilder.builder().withStateHandle(stateHandle).build();
    try {
        Request request = new DefaultRequest(HttpMethod.POST, clientConfiguration.getBaseUrl() + "/idp/idx/cancel", null, getHttpHeaders(false), new ByteArrayInputStream(objectMapper.writeValueAsBytes(cancelRequest)), -1L);
        Response response = requestExecutor.executeRequest(request);
        if (response.getHttpStatus() != 200) {
            handleErrorResponse(request, response);
        }
        JsonNode responseJsonNode = objectMapper.readTree(response.getBody());
        idxResponse = objectMapper.convertValue(responseJsonNode, IDXResponse.class);
    } catch (IOException | HttpException e) {
        throw new ProcessingException(e);
    }
    return idxResponse;
}
Also used : ErrorResponse(com.okta.idx.sdk.api.response.ErrorResponse) IDXResponse(com.okta.idx.sdk.api.response.IDXResponse) InteractResponse(com.okta.idx.sdk.api.response.InteractResponse) Response(com.okta.commons.http.Response) TokenResponse(com.okta.idx.sdk.api.response.TokenResponse) DefaultRequest(com.okta.commons.http.DefaultRequest) ByteArrayInputStream(java.io.ByteArrayInputStream) SkipAuthenticatorEnrollmentRequest(com.okta.idx.sdk.api.request.SkipAuthenticatorEnrollmentRequest) Request(com.okta.commons.http.Request) IdentifyRequest(com.okta.idx.sdk.api.request.IdentifyRequest) EnrollUserProfileUpdateRequest(com.okta.idx.sdk.api.request.EnrollUserProfileUpdateRequest) DefaultRequest(com.okta.commons.http.DefaultRequest) EnrollRequest(com.okta.idx.sdk.api.request.EnrollRequest) ChallengeRequest(com.okta.idx.sdk.api.request.ChallengeRequest) CancelRequest(com.okta.idx.sdk.api.request.CancelRequest) RecoverRequest(com.okta.idx.sdk.api.request.RecoverRequest) IntrospectRequest(com.okta.idx.sdk.api.request.IntrospectRequest) AnswerChallengeRequest(com.okta.idx.sdk.api.request.AnswerChallengeRequest) PollRequest(com.okta.idx.sdk.api.request.PollRequest) CancelRequest(com.okta.idx.sdk.api.request.CancelRequest) JsonNode(com.fasterxml.jackson.databind.JsonNode) HttpException(com.okta.commons.http.HttpException) IOException(java.io.IOException) IDXResponse(com.okta.idx.sdk.api.response.IDXResponse) ProcessingException(com.okta.idx.sdk.api.exception.ProcessingException)

Example 3 with IDXResponse

use of com.okta.idx.sdk.api.response.IDXResponse in project okta-idx-java by okta.

the class BaseIDXClient method introspect.

@Override
public IDXResponse introspect(IDXClientContext idxClientContext) throws ProcessingException {
    IDXResponse idxResponse;
    IntrospectRequest introspectRequest = new IntrospectRequest(idxClientContext.getInteractionHandle());
    try {
        Request request = new DefaultRequest(HttpMethod.POST, clientConfiguration.getBaseUrl() + "/idp/idx/introspect", null, getHttpHeaders(false), new ByteArrayInputStream(objectMapper.writeValueAsBytes(introspectRequest)), -1L);
        Response response = requestExecutor.executeRequest(request);
        if (response.getHttpStatus() != 200) {
            handleErrorResponse(request, response);
        }
        JsonNode responseJsonNode = objectMapper.readTree(response.getBody());
        idxResponse = objectMapper.convertValue(responseJsonNode, IDXResponse.class);
    } catch (IOException | HttpException e) {
        throw new ProcessingException(e);
    }
    return idxResponse;
}
Also used : ErrorResponse(com.okta.idx.sdk.api.response.ErrorResponse) IDXResponse(com.okta.idx.sdk.api.response.IDXResponse) InteractResponse(com.okta.idx.sdk.api.response.InteractResponse) Response(com.okta.commons.http.Response) TokenResponse(com.okta.idx.sdk.api.response.TokenResponse) DefaultRequest(com.okta.commons.http.DefaultRequest) ByteArrayInputStream(java.io.ByteArrayInputStream) SkipAuthenticatorEnrollmentRequest(com.okta.idx.sdk.api.request.SkipAuthenticatorEnrollmentRequest) Request(com.okta.commons.http.Request) IdentifyRequest(com.okta.idx.sdk.api.request.IdentifyRequest) EnrollUserProfileUpdateRequest(com.okta.idx.sdk.api.request.EnrollUserProfileUpdateRequest) DefaultRequest(com.okta.commons.http.DefaultRequest) EnrollRequest(com.okta.idx.sdk.api.request.EnrollRequest) ChallengeRequest(com.okta.idx.sdk.api.request.ChallengeRequest) CancelRequest(com.okta.idx.sdk.api.request.CancelRequest) RecoverRequest(com.okta.idx.sdk.api.request.RecoverRequest) IntrospectRequest(com.okta.idx.sdk.api.request.IntrospectRequest) AnswerChallengeRequest(com.okta.idx.sdk.api.request.AnswerChallengeRequest) PollRequest(com.okta.idx.sdk.api.request.PollRequest) JsonNode(com.fasterxml.jackson.databind.JsonNode) HttpException(com.okta.commons.http.HttpException) IntrospectRequest(com.okta.idx.sdk.api.request.IntrospectRequest) IOException(java.io.IOException) IDXResponse(com.okta.idx.sdk.api.response.IDXResponse) ProcessingException(com.okta.idx.sdk.api.exception.ProcessingException)

Example 4 with IDXResponse

use of com.okta.idx.sdk.api.response.IDXResponse in project okta-idx-java by okta.

the class BaseIDXClient method poll.

@Override
public IDXResponse poll(PollRequest pollRequest, String href) throws ProcessingException {
    IDXResponse idxResponse;
    try {
        Request request = new DefaultRequest(HttpMethod.POST, Strings.hasText(href) ? href : clientConfiguration.getBaseUrl() + "/idp/idx/challenge/poll", null, getHttpHeaders(false), new ByteArrayInputStream(objectMapper.writeValueAsBytes(pollRequest)), -1L);
        Response response = requestExecutor.executeRequest(request);
        if (response.getHttpStatus() != 200) {
            handleErrorResponse(request, response);
        }
        JsonNode responseJsonNode = objectMapper.readTree(response.getBody());
        idxResponse = objectMapper.convertValue(responseJsonNode, IDXResponse.class);
    } catch (IOException | HttpException e) {
        throw new ProcessingException(e);
    }
    return idxResponse;
}
Also used : ErrorResponse(com.okta.idx.sdk.api.response.ErrorResponse) IDXResponse(com.okta.idx.sdk.api.response.IDXResponse) InteractResponse(com.okta.idx.sdk.api.response.InteractResponse) Response(com.okta.commons.http.Response) TokenResponse(com.okta.idx.sdk.api.response.TokenResponse) DefaultRequest(com.okta.commons.http.DefaultRequest) ByteArrayInputStream(java.io.ByteArrayInputStream) SkipAuthenticatorEnrollmentRequest(com.okta.idx.sdk.api.request.SkipAuthenticatorEnrollmentRequest) Request(com.okta.commons.http.Request) IdentifyRequest(com.okta.idx.sdk.api.request.IdentifyRequest) EnrollUserProfileUpdateRequest(com.okta.idx.sdk.api.request.EnrollUserProfileUpdateRequest) DefaultRequest(com.okta.commons.http.DefaultRequest) EnrollRequest(com.okta.idx.sdk.api.request.EnrollRequest) ChallengeRequest(com.okta.idx.sdk.api.request.ChallengeRequest) CancelRequest(com.okta.idx.sdk.api.request.CancelRequest) RecoverRequest(com.okta.idx.sdk.api.request.RecoverRequest) IntrospectRequest(com.okta.idx.sdk.api.request.IntrospectRequest) AnswerChallengeRequest(com.okta.idx.sdk.api.request.AnswerChallengeRequest) PollRequest(com.okta.idx.sdk.api.request.PollRequest) JsonNode(com.fasterxml.jackson.databind.JsonNode) HttpException(com.okta.commons.http.HttpException) IOException(java.io.IOException) IDXResponse(com.okta.idx.sdk.api.response.IDXResponse) ProcessingException(com.okta.idx.sdk.api.exception.ProcessingException)

Example 5 with IDXResponse

use of com.okta.idx.sdk.api.response.IDXResponse in project okta-idx-java by okta.

the class AuthenticationTransaction method create.

static AuthenticationTransaction create(IDXClient client, String token, EmailTokenType tokenType) throws ProcessingException {
    IDXClientContext idxClientContext;
    if (token == null) {
        idxClientContext = client.interact();
    } else {
        Assert.notNull(tokenType, "token type may not be null");
        idxClientContext = client.interact(token, tokenType);
    }
    Assert.notNull(idxClientContext, "IDX client context may not be null");
    IDXResponse introspectResponse = client.introspect(idxClientContext);
    String stateHandle = introspectResponse.getStateHandle();
    Assert.hasText(stateHandle, "State handle may not be null");
    WrapperUtil.printRemediationOptions(introspectResponse);
    return new AuthenticationTransaction(client, idxClientContext, introspectResponse);
}
Also used : IDXClientContext(com.okta.idx.sdk.api.model.IDXClientContext) IDXResponse(com.okta.idx.sdk.api.response.IDXResponse)

Aggregations

IDXResponse (com.okta.idx.sdk.api.response.IDXResponse)16 ProcessingException (com.okta.idx.sdk.api.exception.ProcessingException)12 Response (com.okta.commons.http.Response)11 IdentifyRequest (com.okta.idx.sdk.api.request.IdentifyRequest)11 RecoverRequest (com.okta.idx.sdk.api.request.RecoverRequest)11 TokenResponse (com.okta.idx.sdk.api.response.TokenResponse)11 JsonNode (com.fasterxml.jackson.databind.JsonNode)10 DefaultRequest (com.okta.commons.http.DefaultRequest)10 HttpException (com.okta.commons.http.HttpException)10 Request (com.okta.commons.http.Request)10 AnswerChallengeRequest (com.okta.idx.sdk.api.request.AnswerChallengeRequest)10 CancelRequest (com.okta.idx.sdk.api.request.CancelRequest)10 ChallengeRequest (com.okta.idx.sdk.api.request.ChallengeRequest)10 EnrollRequest (com.okta.idx.sdk.api.request.EnrollRequest)10 EnrollUserProfileUpdateRequest (com.okta.idx.sdk.api.request.EnrollUserProfileUpdateRequest)10 IntrospectRequest (com.okta.idx.sdk.api.request.IntrospectRequest)10 PollRequest (com.okta.idx.sdk.api.request.PollRequest)10 SkipAuthenticatorEnrollmentRequest (com.okta.idx.sdk.api.request.SkipAuthenticatorEnrollmentRequest)10 ErrorResponse (com.okta.idx.sdk.api.response.ErrorResponse)10 InteractResponse (com.okta.idx.sdk.api.response.InteractResponse)10