Search in sources :

Example 21 with ClientConfiguration

use of org.apache.cxf.jaxrs.client.ClientConfiguration in project maven-plugins by apache.

the class RestJiraDownloader method setupWebClient.

private WebClient setupWebClient(String jiraUrl) {
    WebClient client = WebClient.create(jiraUrl);
    ClientConfiguration clientConfiguration = WebClient.getConfig(client);
    HTTPConduit http = clientConfiguration.getHttpConduit();
    // MCHANGES-324 - Maintain the client session
    clientConfiguration.getRequestContext().put(Message.MAINTAIN_SESSION, Boolean.TRUE);
    if (getLog().isDebugEnabled()) {
        clientConfiguration.getInInterceptors().add(new LoggingInInterceptor());
        clientConfiguration.getOutInterceptors().add(new LoggingOutInterceptor());
    }
    HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
    // MCHANGES-341 Externalize JIRA server timeout values to the configuration section
    getLog().debug("RestJiraDownloader: connectionTimeout: " + connectionTimeout);
    httpClientPolicy.setConnectionTimeout(connectionTimeout);
    httpClientPolicy.setAllowChunking(false);
    getLog().debug("RestJiraDownloader: receiveTimout: " + receiveTimout);
    httpClientPolicy.setReceiveTimeout(receiveTimout);
    // MCHANGES-334 RestJiraDownloader doesn't honor proxy settings
    getProxyInfo(jiraUrl);
    if (proxyHost != null) {
        getLog().debug("Using proxy: " + proxyHost + " at port " + proxyPort);
        httpClientPolicy.setProxyServer(proxyHost);
        httpClientPolicy.setProxyServerPort(proxyPort);
        httpClientPolicy.setProxyServerType(ProxyServerType.HTTP);
        if (proxyUser != null) {
            ProxyAuthorizationPolicy proxyAuthorizationPolicy = new ProxyAuthorizationPolicy();
            proxyAuthorizationPolicy.setAuthorizationType("Basic");
            proxyAuthorizationPolicy.setUserName(proxyUser);
            proxyAuthorizationPolicy.setPassword(proxyPass);
            http.setProxyAuthorization(proxyAuthorizationPolicy);
        }
    }
    if (webUser != null) {
        AuthorizationPolicy authPolicy = new AuthorizationPolicy();
        authPolicy.setAuthorizationType("Basic");
        authPolicy.setUserName(webUser);
        authPolicy.setPassword(webPassword);
        http.setAuthorization(authPolicy);
    }
    http.setClient(httpClientPolicy);
    return client;
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) ProxyAuthorizationPolicy(org.apache.cxf.configuration.security.ProxyAuthorizationPolicy) AuthorizationPolicy(org.apache.cxf.configuration.security.AuthorizationPolicy) LoggingOutInterceptor(org.apache.cxf.interceptor.LoggingOutInterceptor) ProxyAuthorizationPolicy(org.apache.cxf.configuration.security.ProxyAuthorizationPolicy) HTTPClientPolicy(org.apache.cxf.transports.http.configuration.HTTPClientPolicy) LoggingInInterceptor(org.apache.cxf.interceptor.LoggingInInterceptor) WebClient(org.apache.cxf.jaxrs.client.WebClient) ClientConfiguration(org.apache.cxf.jaxrs.client.ClientConfiguration)

Aggregations

ClientConfiguration (org.apache.cxf.jaxrs.client.ClientConfiguration)21 WebClient (org.apache.cxf.jaxrs.client.WebClient)14 Test (org.junit.Test)6 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)3 HTTPClientPolicy (org.apache.cxf.transports.http.configuration.HTTPClientPolicy)3 Client (javax.ws.rs.client.Client)2 WebTarget (javax.ws.rs.client.WebTarget)2 ClientLifeCycleManagerImpl (org.apache.cxf.bus.managers.ClientLifeCycleManagerImpl)2 LoggingInInterceptor (org.apache.cxf.interceptor.LoggingInInterceptor)2 LoggingOutInterceptor (org.apache.cxf.interceptor.LoggingOutInterceptor)2 Service (org.apache.cxf.service.Service)2 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)2 SLEndpoint (org.talend.esb.servicelocator.client.SLEndpoint)2 PluginTestVerifier (com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ProcessingException (javax.ws.rs.ProcessingException)1 Response (javax.ws.rs.core.Response)1 TLSClientParameters (org.apache.cxf.configuration.jsse.TLSClientParameters)1 AuthorizationPolicy (org.apache.cxf.configuration.security.AuthorizationPolicy)1