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


                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 == _proxyHost) ? _host : _proxyHost;
                final int port = (null == _proxyHost) ? _port : _proxyPort;
               
                _usingSecureSocket = isSecure() && !isProxied();               
               
                final ProtocolSocketFactory socketFactory = (
                    isSecure() && !isProxied()
                    ? _protocol.getSocketFactory()
                    : new DefaultProtocolSocketFactory()
                );
               
                if (connect_timeout == 0) {
                    _socket = socketFactory.createSocket(host,port);
                } else {
                    SocketTask task = new SocketTask() {
                        public void doit() throws IOException {
                            s = socketFactory.createSocket(host,port);
                        }
                    };
                    TimeoutController.execute(task, connect_timeout);
                    _socket = task.s;
                    if (task.exception != null) throw task.exception;
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

        String factory;
        String scheme = targetURI.getScheme();
        int port = targetURI.getPort();
        org.apache.commons.httpclient.protocol.Protocol protocol;
        KeyMaterial keyMaterial = null;
        ProtocolSocketFactory socketFactory;

        if(!scheme.startsWith("http")) {
            // We're only interested in HTTP for this...
            return;
        }
View Full Code Here

        throw new ConfigurationException("Failed to locate keystore '" + keyStore + "'.");
    }

    private ProtocolSocketFactory createFactoryClass(String factory, KeyMaterial keyMaterial, Properties properties) throws ConfigurationException {
        ProtocolSocketFactory socketFactory = null;

        try {
            Class<?> factoryClass = ClassUtil.forName(factory, HttpProtocol.class);

            if(ProtocolSocketFactoryBuilder.class.isAssignableFrom(factoryClass)) {
View Full Code Here

      }
        return url;
    }

    protected void initializeProtocol(int port) {
        ProtocolSocketFactory factory;
      if((getAcceptSelfSignedCertificates().booleanValue())) {
        factory = new  EasySSLProtocolSocketFactory();
        Protocol easyhttps = new Protocol("https", factory, port);
        Protocol.registerProtocol("https", easyhttps);
      } else {
View Full Code Here

    // Javadoc inherited.
    protected Protocol updateProtocol(Protocol protocol) {

        // Create a protocol that encapsulates a socket factory that will
        // create socket wrappers around socket channels.
        ProtocolSocketFactory socketFactory = protocol.getSocketFactory();
        if (socketFactory instanceof SecureProtocolSocketFactory) {
            SecureProtocolSocketFactory secureSocketFactory =
                    (SecureProtocolSocketFactory) socketFactory;
            socketFactory = new SecureProtocolSocketChannelFactory(
                    secureSocketFactory, connectionTimeout);
View Full Code Here

    {       
        HostConfiguration hostConfig = new MuleHostConfiguration(super.getHostConfig(uri));

        HttpsConnector httpsConnector = (HttpsConnector) connector;
        SSLSocketFactory factory = httpsConnector.getSslSocketFactory();
        ProtocolSocketFactory protocolSocketFactory = new MuleSecureProtocolSocketFactory(factory);
        Protocol protocol = new Protocol(uri.getScheme().toLowerCase(), protocolSocketFactory, 443);
       
        String host = uri.getHost();
        int port = uri.getPort();
        hostConfig.setHost(host, port, protocol);           
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.