Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

org.objectweb.cjdbc.common.net.SocketFactoryFactory Class Reference

List of all members.

Static Public Member Functions

ServerSocketFactory createServerFactory (SSLConfiguration config) throws SSLException
SocketFactory createFactory (SSLConfiguration config) throws Exception
SSLContext createSSLContext (SSLConfiguration config) throws Exception

Static Protected Member Functions

KeyManager[] getKeyManagers (File keyStore, String keyStorePassword, String keyPassword) throws IOException, GeneralSecurityException
TrustManager[] getTrustManagers (File trustStore, String trustStorePassword) throws IOException, GeneralSecurityException

Detailed Description

This class defines a SocketFactory

Author:
Marc Wick
Version:
1.0

Definition at line 50 of file SocketFactoryFactory.java.


Member Function Documentation

SocketFactory org.objectweb.cjdbc.common.net.SocketFactoryFactory.createFactory SSLConfiguration  config  )  throws Exception [static]
 

create a socket factory with the specified configuration

Parameters:
config - the ssl configuration
Returns:
- the socket factory
Exceptions:
Exception - could not create factory

Definition at line 92 of file SocketFactoryFactory.java.

00094   {
00095     if (config == null)
00096       // nothing todo return default SocketFactory
00097       return SocketFactory.getDefault();
00098 
00099     SSLContext context = createSSLContext(config);
00100 
00101     // Finally, we get a SocketFactory
00102     SSLSocketFactory ssf = context.getSocketFactory();
00103 
00104     if (!config.isClientAuthenticationRequired())
00105       return ssf;
00106 
00107     return new AuthenticatedSocketFactory(ssf);
00108   }

ServerSocketFactory org.objectweb.cjdbc.common.net.SocketFactoryFactory.createServerFactory SSLConfiguration  config  )  throws SSLException [static]
 

create a server socket factory with the specified configuration

Parameters:
config - the ssl configuration
Returns:
- the socket factory
Exceptions:
SSLException - could not create factory

Definition at line 60 of file SocketFactoryFactory.java.

00062   {
00063     try
00064     {
00065 
00066       if (config == null)
00067         // nothing todo return default SocketFactory
00068         return ServerSocketFactory.getDefault();
00069 
00070       SSLContext context = createSSLContext(config);
00071       // Finally, we get a SocketFactory
00072       SSLServerSocketFactory ssf = context.getServerSocketFactory();
00073 
00074       if (!config.isClientAuthenticationRequired())
00075         return ssf;
00076 
00077       return new AuthenticatedServerSocketFactory(ssf);
00078     }
00079     catch (Exception e)
00080     {
00081       throw new SSLException(e);
00082     }
00083   }

SSLContext org.objectweb.cjdbc.common.net.SocketFactoryFactory.createSSLContext SSLConfiguration  config  )  throws Exception [static]
 

create a ssl context

Parameters:
config - ssl config
Returns:
- the ssl context
Exceptions:
Exception - problems initializing the content

Definition at line 117 of file SocketFactoryFactory.java.

00119   {
00120 
00121     KeyManager[] kms = getKeyManagers(config.getKeyStore(), config
00122         .getKeyStorePassword(), config.getKeyStoreKeyPassword());
00123 
00124     TrustManager[] tms = getTrustManagers(config.getTrustStore(), config
00125         .getTrustStorePassword());
00126 
00127     // Now construct a SSLContext using these KeyManagers. We
00128     // specify a null SecureRandom, indicating that the
00129     // defaults should be used.
00130     SSLContext context = SSLContext.getInstance("SSL");
00131     context.init(kms, tms, null);
00132     return context;
00133   }


The documentation for this class was generated from the following file:
Generated on Mon Apr 11 22:02:02 2005 for C-JDBC by  doxygen 1.3.9.1