Search in sources :

Example 1 with ProtocolSocketFactory

use of org.apache.commons.httpclient.protocol.ProtocolSocketFactory in project zm-mailbox by Zimbra.

the class SocketFactories method register.

private static synchronized void register(X509TrustManager tm) {
    if (registered)
        return;
    // Set default TrustManager
    TrustManagers.setDefaultTrustManager(tm);
    // Register Apache Commons HTTP/HTTPS protocol socket factories
    ProtocolSocketFactory psf = defaultProtocolSocketFactory();
    Protocol.registerProtocol(HTTP, new Protocol(HTTP, psf, 80));
    ProtocolSocketFactory spsf = defaultSecureProtocolSocketFactory();
    Protocol.registerProtocol(HTTPS, new Protocol(HTTPS, spsf, 443));
    // HttpURLConnection already uses system ProxySelector by default
    // Set HttpsURLConnection SSL socket factory and optional hostname verifier
    HttpsURLConnection.setDefaultSSLSocketFactory(defaultSSLSocketFactory(false));
    if (tm instanceof CustomTrustManager) {
        HttpsURLConnection.setDefaultHostnameVerifier(new CustomHostnameVerifier());
    }
    // Set the system-wide default ProxySelector
    ProxySelector.setDefault(ProxySelectors.defaultProxySelector());
    registered = true;
}
Also used : ProtocolSocketFactory(org.apache.commons.httpclient.protocol.ProtocolSocketFactory) SecureProtocolSocketFactory(org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory) Protocol(org.apache.commons.httpclient.protocol.Protocol)

Example 2 with ProtocolSocketFactory

use of org.apache.commons.httpclient.protocol.ProtocolSocketFactory in project translationstudio8 by heartsome.

the class ServiceUtilTest method getService.

public static IService getService() throws MalformedURLException {
    // Service srvcModel = new
    // ObjectServiceFactory().create(IService.class);
    // XFireProxyFactory factory = new XFireProxyFactory(XFireFactory
    // .newInstance().getXFire());
    //
    // IService srvc = (IService) factory.create(srvcModel,
    // Constants.CONNECT_URL);
    // return srvc;
    ProtocolSocketFactory easy = new EasySSLProtocolSocketFactory();
    Protocol protocol = new Protocol(HTTP_TYPE, easy, PORT);
    Protocol.registerProtocol(HTTP_TYPE, protocol);
    Service serviceModel = new ObjectServiceFactory().create(IService.class, SERVICE_NAME, SERVICE_NAMESPACE, null);
    IService service = (IService) new XFireProxyFactory().create(serviceModel, SERVICE_URL);
    Client client = ((XFireProxy) Proxy.getInvocationHandler(service)).getClient();
    client.addOutHandler(new DOMOutHandler());
    client.setProperty(CommonsHttpMessageSender.GZIP_ENABLED, Boolean.FALSE);
    client.setProperty(CommonsHttpMessageSender.DISABLE_EXPECT_CONTINUE, "1");
    client.setProperty(CommonsHttpMessageSender.HTTP_TIMEOUT, "0");
    return service;
}
Also used : ProtocolSocketFactory(org.apache.commons.httpclient.protocol.ProtocolSocketFactory) EasySSLProtocolSocketFactory(org.codehaus.xfire.transport.http.EasySSLProtocolSocketFactory) ObjectServiceFactory(org.codehaus.xfire.service.binding.ObjectServiceFactory) DOMOutHandler(org.codehaus.xfire.util.dom.DOMOutHandler) Service(org.codehaus.xfire.service.Service) Protocol(org.apache.commons.httpclient.protocol.Protocol) Client(org.codehaus.xfire.client.Client) XFireProxy(org.codehaus.xfire.client.XFireProxy) XFireProxyFactory(org.codehaus.xfire.client.XFireProxyFactory) EasySSLProtocolSocketFactory(org.codehaus.xfire.transport.http.EasySSLProtocolSocketFactory)

