org.apache.commons.ssl
Class JavaImpl

java.lang.Object
  extended by org.apache.commons.ssl.JavaImpl
Direct Known Subclasses:
Java13, Java14

public abstract class JavaImpl
extends Object

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

Field Summary
private static JavaImpl HANDLER
           
 
Constructor Summary
JavaImpl()
           
 
Method Summary
protected abstract  Object buildKeyManagerFactory(KeyStore ks, char[] pass)
           
protected abstract  Socket buildPlainSocket(SSL ssl, String remoteHost, int remotePort, InetAddress localHost, int localPort, int connectTimeout)
           
protected abstract  RuntimeException buildRuntimeException(Exception cause)
           
protected abstract  SSLServerSocket buildServerSocket(SSL ssl)
           
protected abstract  SSLSocket buildSocket(SSL ssl)
           
protected abstract  SSLSocket buildSocket(SSL ssl, String remoteHost, int remotePort, InetAddress localHost, int localPort, int connectTimeout)
           
protected abstract  SSLServerSocketFactory buildSSLServerSocketFactory(Object ssl)
           
protected abstract  SSLSocketFactory buildSSLSocketFactory(Object ssl)
           
protected abstract  Object buildTrustManagerFactory(KeyStore ks)
           
protected abstract  void checkTrusted(Object trustManager, X509Certificate[] chain, String authType)
           
protected static Socket connect(Socket s, SocketFactory sf, String remoteHost, int remotePort, InetAddress localHost, int localPort, int timeout, SSL ssl)
           
protected abstract  Socket connectSocket(Socket s, SocketFactory sf, String remoteHost, int remotePort, InetAddress localHost, int localPort, int timeout, SSL ssl)
           
static Socket createPlainSocket(SSL ssl, String remoteHost, int remotePort, InetAddress localHost, int localPort, int connectTimeout)
           
static SSLServerSocket createServerSocket(SSL ssl)
           
static SSLSocket createSocket(SSL ssl)
           
static SSLSocket createSocket(SSL ssl, String remoteHost, int remotePort, InetAddress localHost, int localPort, int connectTimeout)
           
static void downgrade()
           
protected abstract  void enabledProtocols(Object o, String[] enabledProtocols)
           
static String getIssuerX500(X509Certificate cert)
           
static Object[] getKeyManagers(Object keyManagerFactory)
           
static Certificate[] getPeerCertificates(SSLSession session)
           
static SSLServerSocketFactory getSSLServerSocketFactory(Object sslContext)
           
static SSLSocketFactory getSSLSocketFactory(Object sslContext)
           
static String getSubjectX500(X509Certificate cert)
           
static Object[] getTrustManagers(Object trustManagerFactory)
           
abstract  String getVersion()
           
static Object init(SSL ssl, TrustChain trustChain, KeyMaterial keyMaterial)
           
protected abstract  Object initSSL(SSL ssl, TrustChain tc, KeyMaterial km)
           
static boolean isJava13()
           
static void load()
           
static Object newKeyManagerFactory(KeyStore ks, char[] password)
           
static RuntimeException newRuntimeException(Exception cause)
           
static Object newTrustManagerFactory(KeyStore ks)
           
protected abstract  String retrieveIssuerX500(X509Certificate cert)
           
protected abstract  Object[] retrieveKeyManagers(Object keyManagerFactory)
           
protected abstract  Certificate[] retrievePeerCerts(SSLSession sslSession)
           
protected abstract  String retrieveSubjectX500(X509Certificate cert)
           
protected abstract  Object[] retrieveTrustManagers(Object trustManagerFactory)
           
static void setEnabledProtocols(Object o, String[] enabledProtocols)
           
static void setWantClientAuth(Object o, boolean wantClientAuth)
           
static void testTrust(Object trustManager, X509Certificate[] chain, String authType)
           
static void uprade()
           
protected abstract  void wantClientAuth(Object o, boolean wantClientAuth)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HANDLER

private static JavaImpl HANDLER
Constructor Detail

JavaImpl

public JavaImpl()
Method Detail

downgrade

public static void downgrade()

isJava13

public static boolean isJava13()

uprade

public static void uprade()

getVersion

public abstract String getVersion()

buildKeyManagerFactory

protected abstract Object buildKeyManagerFactory(KeyStore ks,
                                                 char[] pass)
                                          throws NoSuchAlgorithmException,
                                                 KeyStoreException,
                                                 UnrecoverableKeyException
Throws:
NoSuchAlgorithmException
KeyStoreException
UnrecoverableKeyException

retrieveKeyManagers

protected abstract Object[] retrieveKeyManagers(Object keyManagerFactory)

buildTrustManagerFactory

protected abstract Object buildTrustManagerFactory(KeyStore ks)
                                            throws NoSuchAlgorithmException,
                                                   KeyStoreException
Throws:
NoSuchAlgorithmException
KeyStoreException

retrieveTrustManagers

protected abstract Object[] retrieveTrustManagers(Object trustManagerFactory)

retrieveSubjectX500

protected abstract String retrieveSubjectX500(X509Certificate cert)

retrieveIssuerX500

protected abstract String retrieveIssuerX500(X509Certificate cert)

retrievePeerCerts

protected abstract Certificate[] retrievePeerCerts(SSLSession sslSession)
                                            throws SSLPeerUnverifiedException
