org.apache.commons.ssl

## Class HttpSecureProtocol

- java.lang.Object
- - javax.net.SocketFactory
  - - javax.net.ssl.SSLSocketFactory
    - - org.apache.commons.ssl.SSLClient
      - - org.apache.commons.ssl.HttpSecureProtocol

All Implemented Interfaces:
  org.apache.commons.httpclient.protocol.ProtocolSocketFactory, org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory

Direct Known Subclasses:
  AuthSSLProtocolSocketFactory, EasySSLProtocolSocketFactory, StrictSSLProtocolSocketFactory, TrustSSLProtocolSocketFactory

    public class HttpSecureProtocol
    extends SSLClient
    implements org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory

Hook into HttpClient.

Since:
  5-May-2006
Author:
  Credit Union Central of British Columbia, www.cucbc.com, juliusdavies@cucbc.com

### Constructor Summary

Constructors
Constructor and Description
`HttpSecureProtocol()`

### Method Summary

Methods
`java.net.Socket` `createSocket(java.lang.String host, int port, java.net.InetAddress localAddress, int localPort, org.apache.commons.httpclient.params.HttpConnectionParams params)` Attempts to get a new socket connection to the given host within the given time limit.

### Methods inherited from class org.apache.commons.ssl.SSLClient

`addTrustMaterial, createSocket, createSocket, createSocket, createSocket, createSocket, createSocket, createSocket, getAssociatedCertificateChain, getCheckCRL, getCheckExpiry, getCheckHostname, getConnectTimeout, getCurrentServerChain, getDefaultCipherSuites, getDefaultProtocol, getEnabledCiphers, getEnabledProtocols, getHostnameVerifier, getNeedClientAuth, getSoTimeout, getSSLContext, getSSLWrapperFactory, getSupportedCipherSuites, getTrustChain, getUseClientMode, getWantClientAuth, isSecure, setCheckCRL, setCheckExpiry, setCheckHostname, setConnectTimeout, setDefaultProtocol, setDnsOverride, setEnabledCiphers, setEnabledProtocols, setHostnameVerifier, setIsSecure, setKeyMaterial, setNeedClientAuth, setSoTimeout, setSSLWrapperFactory, setTrustMaterial, setUseClientMode, setWantClientAuth, useDefaultJavaCiphers, useStrongCiphers`

### Methods inherited from class javax.net.ssl.SSLSocketFactory

`getDefault`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory

`createSocket`

### Methods inherited from interface org.apache.commons.httpclient.protocol.ProtocolSocketFactory

`createSocket, createSocket`

### Constructor Detail

#### HttpSecureProtocol

    public HttpSecureProtocol()
                       throws java.security.GeneralSecurityException,
                              java.io.IOException

Throws:
  `java.security.GeneralSecurityException`
  `java.io.IOException`

### Method Detail

#### createSocket

    public java.net.Socket createSocket(java.lang.String host,
                               int port,
                               java.net.InetAddress localAddress,
                               int localPort,
                               org.apache.commons.httpclient.params.HttpConnectionParams params)
                                 throws java.io.IOException

Attempts to get a new socket connection to the given host within the given time limit.

To circumvent the limitations of older JREs that do not support connect timeout a controller thread is executed. The controller thread attempts to create a new socket within the given limit of time. If socket constructor does not return until the timeout expires, the controller terminates and throws an `ConnectTimeoutException`

Specified by:
  `createSocket` in interface `org.apache.commons.httpclient.protocol.ProtocolSocketFactory`
Parameters:
  `host` - the host name/IP
  `port` - the port on the host
  `localAddress` - the local host name/IP to bind the socket to
  `localPort` - the port on the local machine
  `params` - `Http connection parameters`
Returns:
  Socket a new socket
Throws:
  `java.io.IOException` - if an I/O error occurs while creating the socket
  `java.net.UnknownHostException` - if the IP address of the host cannot be determined