Search in sources :

Example 11 with HTTPConduit

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);
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) Client(org.apache.cxf.endpoint.Client)

Example 12 with HTTPConduit

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;
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) TLSClientParameters(org.apache.cxf.configuration.jsse.TLSClientParameters) JAXRSClientFactoryBean(org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean) LoggingFeature(org.apache.cxf.feature.LoggingFeature) HTTPClientPolicy(org.apache.cxf.transports.http.configuration.HTTPClientPolicy) ClientConfiguration(org.apache.cxf.jaxrs.client.ClientConfiguration)

Example 13 with HTTPConduit

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();
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) ClientConfiguration(org.apache.cxf.jaxrs.client.ClientConfiguration)

Example 14 with HTTPConduit

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.");
    }
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) AuthorizationPolicy(org.apache.cxf.configuration.security.AuthorizationPolicy)

Example 15 with HTTPConduit

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;
    }
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) HTTPClientPolicy(org.apache.cxf.transports.http.configuration.HTTPClientPolicy) Client(org.apache.cxf.endpoint.Client) MalformedURLException(java.net.MalformedURLException)

Aggregations

HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)158 Client (org.apache.cxf.endpoint.Client)65 Test (org.junit.Test)60 HTTPClientPolicy (org.apache.cxf.transports.http.configuration.HTTPClientPolicy)52 URL (java.net.URL)43 TLSClientParameters (org.apache.cxf.configuration.jsse.TLSClientParameters)43 Bus (org.apache.cxf.Bus)36 QName (javax.xml.namespace.QName)24 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)23 KeyStore (java.security.KeyStore)21 Greeter (org.apache.hello_world.Greeter)21 SOAPService (org.apache.hello_world.services.SOAPService)21 Service (javax.xml.ws.Service)18 TrustManagerFactory (javax.net.ssl.TrustManagerFactory)17 InputStream (java.io.InputStream)15 AuthorizationPolicy (org.apache.cxf.configuration.security.AuthorizationPolicy)15 IOException (java.io.IOException)13 ExecutionException (java.util.concurrent.ExecutionException)13 TrustManager (javax.net.ssl.TrustManager)13 WebClient (org.apache.cxf.jaxrs.client.WebClient)11