Example 3 with ProtocolSocketFactory

use of org.apache.commons.httpclient.protocol.ProtocolSocketFactory in project camel by apache.

the class HttpsSslContextParametersGetTest method createRouteBuilder.

@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {

        public void configure() {
            SSLContextParameters params = new SSLContextParameters();
            ProtocolSocketFactory factory = new SSLContextParametersSecureProtocolSocketFactory(params, context);
            Protocol.registerProtocol("https", new Protocol("https", factory, 443));
            from("direct:start").to("https://mail.google.com/mail/").to("mock:results");
        }
    };
}
Also used : ProtocolSocketFactory(org.apache.commons.httpclient.protocol.ProtocolSocketFactory) RouteBuilder(org.apache.camel.builder.RouteBuilder) Protocol(org.apache.commons.httpclient.protocol.Protocol) SSLContextParameters(org.apache.camel.util.jsse.SSLContextParameters)

Example 4 with ProtocolSocketFactory

use of org.apache.commons.httpclient.protocol.ProtocolSocketFactory in project zaproxy by zaproxy.

the class OptionsParamCertificate method setActiveCertificate.

public void setActiveCertificate() {
    ProtocolSocketFactory sslFactory = Protocol.getProtocol("https").getSocketFactory();
    if (sslFactory instanceof SSLConnector) {
        SSLConnector ssl = (SSLConnector) sslFactory;
        ssl.setActiveCertificate();
    }
}
Also used : ProtocolSocketFactory(org.apache.commons.httpclient.protocol.ProtocolSocketFactory) SSLConnector(org.parosproxy.paros.network.SSLConnector)

Example 5 with ProtocolSocketFactory

use of org.apache.commons.httpclient.protocol.ProtocolSocketFactory in project zaproxy by zaproxy.

the class OptionsParamCertificate method setEnableCertificate.

public void setEnableCertificate(boolean enabled) {
    ProtocolSocketFactory sslFactory = Protocol.getProtocol("https").getSocketFactory();
    if (sslFactory instanceof SSLConnector) {
        SSLConnector ssl = (SSLConnector) sslFactory;
        ssl.setEnableClientCert(enabled);
        setUseClientCert(enabled);
    }
}
Also used : ProtocolSocketFactory(org.apache.commons.httpclient.protocol.ProtocolSocketFactory) SSLConnector(org.parosproxy.paros.network.SSLConnector)

Aggregations

ProtocolSocketFactory (org.apache.commons.httpclient.protocol.ProtocolSocketFactory)8 Protocol (org.apache.commons.httpclient.protocol.Protocol)6 SecureProtocolSocketFactory (org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory)2 Client (org.codehaus.xfire.client.Client)2 XFireProxy (org.codehaus.xfire.client.XFireProxy)2 XFireProxyFactory (org.codehaus.xfire.client.XFireProxyFactory)2 Service (org.codehaus.xfire.service.Service)2 ObjectServiceFactory (org.codehaus.xfire.service.binding.ObjectServiceFactory)2 EasySSLProtocolSocketFactory (org.codehaus.xfire.transport.http.EasySSLProtocolSocketFactory)2 DOMOutHandler (org.codehaus.xfire.util.dom.DOMOutHandler)2 SSLConnector (org.parosproxy.paros.network.SSLConnector)2 BufferedInputStream (java.io.BufferedInputStream)1 BufferedOutputStream (java.io.BufferedOutputStream)1 IOException (java.io.IOException)1 InterruptedIOException (java.io.InterruptedIOException)1 RouteBuilder (org.apache.camel.builder.RouteBuilder)1 SSLContextParameters (org.apache.camel.util.jsse.SSLContextParameters)1 HostConfiguration (org.apache.commons.httpclient.HostConfiguration)1 HttpClient (org.apache.commons.httpclient.HttpClient)1 HttpHost (org.apache.commons.httpclient.HttpHost)1