Search in sources :

Example 6 with ApacheHttpClient

use of com.sun.jersey.client.apache.ApacheHttpClient in project coprhd-controller by CoprHD.

the class ECSApiFactory method getRESTClient.

/**
 * Create ECS API client
 *
 * @param endpoint ECS endpoint
 * @return
 */
public ECSApi getRESTClient(URI endpoint, String username, String password) {
    ECSApi ecsApi = _clientMap.get(endpoint.toString() + ":" + username + ":" + password);
    if (ecsApi == null) {
        Client jerseyClient = new ApacheHttpClient(_clientHandler);
        jerseyClient.addFilter(new HTTPBasicAuthFilter(username, password));
        RESTClient restClient = new RESTClient(jerseyClient);
        ecsApi = new ECSApi(endpoint, restClient);
        _clientMap.putIfAbsent(endpoint.toString() + ":" + username + ":" + password, ecsApi);
    }
    return ecsApi;
}
Also used : ApacheHttpClient(com.sun.jersey.client.apache.ApacheHttpClient) ApacheHttpClient(com.sun.jersey.client.apache.ApacheHttpClient) HttpClient(org.apache.commons.httpclient.HttpClient) Client(com.sun.jersey.api.client.Client) HTTPBasicAuthFilter(com.sun.jersey.api.client.filter.HTTPBasicAuthFilter)

Example 7 with ApacheHttpClient

use of com.sun.jersey.client.apache.ApacheHttpClient in project coprhd-controller by CoprHD.

the class RestClientFactory method getRESTClient.

public RestClientItf getRESTClient(URI endpoint, String username, String password) {
    RestClientItf clientApi = _clientMap.get(endpoint.toString() + ":" + username + ":" + password);
    if (clientApi == null) {
        Client jerseyClient = new ApacheHttpClient(_clientHandler);
        clientApi = createNewRestClient(endpoint, username, password, jerseyClient);
        _clientMap.putIfAbsent(endpoint.toString() + ":" + username + ":" + password, clientApi);
    }
    return clientApi;
}
Also used : ApacheHttpClient(com.sun.jersey.client.apache.ApacheHttpClient) ApacheHttpClient(com.sun.jersey.client.apache.ApacheHttpClient) HttpClient(org.apache.commons.httpclient.HttpClient) Client(com.sun.jersey.api.client.Client)

Example 8 with ApacheHttpClient

use of com.sun.jersey.client.apache.ApacheHttpClient in project coprhd-controller by CoprHD.

the class RestClientFactory method getRESTClient.

public RestClientItf getRESTClient(URI endpoint, String username, String password, boolean authFilter) {
    RestClientItf clientApi = _clientMap.get(endpoint.toString() + ":" + username + ":" + password);
    if (clientApi == null) {
        Client jerseyClient = new ApacheHttpClient(_clientHandler);
        if (authFilter) {
            jerseyClient.addFilter(new HTTPBasicAuthFilter(username, password));
        }
        clientApi = createNewRestClient(endpoint, username, password, jerseyClient);
        _clientMap.putIfAbsent(endpoint.toString() + ":" + username + ":" + password, clientApi);
    }
    return clientApi;
}
Also used : ApacheHttpClient(com.sun.jersey.client.apache.ApacheHttpClient) ApacheHttpClient(com.sun.jersey.client.apache.ApacheHttpClient) HttpClient(org.apache.commons.httpclient.HttpClient) Client(com.sun.jersey.api.client.Client) HTTPBasicAuthFilter(com.sun.jersey.api.client.filter.HTTPBasicAuthFilter)

Example 9 with ApacheHttpClient

use of com.sun.jersey.client.apache.ApacheHttpClient in project coprhd-controller by CoprHD.

the class XtremIOClientFactory method getRESTClient.

