nl.nikhef.slcshttps.crypto
Class CryptoSSL

java.lang.Object
  extended by nl.nikhef.slcshttps.crypto.CryptoSSL

public class CryptoSSL
extends Object

The main task of this class is to provide a SSLSocketFactory for a given CryptoStore containing a client certificate and corresponding private key, this is the input needed for setting up Client Side authentication during SSL setup.

Version:
0.1
Author:
Mischa Sallé

Field Summary
private  KeyManager[] keyManagers
          Contains the KeyManagers to be used for client side authentication.
private  TrustManager[] trustManagers
          Contains the TrustManagers which provide authentication of server side.
 
Constructor Summary
CryptoSSL(CryptoStore cryptoStore)
          constructs a new CryptoSSL, initializing the keyManagers field using the given CryptoStore, while using the default TrustManager.
CryptoSSL(CryptoStore cryptoStore, TrustManager trustManager)
          constructs a new CryptoSSL, initializing the keyManagers field using the given CryptoStore, parameter and the trustManagers field using the given TrustManager.
 
Method Summary
 void addCryptoStore(CryptoStore cryptoStore)
          Adds an extra KeyManager for the given CryptoStore parameter.
 SSLSocketFactory getSSLSocketFactory()
          Creates a SSLSocketFactory, which provides both key and trust material during the setting up of an SSL session.
 void init(CryptoStore cryptoStore)
          initializes the keyManagers field using the give CryptoStore and the trustManagers field to use the default TrustManager.
 void init(CryptoStore cryptoStore, TrustManager trustManager)
          initializes the keyManagers and trustManagers fields using the given CryptoStore and TrustManager parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

keyManagers

private KeyManager[] keyManagers
Contains the KeyManagers to be used for client side authentication.


trustManagers

private TrustManager[] trustManagers
Contains the TrustManagers which provide authentication of server side.

Constructor Detail

CryptoSSL

public CryptoSSL(CryptoStore cryptoStore)
          throws KeyStoreException
constructs a new CryptoSSL, initializing the keyManagers field using the given CryptoStore, while using the default TrustManager. Initialization is done using init(CryptoStore), so we can reinitialize the class.

Parameters:
cryptoStore - CryptoStore to get the KeyManager[] from.
Throws:
KeyStoreException
See Also:
CryptoSSL(CryptoStore,TrustManager), init(CryptoStore)

CryptoSSL

public CryptoSSL(CryptoStore cryptoStore,
                 TrustManager trustManager)
          throws KeyStoreException
constructs a new CryptoSSL, initializing the keyManagers field using the given CryptoStore, parameter and the trustManagers field using the given TrustManager. Initialization is done using #init(CryptoStore,TrustManager)}, so we can reinitialize the class.

Parameters:
cryptoStore - CryptoStore to get the KeyManager[] from.
trustManager - TrustManager to use for server certificate checking. Use null for the default.
Throws:
KeyStoreException
See Also:
init(CryptoStore,TrustManager)
Method Detail

init

public void init(CryptoStore cryptoStore)
          throws KeyStoreException
initializes the keyManagers field using the give CryptoStore and the trustManagers field to use the default TrustManager.

Parameters:
cryptoStore - CryptoStore to get the KeyManager[] from.
Throws:
KeyStoreException
See Also:
init(CryptoStore,TrustManager)

init

public void init(CryptoStore cryptoStore,
                 TrustManager trustManager)
          throws KeyStoreException
initializes the keyManagers and trustManagers fields using the given CryptoStore and TrustManager parameters.

Parameters:
cryptoStore - CryptoStore to get the KeyManager[] from.
trustManager - TrustManager to use for server certificate checking. Use null for the default.
Throws:
KeyStoreException

addCryptoStore

public void addCryptoStore(CryptoStore cryptoStore)
                    throws KeyStoreException
Adds an extra KeyManager for the given CryptoStore parameter. Hence multiple client certificates can be offered when setting up an SSL connection.

Parameters:
cryptoStore - CryptoStore to use to get an extra KeyManager for client certificate checking from.
Throws:
KeyStoreException - when getting the KeyManagers from cryptoStore failed.

getSSLSocketFactory

public SSLSocketFactory getSSLSocketFactory()
                                     throws KeyManagementException
Creates a SSLSocketFactory, which provides both key and trust material during the setting up of an SSL session. Key material is taken from keyManagers, trust material from trustManagerss.

Returns:
SSLSocketFactory
Throws:
KeyManagementException - in case of failure


nl.nikhef.slcshttps Mischa Sallé - msalle(AT)nikhef.nl