Search in sources :

Example 11 with ProxyAuthorizationPolicy

use of org.apache.cxf.configuration.security.ProxyAuthorizationPolicy 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

ProxyAuthorizationPolicy (org.apache.cxf.configuration.security.ProxyAuthorizationPolicy)11 HTTPClientPolicy (org.apache.cxf.transports.http.configuration.HTTPClientPolicy)6 AuthorizationPolicy (org.apache.cxf.configuration.security.AuthorizationPolicy)5 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 IOException (java.io.IOException)2 PrintStream (java.io.PrintStream)2 MalformedURLException (java.net.MalformedURLException)2 URISyntaxException (java.net.URISyntaxException)2 Client (org.apache.cxf.endpoint.Client)2 Endpoint (org.apache.cxf.endpoint.Endpoint)2 CertConstraints (org.apache.cxf.transport.https.CertConstraints)2 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)2 JBossWSTest (org.jboss.wsf.test.JBossWSTest)2 Test (org.junit.Test)2 LoggingInInterceptor (org.apache.cxf.interceptor.LoggingInInterceptor)1 LoggingOutInterceptor (org.apache.cxf.interceptor.LoggingOutInterceptor)1 ClientConfiguration (org.apache.cxf.jaxrs.client.ClientConfiguration)1 WebClient (org.apache.cxf.jaxrs.client.WebClient)1