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());
}
}
Aggregations