org.apache.commons.ssl
Class SSLServer

java.lang.Object
  extended by javax.net.ServerSocketFactory
      extended by javax.net.ssl.SSLServerSocketFactory
          extended by org.apache.commons.ssl.SSLServer

public class SSLServer
extends SSLServerSocketFactory

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

Field Summary
protected  SSL ssl
           
 
Constructor Summary
SSLServer()
           
 
Method Summary
 void addTrustMaterial(TrustChain trustChain)
           
 ServerSocket createServerSocket()
           
 ServerSocket createServerSocket(int port)
           
 ServerSocket createServerSocket(int port, int backlog)
           
 ServerSocket createServerSocket(int port, int backlog, InetAddress localHost)
          Attempts to get a new socket connection to the given host within the given time limit.
 X509Certificate[] getAssociatedCertificateChain()
           
 boolean getCheckCRL()
           
 boolean getCheckExpiry()
           
 boolean getCheckHostname()
           
 int getConnectTimeout()
           
 X509Certificate[] getCurrentClientChain()
           
 String[] getDefaultCipherSuites()
           
 String getDefaultProtocol()
           
 String[] getEnabledCiphers()
           
 String[] getEnabledProtocols()
           
 HostnameVerifier getHostnameVerifier()
           
 boolean getNeedClientAuth()
           
 int getSoTimeout()
           
 SSLContext getSSLContext()
           
 SSLWrapperFactory getSSLWrapperFactory()
           
 String[] getSupportedCipherSuites()
           
 TrustChain getTrustChain()
           
 boolean getUseClientMode()
           
 boolean getWantClientAuth()
           
 void setCheckCRL(boolean b)
           
 void setCheckExpiry(boolean b)
           
 void setCheckHostname(boolean b)
           
 void setConnectTimeout(int i)
           
 void setDefaultProtocol(String s)
           
 void setDnsOverride(Map m)
           
 void setEnabledCiphers(String[] ciphers)
           
 void setEnabledProtocols(String[] protocols)
           
 void setHostnameVerifier(HostnameVerifier verifier)
           
 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()
           
private  boolean useDefaultKeyMaterial()
           
 void useStrongCiphers()
           
 boolean useTomcatSSLMaterial()
          Tries to extract the TrustMaterial and KeyMaterial being used by a Tomcat SSL server (usually on 8443) by analyzing Tomcat's "server.xml" file.
 
Methods inherited from class javax.net.ssl.SSLServerSocketFactory
getDefault
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ssl

protected final SSL ssl
Constructor Detail

SSLServer

public SSLServer()
          throws GeneralSecurityException,
                 IOException
Throws:
GeneralSecurityException
IOException
Method Detail

useTomcatSSLMaterial

public boolean useTomcatSSLMaterial()
                             throws GeneralSecurityException,
                                    IOException
Tries to extract the TrustMaterial and KeyMaterial being used by a Tomcat SSL server (usually on 8443) by analyzing Tomcat's "server.xml" file. If the extraction is successful, the TrustMaterial and KeyMaterial are applied to this SSLServer.

Returns:
true if the operation was successful.
Throws:
GeneralSecurityException - setKeyMaterial() failed
IOException - setKeyMaterial() failed

useDefaultKeyMaterial

private boolean useDefaultKeyMaterial()
                               throws GeneralSecurityException,
                                      IOException
Throws:
GeneralSecurityException
IOException

setDnsOverride

public void setDnsOverride(Map m)

addTrustMaterial

public void addTrustMaterial(TrustChain trustChain)
                      throws NoSuchAlgorithmException,
                             KeyStoreException,
                             KeyManagementException,
                             IOException,
                             CertificateException
Throws:
NoSuchAlgorithmException
KeyStoreException
KeyManagementException
IOException
CertificateException

setTrustMaterial

public void setTrustMaterial(TrustChain trustChain)
                      throws NoSuchAlgorithmException,
                             KeyStoreException,
                             KeyManagementException,
                             IOException,
                             CertificateException
Throws:
NoSuchAlgorithmException
KeyStoreException
KeyManagementException
IOException
CertificateException

setKeyMaterial

public void setKeyMaterial(KeyMaterial keyMaterial)
                    throws NoSuchAlgorithmException,
                           KeyStoreException,
                           KeyManagementException,
                           IOException,
                           CertificateException
Throws:
NoSuchAlgorithmException
KeyStoreException
KeyManagementException
IOException
CertificateException

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(String s)

useDefaultJavaCiphers

public void useDefaultJavaCiphers()

useStrongCiphers

public void useStrongCiphers()

setEnabledCiphers

public void setEnabledCiphers(String[] ciphers)

setEnabledProtocols

public void setEnabledProtocols(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)

getAssociatedCertificateChain

public X509Certificate[] getAssociatedCertificateChain()

getCheckCRL

public boolean getCheckCRL()

getCheckExpiry

public boolean getCheckExpiry()

getCheckHostname

public boolean getCheckHostname()

getConnectTimeout

public int getConnectTimeout()

getDefaultProtocol

public String getDefaultProtocol()

getEnabledCiphers

public String[] getEnabledCiphers()

getEnabledProtocols

public 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 SSLContext getSSLContext()
                         throws GeneralSecurityException,
                                IOException
Throws:
GeneralSecurityException
IOException

getTrustChain

public TrustChain getTrustChain()

getCurrentClientChain

public X509Certificate[] getCurrentClientChain()

getDefaultCipherSuites

public String[] getDefaultCipherSuites()
Specified by:
getDefaultCipherSuites in class SSLServerSocketFactory

getSupportedCipherSuites

public String[] getSupportedCipherSuites()
Specified by:
getSupportedCipherSuites in class SSLServerSocketFactory

createServerSocket

public ServerSocket createServerSocket()
                                throws IOException
Overrides:
createServerSocket in class ServerSocketFactory
Throws:
IOException

createServerSocket

public ServerSocket createServerSocket(int port)
                                throws IOException
Specified by:
createServerSocket in class ServerSocketFactory
Throws:
IOException

createServerSocket

public ServerSocket createServerSocket(int port,
                                       int backlog)
                                throws IOException
Specified by:
createServerSocket in class ServerSocketFactory
Throws:
IOException

createServerSocket

public ServerSocket createServerSocket(int port,
                                       int backlog,
                                       InetAddress localHost)
                                throws IOException
Attempts to get a new socket connection to the given host within the given time limit.

Specified by:
createServerSocket in class ServerSocketFactory
Parameters:
localHost - the local host name/IP to bind against (null == ANY)
port - the port to listen on
backlog - number of connections allowed to queue up for accept().
Returns:
SSLServerSocket a new server socket
Throws:
IOException - if an I/O error occurs while creating thesocket