org.apache.commons.ssl
Class SSLClient

java.lang.Object
  extended by javax.net.SocketFactory
      extended by javax.net.ssl.SSLSocketFactory
          extended by org.apache.commons.ssl.SSLClient
Direct Known Subclasses:
CRLSocket, HttpSecureProtocol, LDAPSocket

public class SSLClient
extends javax.net.ssl.SSLSocketFactory

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

Field Summary
private  SSL ssl
           
 
Constructor Summary
SSLClient()
           
 
Method Summary
 void addTrustMaterial(TrustChain trustChain)
           
 java.net.Socket createSocket()
           
 java.net.Socket createSocket(java.net.InetAddress host, int port)
           
 java.net.Socket createSocket(java.net.InetAddress host, int port, java.net.InetAddress localHost, int localPort)
           
 java.net.Socket createSocket(java.net.Socket s, java.lang.String remoteHost, int remotePort, boolean autoClose)
           
 java.net.Socket createSocket(java.lang.String host, int port)
           
 java.net.Socket createSocket(java.lang.String host, int port, java.net.InetAddress localHost, int localPort)
           
 java.net.Socket createSocket(java.lang.String host, int port, java.net.InetAddress localHost, int localPort, int timeout)
          Attempts to get a new socket connection to the given host within the given time limit.
 java.security.cert.X509Certificate[] getAssociatedCertificateChain()
           
 boolean getCheckCRL()
           
 boolean getCheckExpiry()
           
 boolean getCheckHostname()
           
 int getConnectTimeout()
           
 java.security.cert.X509Certificate[] getCurrentServerChain()
           
 java.lang.String[] getDefaultCipherSuites()
           
 java.lang.String getDefaultProtocol()
           
 java.lang.String[] getEnabledCiphers()
           
 java.lang.String[] getEnabledProtocols()
           
 HostnameVerifier getHostnameVerifier()
           
 boolean getNeedClientAuth()
           
 int getSoTimeout()
           
 javax.net.ssl.SSLContext getSSLContext()
           
 SSLWrapperFactory getSSLWrapperFactory()
           
 java.lang.String[] getSupportedCipherSuites()
           
 TrustChain getTrustChain()
           
 boolean getUseClientMode()
           
 boolean getWantClientAuth()
           
 boolean isSecure()
           
 void setCheckCRL(boolean b)
           
 void setCheckExpiry(boolean b)
           
 void setCheckHostname(boolean b)
           
 void setConnectTimeout(int i)
           
 void setDefaultProtocol(java.lang.String s)
           
 void setDnsOverride(java.util.Map m)
           
 void setEnabledCiphers(java.lang.String[] ciphers)
           
 void setEnabledProtocols(java.lang.String[] protocols)
           
 void setHostnameVerifier(HostnameVerifier verifier)
           
 void setIsSecure(boolean b)
           
 void setKeyMaterial(KeyMaterial keyMaterial)
           
 void setNeedClientAuth(boolean b)
           
 void setSoTimeout(int soTimeout)
           
 void setSSLWrapperFactory(SSLWrapperFactory wf)
           
 void setTrustMaterial(TrustChain trustChain)
           
 void setUseClientMode(boolean b)
           
 void setWantClientAuth(boolean b)
           
 void useDefaultJavaCiphers()
           
 void 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
 

Field Detail

ssl

private final SSL ssl
Constructor Detail

SSLClient

public SSLClient()
          throws java.security.GeneralSecurityException,
                 java.io.IOException
Throws:
java.security.GeneralSecurityException
java.io.IOException
Method Detail

addTrustMaterial

public void addTrustMaterial(TrustChain trustChain)
                      throws java.security.NoSuchAlgorithmException,
                             java.security.KeyStoreException,
                             java.security.KeyManagementException,
                             java.io.IOException,
                             java.security.cert.CertificateException
Throws:
java.security.NoSuchAlgorithmException
java.security.KeyStoreException
java.security.KeyManagementException
java.io.IOException
java.security.cert.CertificateException

setTrustMaterial

public void setTrustMaterial(TrustChain trustChain)
                      throws java.security.NoSuchAlgorithmException,
                             java.security.KeyStoreException,
                             java.security.KeyManagementException,
                             java.io.IOException,
                             java.security.cert.CertificateException
Throws:
java.security.NoSuchAlgorithmException
java.security.KeyStoreException
java.security.KeyManagementException
java.io.IOException
java.security.cert.CertificateException

setKeyMaterial

public void setKeyMaterial(KeyMaterial keyMaterial)
                    throws java.security.NoSuchAlgorithmException,
                           java.security.KeyStoreException,
                           java.security.KeyManagementException,
                           java.io.IOException,
                           java.security.cert.CertificateException
Throws:
java.security.NoSuchAlgorithmException
java.security.KeyStoreException
java.security.KeyManagementException
java.io.IOException
java.security.cert.CertificateException

setIsSecure

public void setIsSecure(boolean b)

