Search in sources :

Example 41 with DefaultClientConfig

use of com.sun.jersey.api.client.config.DefaultClientConfig in project ff4j by ff4j.

the class ClientHttpJersey1Utils method buildJersey1Client.

/**
 * Initializing jerseyClient.
 */
public static Client buildJersey1Client() {
    ClientConfig config = new DefaultClientConfig();
    config.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
    config.getSingletons().add(new JacksonJsonProvider());
    config.getSingletons().add(new FF4jJacksonMapper());
    return Client.create(config);
}
Also used : DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) FF4jJacksonMapper(org.ff4j.web.api.FF4jJacksonMapper) JacksonJsonProvider(io.swagger.jaxrs.json.JacksonJsonProvider) DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) ClientConfig(com.sun.jersey.api.client.config.ClientConfig)

Example 42 with DefaultClientConfig

use of com.sun.jersey.api.client.config.DefaultClientConfig in project ff4j by ff4j.

the class SecuredFF4JResourceTestIT method configure.

/**
 * {@inheritDoc}
 */
@Override
public WebAppDescriptor configure() {
    ClientConfig cc = new DefaultClientConfig();
    cc.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
    return new WebAppDescriptor.Builder().initParam(WebComponent.APPLICATION_CONFIG_CLASS, // 
    SecuredFF4jProvider.class.getName()).clientConfig(cc).build();
}
Also used : WebAppDescriptor(com.sun.jersey.test.framework.WebAppDescriptor) DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) ClientConfig(com.sun.jersey.api.client.config.ClientConfig) DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig)

Example 43 with DefaultClientConfig

use of com.sun.jersey.api.client.config.DefaultClientConfig in project coprhd-controller by CoprHD.

the class CinderApiFactory method getApi.

/**
 * Return Cinder API client, create if not present
 *
 * @param provider Storage Provider URI
 * @return
 */
public CinderApi getApi(URI provider, CinderEndPointInfo endPoint) {
    boolean isNew = false;
    CinderApi cinderApi = _clientMap.get(provider.toString());
    if (cinderApi == null) {
        isNew = true;
        ClientConfig config = new DefaultClientConfig();
        Client jerseyClient = Client.create(config);
        cinderApi = new CinderApi(endPoint, jerseyClient);
        _clientMap.putIfAbsent(provider.toString(), cinderApi);
    }
    if (!isNew) {
        // Token gets expired, if the instance is not new refresh it.
        cinderApi.getClient().setAuthTokenHeader(endPoint.getCinderToken());
    }
    return cinderApi;
}
Also used : DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) ClientConfig(com.sun.jersey.api.client.config.ClientConfig) Client(com.sun.jersey.api.client.Client)

Example 44 with DefaultClientConfig

use of com.sun.jersey.api.client.config.DefaultClientConfig in project coprhd-controller by CoprHD.

the class ClientRequestHelper method createClient.

/**
 * Create an SSL-trusting Client using the specified configurations
 *
 * This method adds permissive HTTPSProperties settings to the
 * configuration of the client.
 *
 * Note: Client objects are expensive to create and largely
 * thread-safe so they should be re-used across requests
 *
 * @param readTimeout the read timeout
 * @param connectTimeout the connect timeout
 * @return the client
 */
public Client createClient(int readTimeout, int connectTimeout) {
    ClientConfig config = new DefaultClientConfig();
    config.getClasses().add(JacksonJaxbJsonProvider.class);
    config.getProperties().put(ClientConfig.PROPERTY_READ_TIMEOUT, readTimeout);
    config.getProperties().put(ClientConfig.PROPERTY_CONNECT_TIMEOUT, connectTimeout);
    return createClient(config);
}
Also used : DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) ClientConfig(com.sun.jersey.api.client.config.ClientConfig) DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig)

Example 45 with DefaultClientConfig

use of com.sun.jersey.api.client.config.DefaultClientConfig in project data-access by pentaho.

the class TestDataSourceResource method init.

private static void init() {
    ClientConfig clientConfig = new DefaultClientConfig();
    client = Client.create(clientConfig);
    client.addFilter(new HTTPBasicAuthFilter("joe", "password"));
}
Also used : DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) DefaultClientConfig(com.sun.jersey.api.client.config.DefaultClientConfig) ClientConfig(com.sun.jersey.api.client.config.ClientConfig) HTTPBasicAuthFilter(com.sun.jersey.api.client.filter.HTTPBasicAuthFilter)

Aggregations

DefaultClientConfig (com.sun.jersey.api.client.config.DefaultClientConfig)65 ClientConfig (com.sun.jersey.api.client.config.ClientConfig)55 Client (com.sun.jersey.api.client.Client)42 WebResource (com.sun.jersey.api.client.WebResource)21 HTTPBasicAuthFilter (com.sun.jersey.api.client.filter.HTTPBasicAuthFilter)15 ClientResponse (com.sun.jersey.api.client.ClientResponse)14 HTTPSProperties (com.sun.jersey.client.urlconnection.HTTPSProperties)9 HostnameVerifier (javax.net.ssl.HostnameVerifier)7 SSLSession (javax.net.ssl.SSLSession)7 TrustManager (javax.net.ssl.TrustManager)7 ClientHandlerException (com.sun.jersey.api.client.ClientHandlerException)6 URLConnectionClientHandler (com.sun.jersey.client.urlconnection.URLConnectionClientHandler)6 IOException (java.io.IOException)6 VisibleForTesting (com.google.common.annotations.VisibleForTesting)5 ClientFilter (com.sun.jersey.api.client.filter.ClientFilter)5 LoggingFilter (com.sun.jersey.api.client.filter.LoggingFilter)5 SecureRandom (java.security.SecureRandom)5 SSLContext (javax.net.ssl.SSLContext)5 URISyntaxException (java.net.URISyntaxException)4 ArrayList (java.util.ArrayList)4