use of com.opentext.ia.sdk.support.http.Header in project infoarchive-sip-sdk by Enterprise-Content-Management.
the class WhenMakingRestCalls method shouldForwardToHttpClient.
@Test
public void shouldForwardToHttpClient() throws IOException {
String uri = randomString();
Class<?> type = String.class;
Collection<Header> authorizationHeader = new ArrayList<>();
authorizationHeader.add(new Header("Authorization", "Bearer " + token));
Collection<Header> contentAndAuthorizationHeaders = new ArrayList<>();
contentAndAuthorizationHeaders.add(new Header("Accept", MediaTypes.HAL));
contentAndAuthorizationHeaders.addAll(authorizationHeader);
restClient.get(uri, type);
verify(httpClient).get(eq(uri), eq(contentAndAuthorizationHeaders), eq(type));
restClient.put(uri, type);
verify(httpClient).put(eq(uri), eq(contentAndAuthorizationHeaders), eq(type));
restClient.post(uri, type);
verify(httpClient).post(eq(uri), eq(contentAndAuthorizationHeaders), eq(type));
restClient.delete(uri);
verify(httpClient).delete(eq(uri), eq(authorizationHeader));
}
use of com.opentext.ia.sdk.support.http.Header in project infoarchive-sip-sdk by Enterprise-Content-Management.
the class JwtAuthentication method postToGateway.
private AuthenticationSuccess postToGateway(String payload) {
AuthenticationSuccess result;
String gatewayUrl = gatewayInfo.getGatewayUrl();
Collection<Header> headers = new ArrayList<>(Arrays.asList(gatewayInfo.getAuthorizationHeader(), gatewayInfo.getContentTypeHeader()));
try {
result = httpClient.post(gatewayUrl, headers, AuthenticationSuccess.class, payload);
} catch (IOException ex) {
if (timer != null) {
timer.stop();
}
throw new RuntimeIoException(ex);
}
return result;
}
Aggregations