use of org.apache.cxf.transport.http.HTTPConduit in project components by Talend.
the class NetSuiteClientService method setHttpClientPolicy.
protected void setHttpClientPolicy(PortT port, HTTPClientPolicy httpClientPolicy) {
Client proxy = ClientProxy.getClient(port);
HTTPConduit conduit = (HTTPConduit) proxy.getConduit();
conduit.setClient(httpClientPolicy);
}
use of org.apache.cxf.transport.http.HTTPConduit in project components by Talend.
the class AmbariClientBuilder method build.
/**
* Build a client proxy, for a specific proxy type.
*
* @param proxyType proxy type class
* @return client proxy stub
*/
protected <T> T build(Class<T> proxyType) {
String address = generateAddress();
T rootResource;
// We want to ensure that the shared bean isn't set concurrently in multiple callers
synchronized (AmbariClientBuilder.class) {
JAXRSClientFactoryBean bean = cleanFactory(clientStaticResources.getUnchecked(proxyType));
bean.setAddress(address);
if (username != null) {
bean.setUsername(username);
bean.setPassword(password);
}
if (enableLogging) {
bean.setFeatures(Arrays.<AbstractFeature>asList(new LoggingFeature()));
}
rootResource = bean.create(proxyType);
}
boolean isTlsEnabled = address.startsWith("https://");
ClientConfiguration config = WebClient.getConfig(rootResource);
HTTPConduit conduit = (HTTPConduit) config.getConduit();
if (isTlsEnabled) {
TLSClientParameters tlsParams = new TLSClientParameters();
if (!validateCerts) {
tlsParams.setTrustManagers(new TrustManager[] { new AcceptAllTrustManager() });
} else if (trustManagers != null) {
tlsParams.setTrustManagers(trustManagers);
}
tlsParams.setDisableCNCheck(!validateCn);
conduit.setTlsClientParameters(tlsParams);
}
HTTPClientPolicy policy = conduit.getClient();
policy.setConnectionTimeout(connectionTimeoutUnits.toMillis(connectionTimeout));
policy.setReceiveTimeout(receiveTimeoutUnits.toMillis(receiveTimeout));
return rootResource;
}
use of org.apache.cxf.transport.http.HTTPConduit in project components by Talend.
the class AmbariClientBuilder method closeClient.
/**
* Closes the transport level conduit in the client. Reopening a new connection, requires creating a new client
* object using the build() method in this builder.
*
* @param root The resource returned by the build() method of this builder class
*/
public static void closeClient(ApiRootResource root) {
ClientConfiguration config = WebClient.getConfig(root);
HTTPConduit conduit = config.getHttpConduit();
if (conduit == null) {
throw new IllegalArgumentException("Client is not using the HTTP transport");
}
conduit.close();
}
use of org.apache.cxf.transport.http.HTTPConduit in project jbpm by kiegroup.
the class WebServiceCommand method applyAuthorization.
protected void applyAuthorization(String userName, String password, Client client) {
if (userName != null && password != null) {
HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
AuthorizationPolicy authorizationPolicy = new AuthorizationPolicy();
authorizationPolicy.setUserName(userName);
authorizationPolicy.setPassword(password);
authorizationPolicy.setAuthorizationType("Basic");
httpConduit.setAuthorization(authorizationPolicy);
} else {
logger.warn("UserName and Password must be provided to set the authorization policy.");
}
}
use of org.apache.cxf.transport.http.HTTPConduit in project jbossws-cxf by jbossws.
the class Helper method testFailureGZIPServerSideOnlyInterceptorOnClient.
public boolean testFailureGZIPServerSideOnlyInterceptorOnClient() throws Exception {
HelloWorld port = getPort();
Client client = ClientProxy.getClient(port);
HTTPConduit conduit = (HTTPConduit) client.getConduit();
HTTPClientPolicy policy = conduit.getClient();
// enable Accept gzip, otherwise the server will not try to reply using gzip
policy.setAcceptEncoding("gzip;q=1.0, identity; q=0.5, *;q=0");
try {
port.echo("foo");
return false;
} catch (Exception e) {
// expected exception, as the client is not able to decode gzip message
return true;
}
}
Aggregations