Search in sources :

Example 1 with ApacheHttpClient

use of com.opentext.ia.sdk.support.http.apache.ApacheHttpClient 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();
    }
}
Also used : GatewayInfo(com.opentext.ia.sdk.support.http.rest.GatewayInfo) Header(com.opentext.ia.sdk.support.http.Header) HttpClient(com.opentext.ia.sdk.support.http.HttpClient) ApacheHttpClient(com.opentext.ia.sdk.support.http.apache.ApacheHttpClient) ApacheHttpClient(com.opentext.ia.sdk.support.http.apache.ApacheHttpClient) AuthenticationStrategy(com.opentext.ia.sdk.support.http.rest.AuthenticationStrategy) JwtAuthentication(com.opentext.ia.sdk.support.http.rest.JwtAuthentication)

Aggregations

Header (com.opentext.ia.sdk.support.http.Header)1 HttpClient (com.opentext.ia.sdk.support.http.HttpClient)1 ApacheHttpClient (com.opentext.ia.sdk.support.http.apache.ApacheHttpClient)1 AuthenticationStrategy (com.opentext.ia.sdk.support.http.rest.AuthenticationStrategy)1 GatewayInfo (com.opentext.ia.sdk.support.http.rest.GatewayInfo)1 JwtAuthentication (com.opentext.ia.sdk.support.http.rest.JwtAuthentication)1