use of com.opentext.ia.sdk.support.http.HttpClient in project infoarchive-sip-sdk by Enterprise-Content-Management.
the class WhenConfiguringAuthenticationStrategy method shouldGetJwtAuthentication.
@Test
public void shouldGetJwtAuthentication() {
configuration.setClientId(randomString());
configuration.setClientSecret(randomString());
configuration.setAuthenticationGateway(randomString());
configuration.setAuthenticationUser(randomString());
configuration.setAuthenticationPassword(randomString());
HttpClient httpClient = mock(HttpClient.class);
Clock clock = mock(Clock.class);
AuthenticationStrategy authentication = authFactory.getAuthenticationStrategy(() -> httpClient, () -> clock);
assertTrue(authentication instanceof JwtAuthentication);
}
use of com.opentext.ia.sdk.support.http.HttpClient in project infoarchive-sip-sdk by Enterprise-Content-Management.
the class WhenConfiguringAuthenticationStrategy method shouldThrowException.
@Test(expected = IllegalArgumentException.class)
public void shouldThrowException() {
configuration.setClientId(randomString());
configuration.setClientSecret(randomString());
configuration.setAuthenticationGateway(randomString());
configuration.setAuthenticationUser(randomString());
HttpClient httpClient = mock(HttpClient.class);
Clock clock = mock(Clock.class);
authFactory.getAuthenticationStrategy(() -> httpClient, () -> clock);
}
use of com.opentext.ia.sdk.support.http.HttpClient 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.HttpClient in project infoarchive-sip-sdk by Enterprise-Content-Management.
the class WhenCreatingAuthenticationStrategy method shouldNotConfigureJwtAuthentication.
@Test
public void shouldNotConfigureJwtAuthentication() {
String username = randomString();
String password = randomString();
HttpClient httpClient = mock(HttpClient.class);
Clock clock = mock(Clock.class);
assertFalse("Should not configure JwtAuthentication because of abscence of gatewayInfo", JwtAuthentication.optional(username, password, null, httpClient, clock).isPresent());
}
use of com.opentext.ia.sdk.support.http.HttpClient in project infoarchive-sip-sdk by Enterprise-Content-Management.
the class WhenCreatingAuthenticationStrategy method shouldConfigureJwtAuthentication.
@Test
public void shouldConfigureJwtAuthentication() {
String username = randomString();
String password = randomString();
Optional<GatewayInfo> gatewayInfo = GatewayInfo.optional(randomString(), randomString(), randomString());
HttpClient httpClient = mock(HttpClient.class);
Clock clock = mock(Clock.class);
assertTrue("Should configure JwtAuthentication", JwtAuthentication.optional(username, password, gatewayInfo.orElse(null), httpClient, clock).isPresent());
}
Aggregations