use of com.okta.commons.http.DefaultRequest in project okta-sdk-java by okta.
the class DefaultDataStore method doDelete.
private void doDelete(String resourceHref, Class resourceClass, QueryString qs, HttpHeaders httpHeaders) {
Assert.hasText(resourceHref, "This resource does not have an href value, therefore it cannot be deleted.");
// if this URL is a partial, then we MUST add the baseUrl
final CanonicalUri uri = canonicalize(resourceHref, qs);
FilterChain chain = new DefaultFilterChain(this.filters, request -> {
Request deleteRequest = new DefaultRequest(HttpMethod.DELETE, uri.getAbsolutePath(), uri.getQuery(), httpHeaders);
execute(deleteRequest);
// delete requests have HTTP 204 (no content), so just create an empty setBody for the result:
return new DefaultResourceDataResult(request.getAction(), request.getUri(), request.getResourceClass(), new HashMap<>());
});
final CanonicalUri resourceUri = canonicalize(resourceHref, null);
ResourceDataRequest request = new DefaultResourceDataRequest(ResourceAction.DELETE, resourceUri, resourceClass, new HashMap<>());
chain.filter(request);
}
use of com.okta.commons.http.DefaultRequest in project okta-idx-java by okta.
the class BaseIDXClient method enrollUpdateUserProfile.
@Override
public IDXResponse enrollUpdateUserProfile(EnrollUserProfileUpdateRequest enrollUserProfileUpdateRequest, String href) throws ProcessingException {
IDXResponse idxResponse;
try {
Request request = new DefaultRequest(HttpMethod.POST, href, null, getHttpHeaders(false), new ByteArrayInputStream(objectMapper.writeValueAsBytes(enrollUserProfileUpdateRequest)), -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.commons.http.DefaultRequest in project okta-idx-java by okta.
the class BaseIDXClient method skip.
@Override
public IDXResponse skip(SkipAuthenticatorEnrollmentRequest skipAuthenticatorEnrollmentRequest, String href) throws ProcessingException {
IDXResponse idxResponse;
try {
Request request = new DefaultRequest(HttpMethod.POST, href, null, getHttpHeaders(false), new ByteArrayInputStream(objectMapper.writeValueAsBytes(skipAuthenticatorEnrollmentRequest)), -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.commons.http.DefaultRequest in project okta-idx-java by okta.
the class BaseIDXClient method verifyEmailToken.
@Override
public Response verifyEmailToken(String token) throws ProcessingException {
StringBuilder urlParameter = new StringBuilder();
urlParameter.append("token=").append(token);
try {
Request request = new DefaultRequest(HttpMethod.GET, clientConfiguration.getBaseUrl() + "/email/verify", null, getHttpHeaders(false), new ByteArrayInputStream(urlParameter.toString().getBytes(StandardCharsets.UTF_8)), -1L);
return requestExecutor.executeRequest(request);
} catch (HttpException e) {
throw new ProcessingException(e);
}
}
use of com.okta.commons.http.DefaultRequest in project okta-idx-java by okta.
the class BaseIDXClient method recover.
@Override
public IDXResponse recover(RecoverRequest recoverRequest, String href) throws ProcessingException {
IDXResponse idxResponse;
try {
Request request = new DefaultRequest(HttpMethod.POST, Strings.hasText(href) ? href : clientConfiguration.getBaseUrl() + "/idp/idx/recover", null, getHttpHeaders(false), new ByteArrayInputStream(objectMapper.writeValueAsBytes(recoverRequest)), -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;
}
Aggregations