Package org.apache.commons.httpclient.protocol

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


                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


        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

      final String inAliasMapString, final FeedType inFeedType,
      boolean useSPSearchVisibility) throws SharepointException {
    // Avoid a deprecation warning on an overloaded Protocol constructor
    // by passing the argument as a ProtocolSocketFactory instead of an
    // SSLProtocolSocketFactory.
    ProtocolSocketFactory socketFactory = new SSLProtocolSocketFactory();
    Protocol.registerProtocol("https",
        new Protocol("https", socketFactory, SPConstants.SSL_DEFAULT_PORT));

    this.clientFactory = clientFactory;
    kdcServer = inKdcHost;
View Full Code Here

        Protocol protocol = PROTOCOL.get(scheme);
        if (protocol == null)
        {
            HttpsConnector httpsConnector = (HttpsConnector) httpConnector;
            SSLSocketFactory factory = httpsConnector.getSslSocketFactory();
            ProtocolSocketFactory protocolSocketFactory = new MuleSecureProtocolSocketFactory(factory);
            protocol = new Protocol(scheme, protocolSocketFactory, 443);
            PROTOCOL.put(scheme, protocol);
        }
        return protocol;
    }
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

                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

                final String host = (null == proxyHostName) ? hostName : proxyHostName;
                final int port = (null == proxyHostName) ? portNumber : proxyPortNumber;

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

                final ProtocolSocketFactory socketFactory =
                    (isSecure()
                        && !isProxied()
                            ? protocolInUse.getSocketFactory()
                            : new DefaultProtocolSocketFactory());

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

     * @param useInsecureSSL whether or not to use insecure SSL
     * @throws GeneralSecurityException if a security error occurs
     */
    public void setUseInsecureSSL(final boolean useInsecureSSL) throws GeneralSecurityException {
        if (useInsecureSSL) {
            final ProtocolSocketFactory factory = new InsecureSSLProtocolSocketFactory();
            final Protocol https = new Protocol("https", factory, 443);
            Protocol.registerProtocol("https", https);
        }
        else {
            Protocol.unregisterProtocol("https");
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

        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

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.