Search in sources :

Example 1 with JacksonJsonProvider

use of org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJsonProvider in project athenz by yahoo.

the class ZTSClient method initClient.

private void initClient(final String serverUrl, Principal identity, final String domainName, final String serviceName, final ServiceIdentityProvider siaProvider) {
    ztsUrl = (serverUrl == null) ? confZtsUrl : serverUrl;
    if (!isEmpty(ztsUrl)) {
        if (!ztsUrl.endsWith("/zts/v1")) {
            if (ztsUrl.charAt(ztsUrl.length() - 1) != '/') {
                ztsUrl += '/';
            }
            ztsUrl += "zts/v1";
        }
    }
    // determine to see if we need a host verifier for our ssl connections
    HostnameVerifier hostnameVerifier = null;
    if (!isEmpty(x509CertDNSName)) {
        hostnameVerifier = new AWSHostNameVerifier(x509CertDNSName);
    }
    if (sslContext == null) {
        sslContext = createSSLContext();
    }
    // setup our client config object with timeouts
    final JacksonJsonProvider jacksonJsonProvider = new JacksonJaxbJsonProvider().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    final ClientConfig config = new ClientConfig(jacksonJsonProvider);
    PoolingHttpClientConnectionManager connManager = createConnectionManager(sslContext, hostnameVerifier);
    if (connManager != null) {
        config.property(ApacheClientProperties.CONNECTION_MANAGER, connManager);
    }
    config.connectorProvider(new ApacheConnectorProvider());
    if (proxyUrl != null) {
        config.property(ClientProperties.PROXY_URI, proxyUrl);
    }
    ClientBuilder builder = getClientBuilder();
    if (sslContext != null) {
        builder = builder.sslContext(sslContext);
        enablePrefetch = true;
    }
    // JerseyClientBuilder::withConfig() replaces the existing config with the new client
    // config. Hence the client config should be added to the builder before the timeouts.
    // Otherwise the timeout settings would be overridden.
    Client rsClient = builder.withConfig(config).hostnameVerifier(hostnameVerifier).readTimeout(reqReadTimeout, TimeUnit.MILLISECONDS).connectTimeout(reqConnectTimeout, TimeUnit.MILLISECONDS).build();
    ztsClient = new ZTSRDLGeneratedClient(ztsUrl, rsClient);
    principal = identity;
    domain = domainName;
    service = serviceName;
    this.siaProvider = siaProvider;
    if (principal != null) {
        domain = principal.getDomain();
        service = principal.getName();
        ztsClient.addCredentials(identity.getAuthority().getHeader(), identity.getCredentials());
    }
}
Also used : JacksonJsonProvider(org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJsonProvider) ApacheConnectorProvider(org.glassfish.jersey.apache.connector.ApacheConnectorProvider) JacksonJaxbJsonProvider(org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJaxbJsonProvider) ClientConfig(org.glassfish.jersey.client.ClientConfig) Client(javax.ws.rs.client.Client) HostnameVerifier(javax.net.ssl.HostnameVerifier) PoolingHttpClientConnectionManager(org.apache.http.impl.conn.PoolingHttpClientConnectionManager) AWSSecurityTokenServiceClientBuilder(com.amazonaws.services.securitytoken.AWSSecurityTokenServiceClientBuilder) ClientBuilder(javax.ws.rs.client.ClientBuilder)

Aggregations

AWSSecurityTokenServiceClientBuilder (com.amazonaws.services.securitytoken.AWSSecurityTokenServiceClientBuilder)1 HostnameVerifier (javax.net.ssl.HostnameVerifier)1 Client (javax.ws.rs.client.Client)1 ClientBuilder (javax.ws.rs.client.ClientBuilder)1 PoolingHttpClientConnectionManager (org.apache.http.impl.conn.PoolingHttpClientConnectionManager)1 ApacheConnectorProvider (org.glassfish.jersey.apache.connector.ApacheConnectorProvider)1 ClientConfig (org.glassfish.jersey.client.ClientConfig)1 JacksonJaxbJsonProvider (org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJaxbJsonProvider)1 JacksonJsonProvider (org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJsonProvider)1