setDnsOverride

public void setDnsOverride(java.util.Map m)

setCheckCRL

public void setCheckCRL(boolean b)

setCheckExpiry

public void setCheckExpiry(boolean b)

setCheckHostname

public void setCheckHostname(boolean b)

setConnectTimeout

public void setConnectTimeout(int i)

setDefaultProtocol

public void setDefaultProtocol(java.lang.String s)

useDefaultJavaCiphers

public void useDefaultJavaCiphers()

useStrongCiphers

public void useStrongCiphers()

setEnabledCiphers

public void setEnabledCiphers(java.lang.String[] ciphers)

setEnabledProtocols

public void setEnabledProtocols(java.lang.String[] protocols)

setHostnameVerifier

public void setHostnameVerifier(HostnameVerifier verifier)

setSoTimeout

public void setSoTimeout(int soTimeout)

setSSLWrapperFactory

public void setSSLWrapperFactory(SSLWrapperFactory wf)

setNeedClientAuth

public void setNeedClientAuth(boolean b)

setWantClientAuth

public void setWantClientAuth(boolean b)

setUseClientMode

public void setUseClientMode(boolean b)

isSecure

public boolean isSecure()

getAssociatedCertificateChain

public java.security.cert.X509Certificate[] getAssociatedCertificateChain()

getCheckCRL

public boolean getCheckCRL()

getCheckExpiry

public boolean getCheckExpiry()

getCheckHostname

public boolean getCheckHostname()

getConnectTimeout

public int getConnectTimeout()

getDefaultProtocol

public java.lang.String getDefaultProtocol()

getEnabledCiphers

public java.lang.String[] getEnabledCiphers()

getEnabledProtocols

public java.lang.String[] getEnabledProtocols()

getHostnameVerifier

public HostnameVerifier getHostnameVerifier()

getSoTimeout

public int getSoTimeout()

getSSLWrapperFactory

public SSLWrapperFactory getSSLWrapperFactory()

getNeedClientAuth

public boolean getNeedClientAuth()

getWantClientAuth

public boolean getWantClientAuth()

getUseClientMode

public boolean getUseClientMode()

getSSLContext

public javax.net.ssl.SSLContext getSSLContext()
                                       throws java.security.GeneralSecurityException,
                                              java.io.IOException
Throws:
java.security.GeneralSecurityException
java.io.IOException

getTrustChain

public TrustChain getTrustChain()

getCurrentServerChain

public java.security.cert.X509Certificate[] getCurrentServerChain()

getDefaultCipherSuites

public java.lang.String[] getDefaultCipherSuites()
Specified by:
getDefaultCipherSuites in class javax.net.ssl.SSLSocketFactory

getSupportedCipherSuites

public java.lang.String[] getSupportedCipherSuites()
Specified by:
getSupportedCipherSuites in class javax.net.ssl.SSLSocketFactory

createSocket

public java.net.Socket createSocket()
                             throws java.io.IOException
Overrides:
createSocket in class javax.net.SocketFactory
Throws:
java.io.IOException

createSocket

public java.net.Socket createSocket(java.lang.String host,
                                    int port)
                             throws java.io.IOException
Specified by:
createSocket in class javax.net.SocketFactory
Throws:
java.io.IOException

createSocket

public java.net.Socket createSocket(java.net.InetAddress host,
                                    int port)
                             throws java.io.IOException
Specified by:
createSocket in class javax.net.SocketFactory
Throws:
java.io.IOException

createSocket

public java.net.Socket createSocket(java.net.InetAddress host,
                                    int port,
                                    java.net.InetAddress localHost,
                                    int localPort)
                             throws java.io.IOException
Specified by:
createSocket in class javax.net.SocketFactory
Throws:
java.io.IOException

createSocket

public java.net.Socket createSocket(java.lang.String host,
                                    int port,
                                    java.net.InetAddress localHost,
                                    int localPort)
                             throws java.io.IOException
Specified by:
createSocket in class javax.net.SocketFactory
Throws:
java.io.IOException

createSocket

public java.net.Socket createSocket(java.lang.String host,
                                    int port,
                                    java.net.InetAddress localHost,
                                    int localPort,
                                    int timeout)
                             throws java.io.IOException
Attempts to get a new socket connection to the given host within the given time limit.

Parameters:
host - the host name/IP
port - the port on the host
localHost - the local host name/IP to bind the socket to
localPort - the port on the local machine
timeout - the connection timeout (0==infinite)
Returns:
Socket a new socket
Throws:
java.io.IOException - if an I/O error occurs while creating thesocket
java.net.UnknownHostException - if the IP address of the host cannot be determined

createSocket

public java.net.Socket createSocket(java.net.Socket s,
                                    java.lang.String remoteHost,
                                    int remotePort,
                                    boolean autoClose)
                             throws java.io.IOException
Specified by:
createSocket in class javax.net.ssl.SSLSocketFactory
Throws:
java.io.IOException