public RestClientItf getRESTClient(URI endpoint, String username, String password, String version, boolean authFilter) {
    // removed caching RestClient session as it is not actually a session, just a java RestClient object
    // RestClientItf clientApi = _clientMap.get(endpoint.toString() + ":" + username + ":" + password + ":" + model);
    Client jerseyClient = new ApacheHttpClient(_clientHandler);
    if (authFilter) {
        jerseyClient.addFilter(new HTTPBasicAuthFilter(username, password));
    }
    RestClientItf clientApi = createNewRestClient(endpoint, username, password, version, jerseyClient);
    return clientApi;
}
Also used : ApacheHttpClient(com.sun.jersey.client.apache.ApacheHttpClient) RestClientItf(com.emc.storageos.services.restutil.RestClientItf) ApacheHttpClient(com.sun.jersey.client.apache.ApacheHttpClient) Client(com.sun.jersey.api.client.Client) HTTPBasicAuthFilter(com.sun.jersey.api.client.filter.HTTPBasicAuthFilter)

Example 10 with ApacheHttpClient

use of com.sun.jersey.client.apache.ApacheHttpClient in project coprhd-controller by CoprHD.

the class VPlexApiFactory method getClient.

/**
 * Get the VPlex API client for the VPlex Management Station identified
 * by the passed endpoint suing the passed username and password.
 *
 * @param endpoint VPlex Management Station endpoint URI.
 * @param username The user name to authenticate.
 * @param password The password to authenticate.
 *
 * @return Reference to a VPlexApiClient.
 */
public synchronized VPlexApiClient getClient(URI endpoint, String username, String password) {
    // Make the key dependent on user and password in case they
    // change for a client endpoint.
    StringBuilder clientKeyBuilder = new StringBuilder();
    clientKeyBuilder.append(endpoint.toString());
    clientKeyBuilder.append("_");
    clientKeyBuilder.append(username);
    clientKeyBuilder.append("_");
    clientKeyBuilder.append(password);
    String clientKey = clientKeyBuilder.toString();
    VPlexApiClient vplexApiClient = _clientMap.get(clientKey);
    if (vplexApiClient == null) {
        s_logger.info("Creating new VPLEX client for the management server {}", endpoint);
        Client jerseyClient = new ApacheHttpClient(_clientHandler);
        RESTClient restClient = new RESTClient(jerseyClient, username, password);
        vplexApiClient = new VPlexApiClient(endpoint, restClient);
        _clientMap.putIfAbsent(clientKey, vplexApiClient);
    }
    return vplexApiClient;
}
Also used : ApacheHttpClient(com.sun.jersey.client.apache.ApacheHttpClient) ApacheHttpClient(com.sun.jersey.client.apache.ApacheHttpClient) HttpClient(org.apache.commons.httpclient.HttpClient) Client(com.sun.jersey.api.client.Client)

Aggregations

ApacheHttpClient (com.sun.jersey.client.apache.ApacheHttpClient)10 Client (com.sun.jersey.api.client.Client)9 HttpClient (org.apache.commons.httpclient.HttpClient)9 HTTPBasicAuthFilter (com.sun.jersey.api.client.filter.HTTPBasicAuthFilter)4 RestClientItf (com.emc.storageos.services.restutil.RestClientItf)1 ClientConfig (com.sun.jersey.api.client.config.ClientConfig)1 ApacheHttpClientHandler (com.sun.jersey.client.apache.ApacheHttpClientHandler)1 HTTPSProperties (com.sun.jersey.client.urlconnection.HTTPSProperties)1 IOException (java.io.IOException)1 GeneralSecurityException (java.security.GeneralSecurityException)1 X509Certificate (java.security.cert.X509Certificate)1 SSLContext (javax.net.ssl.SSLContext)1 TrustManager (javax.net.ssl.TrustManager)1 X509TrustManager (javax.net.ssl.X509TrustManager)1 HttpMethod (org.apache.commons.httpclient.HttpMethod)1 HttpMethodRetryHandler (org.apache.commons.httpclient.HttpMethodRetryHandler)1 MultiThreadedHttpConnectionManager (org.apache.commons.httpclient.MultiThreadedHttpConnectionManager)1 HttpConnectionManagerParams (org.apache.commons.httpclient.params.HttpConnectionManagerParams)1 Protocol (org.apache.commons.httpclient.protocol.Protocol)1