Throws:
SSLPeerUnverifiedException

buildSSLSocketFactory

protected abstract SSLSocketFactory buildSSLSocketFactory(Object ssl)

buildSSLServerSocketFactory

protected abstract SSLServerSocketFactory buildSSLServerSocketFactory(Object ssl)

buildSocket

protected abstract SSLSocket buildSocket(SSL ssl)
                                  throws IOException
Throws:
IOException

buildSocket

protected abstract SSLSocket buildSocket(SSL ssl,
                                         String remoteHost,
                                         int remotePort,
                                         InetAddress localHost,
                                         int localPort,
                                         int connectTimeout)
                                  throws IOException
Throws:
IOException

buildPlainSocket

protected abstract Socket buildPlainSocket(SSL ssl,
                                           String remoteHost,
                                           int remotePort,
                                           InetAddress localHost,
                                           int localPort,
                                           int connectTimeout)
                                    throws IOException
Throws:
IOException

connectSocket

protected abstract Socket connectSocket(Socket s,
                                        SocketFactory sf,
                                        String remoteHost,
                                        int remotePort,
                                        InetAddress localHost,
                                        int localPort,
                                        int timeout,
                                        SSL ssl)
                                 throws IOException
Throws:
IOException

buildServerSocket

protected abstract SSLServerSocket buildServerSocket(SSL ssl)
                                              throws IOException
Throws:
IOException

wantClientAuth

protected abstract void wantClientAuth(Object o,
                                       boolean wantClientAuth)

enabledProtocols

protected abstract void enabledProtocols(Object o,
                                         String[] enabledProtocols)

buildRuntimeException

protected abstract RuntimeException buildRuntimeException(Exception cause)

initSSL

protected abstract Object initSSL(SSL ssl,
                                  TrustChain tc,
                                  KeyMaterial km)
                           throws NoSuchAlgorithmException,
                                  KeyStoreException,
                                  CertificateException,
                                  KeyManagementException,
                                  IOException
Throws:
NoSuchAlgorithmException
KeyStoreException
CertificateException
KeyManagementException
IOException

checkTrusted

protected abstract void checkTrusted(Object trustManager,
                                     X509Certificate[] chain,
                                     String authType)
                              throws CertificateException
Throws:
CertificateException

init

public static Object init(SSL ssl,
                          TrustChain trustChain,
                          KeyMaterial keyMaterial)
                   throws NoSuchAlgorithmException,
                          KeyStoreException,
                          CertificateException,
                          KeyManagementException,
                          IOException
Throws:
NoSuchAlgorithmException
KeyStoreException
CertificateException
KeyManagementException
IOException

newRuntimeException

public static RuntimeException newRuntimeException(Exception cause)

getSSLSocketFactory

public static SSLSocketFactory getSSLSocketFactory(Object sslContext)

getSSLServerSocketFactory

public static SSLServerSocketFactory getSSLServerSocketFactory(Object sslContext)

getSubjectX500

public static String getSubjectX500(X509Certificate cert)

getIssuerX500

public static String getIssuerX500(X509Certificate cert)

newKeyManagerFactory

public static Object newKeyManagerFactory(KeyStore ks,
                                          char[] password)
                                   throws NoSuchAlgorithmException,
                                          KeyStoreException,
                                          UnrecoverableKeyException
Throws:
NoSuchAlgorithmException
KeyStoreException
UnrecoverableKeyException

getKeyManagers

public static Object[] getKeyManagers(Object keyManagerFactory)

newTrustManagerFactory

public static Object newTrustManagerFactory(KeyStore ks)
                                     throws NoSuchAlgorithmException,
                                            KeyStoreException
Throws:
NoSuchAlgorithmException
KeyStoreException

getTrustManagers

public static Object[] getTrustManagers(Object trustManagerFactory)

createSocket

public static SSLSocket createSocket(SSL ssl)
                              throws IOException
Throws:
IOException

createSocket

public static SSLSocket createSocket(SSL ssl,
                                     String remoteHost,
                                     int remotePort,
                                     InetAddress localHost,
                                     int localPort,
                                     int connectTimeout)
                              throws IOException
Throws:
IOException

createPlainSocket

public static Socket createPlainSocket(SSL ssl,
                                       String remoteHost,
                                       int remotePort,
                                       InetAddress localHost,
                                       int localPort,
                                       int connectTimeout)
                                throws IOException
Throws:
IOException

connect

protected static Socket connect(Socket s,
                                SocketFactory sf,
                                String remoteHost,
                                int remotePort,
                                InetAddress localHost,
                                int localPort,
                                int timeout,
                                SSL ssl)
                         throws IOException
Throws:
IOException

createServerSocket

public static SSLServerSocket createServerSocket(SSL ssl)
                                          throws IOException
Throws:
IOException

setWantClientAuth

public static void setWantClientAuth(Object o,
                                     boolean wantClientAuth)

setEnabledProtocols

public static void setEnabledProtocols(Object o,
                                       String[] enabledProtocols)

getPeerCertificates

public static Certificate[] getPeerCertificates(SSLSession session)
                                         throws SSLPeerUnverifiedException
Throws:
SSLPeerUnverifiedException

testTrust

public static void testTrust(Object trustManager,
                             X509Certificate[] chain,
                             String authType)
                      throws CertificateException
Throws:
CertificateException

load

public static void load()