use of com.opentext.ia.sdk.support.http.Header in project infoarchive-sip-sdk by Enterprise-Content-Management.
the class WhenMakingClientSideAuthentication method shouldIssueBasicHeader.
@Test
public void shouldIssueBasicHeader() {
String finalToken = "Basic " + Base64.getEncoder().encodeToString((username + ":" + password).getBytes(StandardCharsets.UTF_8));
Header authHeader = new Header("Authorization", finalToken);
assertEquals("Tokens should be the same", authHeader, basicAuth.issueAuthHeader());
}
use of com.opentext.ia.sdk.support.http.Header in project infoarchive-sip-sdk by Enterprise-Content-Management.
the class WhenMakingClientSideAuthentication method shouldIssueGivenHeader.
@Test
public void shouldIssueGivenHeader() {
String finalToken = "Bearer " + token;
Header authHeader = new Header("Authorization", finalToken);
assertEquals("Tokens should be the same", authHeader, tokenAuth.issueAuthHeader());
}
use of com.opentext.ia.sdk.support.http.Header in project infoarchive-sip-sdk by Enterprise-Content-Management.
the class WhenUsingGatewayInfo method shouldCorrecltyFormAuthorizationHeader.
@Test
public void shouldCorrecltyFormAuthorizationHeader() {
String correctToken = "Basic " + Base64.getEncoder().encodeToString((clientId + ":" + clientSecret).getBytes(StandardCharsets.UTF_8));
Header correctHeader = new Header("Authorization", correctToken);
assertEquals("Header should be formed correctly", correctHeader, gatewayInfo.getAuthorizationHeader());
}
use of com.opentext.ia.sdk.support.http.Header in project infoarchive-sip-sdk by Enterprise-Content-Management.
the class Authenticate method main.
@SuppressWarnings("PMD.SystemPrintln")
public static void main(String[] args) {
HttpClient httpClient = new ApacheHttpClient();
try {
// Log in to the gateway with user name & password
AuthenticationStrategy authentication = new JwtAuthentication(USER_NAME, PASSWORD, new GatewayInfo(GATEWAY_URL, CLIENT_ID, CLIENT_SECRET), httpClient);
// Get an authentication header using a token provided by the gateway
Header header = authentication.issueAuthHeader();
// Use this header in calls using the HTTP client
System.out.println(header);
} finally {
httpClient.close();
}
}
use of com.opentext.ia.sdk.support.http.Header in project infoarchive-sip-sdk by Enterprise-Content-Management.
the class WhenMakingJwtAuthentication method shouldCorrectlyFormAuthorizationHeader.
@Test
public void shouldCorrectlyFormAuthorizationHeader() throws IOException {
String authToken = Base64.getEncoder().encodeToString((clientId + ":" + clientSecret).getBytes(StandardCharsets.UTF_8));
Header authHeader = new Header("Authorization", "Basic " + authToken);
Header contentTypeHeader = new Header("Content-Type", ContentType.APPLICATION_FORM_URLENCODED.toString());
Collection<Header> headers = new ArrayList<>(Arrays.asList(authHeader, contentTypeHeader));
authentication.issueAuthHeader();
verify(httpClient).post(any(), eq(headers), eq(AuthenticationSuccess.class), anyString());
}
Aggregations