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