com.metamatrix.common.comm.platform.socket
Class SocketUtil

java.lang.Object
  extended by com.metamatrix.common.comm.platform.socket.SocketUtil

public class SocketUtil
extends java.lang.Object

This class provides some utility methods to create ssl sockets using the keystores and trust stores. these are the properties required for the making the ssl connection


Nested Class Summary
static class SocketUtil.SSLSocketFactory
           
 
Field Summary
static java.lang.String ANON_CIPHER_SUITE
           
static java.lang.String ANON_PROTOCOL
           
static java.lang.String NONE
           
static java.lang.String TRUSTSTORE_FILENAME
           
 
Constructor Summary
SocketUtil()
           
 
Method Summary
static void addCipherSuite(javax.net.ssl.SSLSocket engine, java.lang.String cipherSuite)
           
static javax.net.ssl.SSLContext getAnonSSLContext()
           
static javax.net.ssl.SSLContext getSSLContext(java.lang.String keystore, java.lang.String password, java.lang.String truststore, java.lang.String truststorePassword, java.lang.String algorithm, java.lang.String keystoreType, java.lang.String protocol)
           
static SocketUtil.SSLSocketFactory getSSLSocketFactory(java.util.Properties props)
           
static java.security.KeyStore loadKeyStore(java.lang.String name, java.lang.String password, java.lang.String type)
          Load any defined keystore file, by first looking in the classpath then looking in the file system path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRUSTSTORE_FILENAME

public static final java.lang.String TRUSTSTORE_FILENAME
See Also:
Constant Field Values

NONE

public static final java.lang.String NONE
See Also:
Constant Field Values

ANON_CIPHER_SUITE

public static final java.lang.String ANON_CIPHER_SUITE
See Also:
Constant Field Values

ANON_PROTOCOL

public static final java.lang.String ANON_PROTOCOL
See Also:
Constant Field Values
Constructor Detail

SocketUtil

public SocketUtil()
Method Detail

getSSLSocketFactory

public static SocketUtil.SSLSocketFactory getSSLSocketFactory(java.util.Properties props)
                                                       throws java.io.IOException,
                                                              java.security.GeneralSecurityException
Throws:
java.io.IOException
java.security.GeneralSecurityException

addCipherSuite

public static void addCipherSuite(javax.net.ssl.SSLSocket engine,
                                  java.lang.String cipherSuite)

getAnonSSLContext

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

getSSLContext

public static javax.net.ssl.SSLContext getSSLContext(java.lang.String keystore,
                                                     java.lang.String password,
                                                     java.lang.String truststore,
                                                     java.lang.String truststorePassword,
                                                     java.lang.String algorithm,
                                                     java.lang.String keystoreType,
                                                     java.lang.String protocol)
                                              throws java.io.IOException,
                                                     java.security.GeneralSecurityException
Throws:
java.io.IOException
java.security.GeneralSecurityException

loadKeyStore

public static java.security.KeyStore loadKeyStore(java.lang.String name,
                                                  java.lang.String password,
                                                  java.lang.String type)
                                           throws java.io.IOException,
                                                  java.security.NoSuchAlgorithmException,
                                                  java.security.cert.CertificateException,
                                                  java.security.KeyStoreException
Load any defined keystore file, by first looking in the classpath then looking in the file system path.

Parameters:
name - - name of the keystore
password - - password to load the keystore
type - - type of the keystore
Returns:
loaded keystore
Throws:
java.io.IOException
java.security.NoSuchAlgorithmException
java.security.cert.CertificateException
java.security.KeyStoreException


Copyright © 2009. All Rights Reserved.