use of com.okta.authn.sdk.http.QueryParameter in project okta-auth-java by okta.
the class ReadmeSnippets method headersAndQuery.
private void headersAndQuery() {
List<Header> headers = new ArrayList<>();
// set any header
headers.add(new Header("aHeaderName", "aValue"));
// X-Forwarded-For
headers.add(Header.xForwardedFor("10.10.0.1"));
// X-Device-Fingerprint
headers.add(Header.xDeviceFingerprint("your-finger-print"));
List<QueryParameter> queryParameters = new ArrayList<>();
// set query param
queryParameters.add(new QueryParameter("aQueryParam", "aValue"));
RequestContext requestContext = new RequestContext(headers, queryParameters);
}
use of com.okta.authn.sdk.http.QueryParameter in project okta-auth-java by okta.
the class DefaultAuthenticationClient method doPost.
private AuthenticationResponse doPost(String href, Resource request, AuthenticationStateHandler authenticationStateHandler, RequestContext requestContext) throws AuthenticationException {
try {
Map<String, Object> query = null;
Map<String, List<String>> headers = null;
if (requestContext != null) {
query = requestContext.getQueryParams().stream().collect(Collectors.toMap(QueryParameter::getKey, QueryParameter::getValue));
headers = requestContext.getHeaders().stream().collect(Collectors.toMap(Header::getKey, Header::getValue, (a, b) -> Stream.concat(a.stream(), b.stream()).collect(Collectors.toList())));
}
AuthenticationResponse authenticationResponse = getDataStore().create(href, request, null, AuthenticationResponse.class, query, headers);
if (authenticationStateHandler != null) {
handleResult(authenticationResponse, authenticationStateHandler);
}
return authenticationResponse;
} catch (ResourceException e) {
translateException(e);
// above method should always throw
throw e;
}
}
Aggregations