Package org.apache.commons.httpclient.protocol

Examples of org.apache.commons.httpclient.protocol.ProtocolSocketFactory


        try {
            if (this.socket == null) {
                usingSecureSocket = isSecure() && !isProxied();
                // use the protocol's socket factory unless this is a secure
                // proxied connection
                ProtocolSocketFactory socketFactory = null;
                if (isSecure() && isProxied()) {
                    Protocol defaultprotocol = Protocol.getProtocol("http");
                    socketFactory = defaultprotocol.getSocketFactory();
                } else {
                    socketFactory = this.protocolInUse.getSocketFactory();
                }
                this.socket = socketFactory.createSocket(
                            host, port,
                            localAddress, 0,
                            this.params);
            }
View Full Code Here


        HostConfiguration host;
        URI uri = new URI(locationURI, false);
        if (uri.getScheme().equals("https")) {
            synchronized (this) {
                if (protocol == null) {
                    ProtocolSocketFactory sf = new CommonsHttpSSLSocketFactory(
                                    endpoint.getSsl(),
                                    endpoint.getKeystoreManager());
                    protocol = new Protocol("https", sf, 443);
                }
            }
View Full Code Here

        assertTrue(p2.equals(p1));
    }
   
    public void testProtocolSocketFactory() {
       
        ProtocolSocketFactory p1 = new DefaultProtocolSocketFactory();
        ProtocolSocketFactory p2 = new DefaultProtocolSocketFactory();

        assertTrue(p1.equals(p2));
        assertTrue(p2.equals(p1));

        p1 = new SSLProtocolSocketFactory();
        p2 = new SSLProtocolSocketFactory();

        assertTrue(p1.equals(p2));
        assertTrue(p2.equals(p1));
       
    }
View Full Code Here

        assertTrue(p2.equals(p1));
       
    }
   
    public void testProtocolSocketFactorySublass() {
        ProtocolSocketFactory factory1 = new DefaultProtocolSocketFactory();
        ProtocolSocketFactory factory2 = new DefaultProtocolSocketFactory() {};

        Protocol protocolA = new Protocol("http", factory1, 80);
        Protocol protocolB = new Protocol("http", factory2, 80);
        Protocol protocolC = new Protocol("http", factory2, 80);
View Full Code Here

                X509TrustManager trustManager = new X509TrustManager(criteriaSet, context.getLocalSSLTrustEngine());
                X509KeyManager manager = new X509KeyManager(context.getLocalSSLCredential());
                HostnameVerifier hostnameVerifier = context.getLocalSSLHostnameVerifier();

                ProtocolSocketFactory socketFactory = getSSLSocketFactory(context, manager, trustManager, hostnameVerifier);
                Protocol protocol = new Protocol("https", socketFactory, 443);
                hc.setHost(uri.getHost(), uri.getPort(), protocol);

            }
View Full Code Here

    }
   
    private MuleHostConfiguration createHostConfiguration()
    {
        MuleHostConfiguration hostConfig = new MuleHostConfiguration();
        ProtocolSocketFactory socketFactory = new MockSecureProtocolFactory();
        Protocol protocol = new Protocol("http", socketFactory, 80);
        hostConfig.setHost("localhost", 80, protocol);
       
        // since we're using a setHost variant here, too let's assert that it actually worked
        assertMockSocketFactory(hostConfig);
View Full Code Here

     *
     * @throws Exception error
     */
    @Override
    public void afterPropertiesSet() throws Exception {
        ProtocolSocketFactory socketFactory = new TLSProtocolSocketFactory(keyManager, trustedKeys, sslHostnameVerification);
        Protocol p = new Protocol(protocolName, socketFactory, protocolPort);
        Protocol.registerProtocol(protocolName, p);
    }
View Full Code Here

   * Configures the HTTP client
   */
  private void configureClient() {

    // Set up an HTTPS socket factory that accepts self-signed certs.
    ProtocolSocketFactory factory = new SSLProtocolSocketFactory();
    Protocol https = new Protocol("https", factory, 443);
    Protocol.registerProtocol("https", https);

    HttpConnectionManagerParams params = connectionManager.getParams();
    params.setConnectionTimeout(timeout);
View Full Code Here

   
    protected void init() throws JBIException {
        super.init();
        try {
            URI uri = new URI(url);
            ProtocolSocketFactory sf = new CommonsHttpSSLSocketFactory();
            Protocol protocol = new Protocol("https", sf, 443);
            HttpHost host = new HttpHost(uri.getHost(), uri.getPort(), protocol);
            hostConfiguration.setHost(host);
        } catch (Exception e) {
            throw new JBIException("Unable to initialize HttpsInvoker", e);
View Full Code Here

                usingSecureSocket = isSecure() && !isProxied();

                // use the protocol's socket factory unless this is a secure
                // proxied connection
                final ProtocolSocketFactory socketFactory =
                    (isSecure() && isProxied()
                            ? new DefaultProtocolSocketFactory()
                            : protocolInUse.getSocketFactory());

                if (connectTimeout == 0) {
                    if (localAddress != null) {
                        socket = socketFactory.createSocket(host, port, localAddress, 0);
                    } else {
                        socket = socketFactory.createSocket(host, port);
                    }
                } else {
                    SocketTask task = new SocketTask() {
                        public void doit() throws IOException {
                            if (localAddress != null) {
                                setSocket(socketFactory.createSocket(host, port, localAddress, 0));
                            } else {
                                setSocket(socketFactory.createSocket(host, port));
                            }
                        }
                    };
                    TimeoutController.execute(task, connectTimeout);
                    socket = task.getSocket();
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.protocol.ProtocolSocketFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.