Package org.teiid.net.socket
Class SocketUtil
- java.lang.Object
-
- org.teiid.net.socket.SocketUtil
-
public class SocketUtil extends 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
Nested Classes Modifier and Type Class Description static class
SocketUtil.SSLSocketFactory
-
Field Summary
Fields Modifier and Type Field Description static String
ALLOW_ANON
static String
ANON_CIPHER_SUITE
static String
DEFAULT_KEYSTORE_TYPE
static String
DEFAULT_PROTOCOL
static String
TRUSTSTORE_FILENAME
-
Constructor Summary
Constructors Constructor Description SocketUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
addCipherSuite(SSLSocket engine, String cipherSuite)
static SSLContext
getAnonSSLContext()
static KeyManager[]
getKeyManagers(String keystore, String password, String algorithm, String keystoreType, String keyAlias, String keyPassword)
static SSLContext
getSSLContext(String keystore, String password, String truststore, String truststorePassword, String algorithm, String keystoreType, String protocol, String keyAlias, String keyPassword, boolean trustAll, boolean checkExpired)
static SSLContext
getSSLContext(KeyManager[] keyManagers, TrustManager[] trustManagers, String protocol)
static SocketUtil.SSLSocketFactory
getSSLSocketFactory(Properties props)
static TrustManager[]
getTrustAllManagers()
static TrustManager[]
getTrustManagers(String truststore, String truststorePassword, String algorithm, String keystoreType, boolean checkExpired)
static KeyStore
loadKeyStore(String name, String password, String type)
Load any defined keystore file, by first looking in the classpath then looking in the file system path.
-
-
-
Field Detail
-
TRUSTSTORE_FILENAME
public static final String TRUSTSTORE_FILENAME
- See Also:
- Constant Field Values
-
ALLOW_ANON
public static final String ALLOW_ANON
- See Also:
- Constant Field Values
-
DEFAULT_KEYSTORE_TYPE
public static final String DEFAULT_KEYSTORE_TYPE
- See Also:
- Constant Field Values
-
ANON_CIPHER_SUITE
public static final String ANON_CIPHER_SUITE
- See Also:
- Constant Field Values
-
DEFAULT_PROTOCOL
public static final String DEFAULT_PROTOCOL
- See Also:
- Constant Field Values
-
-
Method Detail
-
getSSLSocketFactory
public static SocketUtil.SSLSocketFactory getSSLSocketFactory(Properties props) throws IOException, GeneralSecurityException
- Throws:
IOException
GeneralSecurityException
-
getAnonSSLContext
public static SSLContext getAnonSSLContext() throws IOException, GeneralSecurityException
- Throws:
IOException
GeneralSecurityException
-
getSSLContext
public static SSLContext getSSLContext(KeyManager[] keyManagers, TrustManager[] trustManagers, String protocol) throws IOException, GeneralSecurityException
- Throws:
IOException
GeneralSecurityException
-
getSSLContext
public static SSLContext getSSLContext(String keystore, String password, String truststore, String truststorePassword, String algorithm, String keystoreType, String protocol, String keyAlias, String keyPassword, boolean trustAll, boolean checkExpired) throws IOException, GeneralSecurityException
- Throws:
IOException
GeneralSecurityException
-
loadKeyStore
public static KeyStore loadKeyStore(String name, String password, String type) throws IOException, NoSuchAlgorithmException, CertificateException, KeyStoreException
Load any defined keystore file, by first looking in the classpath then looking in the file system path.- Parameters:
name
- - name of the keystorepassword
- - password to load the keystoretype
- - type of the keystore- Returns:
- loaded keystore
- Throws:
IOException
NoSuchAlgorithmException
CertificateException
KeyStoreException
-
getKeyManagers
public static KeyManager[] getKeyManagers(String keystore, String password, String algorithm, String keystoreType, String keyAlias, String keyPassword) throws IOException, GeneralSecurityException
- Throws:
IOException
GeneralSecurityException
-
getTrustManagers
public static TrustManager[] getTrustManagers(String truststore, String truststorePassword, String algorithm, String keystoreType, boolean checkExpired) throws IOException, GeneralSecurityException
- Throws:
IOException
GeneralSecurityException
-
getTrustAllManagers
public static TrustManager[] getTrustAllManagers()
-
-