public class SSLContextFactory extends Object
Modifier and Type | Class and Description |
---|---|
protected class |
SSLContextFactory.NullStoreURLException
Used to indicate a store URL was not specified and thus the store is not available.
|
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_KEY_STORE_ALGORITHM
Default key/trust store algorithm if one net set as bean property or via config.
|
static String |
DEFAULT_KEY_STORE_TYPE
Default key/trust store type if one not set as bean property, via config, or via system property.
|
static String |
DEFAULT_SSL_PROTOCOL
If the protocol isn't specified, this will be the default.
|
static String |
KEY_PASSWORD
Constant defining the config property that indicates the key password for the keys in the key store.
|
static String |
SERVER_SSL_USE_CLIENT_MODE
Constant defining the config property used to define if the server sockets will be in
client or server mode.
|
static String |
SSL_SERVER_AUTH_MODE
Constant defining the config property used to define if a client should attempt to
authenticate a server certificate as one it trusts.
|
static String |
SSL_USE_CLIENT_MODE
Constant defining the config property used to define if the sockets will be in
client or server mode.
|
static String |
STANDARD_KEY_STORE_FILE_PATH
Constant that defines the standard system property that the javax.net.ssl
classes look for when locating the keystore file.
|
static String |
STANDARD_KEY_STORE_PASSWORD
Constant that defines the standard system property that the javax.net.ssl
classes look for when needing the keystore password.
|
static String |
STANDARD_KEY_STORE_TYPE
Constant that defines the standard system property that the javax.net.ssl
classes look for when needing to know what type the keystore file is.
|
static String |
STANDARD_TRUST_STORE_FILE_PATH
Constant that defines the standard system property that the javax.net.ssl
classes look for when locating the truststore file.
|
static String |
STANDARD_TRUST_STORE_PASSWORD
Constant that defines the standard system property that the javax.net.ssl
classes look for when needing the truststore password.
|
static String |
STANDARD_TRUST_STORE_TYPE
Constant that defines the standard system property that the javax.net.ssl
classes look for when needing to know what type the truststore file is.
|
Constructor and Description |
---|
SSLContextFactory()
Constructor for
SSLContextFactory that does not have
any configuration so it falls back to all defaults. |
SSLContextFactory(Map<String,Object> config)
Constructor for
SSLContextFactory that allows the caller to
override the default settings for the various SSL configuration
properties. |
Modifier and Type | Method and Description |
---|---|
protected void |
createServerSocketFactorySSLContext()
Creates (but does not initialize) the SSL context used by this object
to create server socket factories.
|
protected void |
createSocketFactorySSLContext()
Creates (but does not initialize) the SSL context used by this object
to create socket factories.
|
String |
getKeyAlias() |
String |
getKeyPassword()
Returns the password to use for the keys within the key store.
|
URL |
getKeyStore() |
String |
getKeyStoreAlgorithm() |
String |
getKeyStorePassword()
Returns the password used to gain access to the keystore.
|
String |
getKeyStoreType() |
String |
getKeyStoreURL() |
Provider |
getProvider() |
String |
getProviderName() |
SecureRandom |
getSecureRandom() |
String |
getSecureSocketProtocol() |
SSLContext |
getServerSSLContext() |
SSLContext |
getSSLContext() |
URL |
getTrustStore() |
String |
getTrustStoreAlgorithm() |
String |
getTrustStorePassword()
Returns the password used to gain access to the truststore.
|
String |
getTrustStoreType() |
String |
getTrustStoreURL() |
protected void |
initializeServerSocketFactorySSLContext()
Initializes the SSL context used by this object that will create the server socket factories.
|
protected void |
initializeSocketFactorySSLContext()
Initializes the SSL context used by this object that will create the socket factories.
|
boolean |
isServerAuthMode() |
boolean |
isServerSocketUseClientMode() |
boolean |
isSocketUseClientMode() |
protected KeyManager[] |
loadKeyManagers()
Loads the key managers based on this object's truststore.
|
protected KeyStore |
loadKeyStore(String storeType,
URL storePathURL,
String storePassword)
Loads a key store file and returns it.
|
protected TrustManager[] |
loadTrustManagers(boolean isClientMode)
Loads the trust managers based on this object's truststore.
|
void |
setKeyAlias(String alias) |
void |
setKeyPassword(String keyPassword) |
void |
setKeyStore(URL keyStore) |
void |
setKeyStoreAlgorithm(String algorithm) |
void |
setKeyStorePassword(String keyStorePassword) |
void |
setKeyStoreType(String keyStoreType) |
void |
setKeyStoreURL(String keyStoreFilePath) |
void |
setProvider(Provider provider) |
void |
setProviderName(String providerName) |
void |
setSecureRandom(SecureRandom secureRandom) |
void |
setSecureSocketProtocol(String protocol) |
void |
setServerAuthMode(boolean mode) |
void |
setServerSocketUseClientMode(boolean useClientMode) |
void |
setSocketUseClientMode(boolean useClientMode) |
void |
setTrustStore(URL trustStore) |
void |
setTrustStoreAlgorithm(String algorithm) |
void |
setTrustStorePassword(String trustStorePassword) |
void |
setTrustStoreType(String trustStoreType) |
void |
setTrustStoreURL(String trustStoreFilePath) |
protected URL |
validateStoreURL(String storePath)
Given a store file path, this will verify that the store actually exists.
|
public static final String DEFAULT_SSL_PROTOCOL
public static final String SSL_USE_CLIENT_MODE
public static final String SERVER_SSL_USE_CLIENT_MODE
public static final String SSL_SERVER_AUTH_MODE
public static final String KEY_PASSWORD
public static final String STANDARD_KEY_STORE_FILE_PATH
public static final String STANDARD_KEY_STORE_TYPE
public static final String STANDARD_KEY_STORE_PASSWORD
public static final String DEFAULT_KEY_STORE_TYPE
public static final String DEFAULT_KEY_STORE_ALGORITHM
public static final String STANDARD_TRUST_STORE_FILE_PATH
public static final String STANDARD_TRUST_STORE_TYPE
public static final String STANDARD_TRUST_STORE_PASSWORD
public SSLContextFactory()
SSLContextFactory
that does not have
any configuration so it falls back to all defaults.public SSLContextFactory(Map<String,Object> config)
SSLContextFactory
that allows the caller to
override the default settings for the various SSL configuration
properties.config
- configuration with properties defining things like where the
keystore and truststore files are, their types, etc.public SSLContext getSSLContext() throws IOException
IOException
public SSLContext getServerSSLContext() throws IOException
IOException
public String getSecureSocketProtocol()
org.jboss.remoting.security.SSLSocketBuilderMBean#getSecureSocketProtocol()
public void setSecureSocketProtocol(String protocol)
org.jboss.remoting.security.SSLSocketBuilderMBean#setSecureSocketProtocol(String)
public Provider getProvider()
org.jboss.remoting.security.SSLSocketBuilderMBean#getProvider()
public void setProvider(Provider provider)
org.jboss.remoting.security.SSLSocketBuilderMBean#setProvider(java.security.Provider)
public String getProviderName()
org.jboss.remoting.security.SSLSocketBuilderMBean#getProviderName()
public void setProviderName(String providerName)
org.jboss.remoting.security.SSLSocketBuilderMBean#setProviderName(java.lang.String)
public SecureRandom getSecureRandom()
org.jboss.remoting.security.SSLSocketBuilderMBean#getSecureRandom()
public void setSecureRandom(SecureRandom secureRandom)
org.jboss.remoting.security.SSLSocketBuilderMBean#setSecureRandom(java.security.SecureRandom)
public String getKeyStoreURL()
org.jboss.remoting.security.SSLSocketBuilderMBean#getKeyStoreURL()
public URL getKeyStore()
org.jboss.remoting.security.SSLSocketBuilderMBean#getKeyStore()
public void setKeyStoreURL(String keyStoreFilePath)
org.jboss.remoting.security.SSLSocketBuilderMBean#setKeyStoreURL(java.lang.String)
public void setKeyStore(URL keyStore)
org.jboss.remoting.security.SSLSocketBuilderMBean#setKeyStore(java.net.URL)
public String getKeyStoreType()
org.jboss.remoting.security.SSLSocketBuilderMBean#getKeyStoreType()
public void setKeyStoreType(String keyStoreType)
org.jboss.remoting.security.SSLSocketBuilderMBean#setKeyStoreType(java.lang.String)
public String getKeyStoreAlgorithm()
org.jboss.remoting.security.SSLSocketBuilderMBean#getKeyStoreAlgorithm()
public void setKeyStoreAlgorithm(String algorithm)
org.jboss.remoting.security.SSLSocketBuilderMBean#setKeyStoreAlgorithm(java.lang.String)
public String getKeyStorePassword()
public void setKeyStorePassword(String keyStorePassword)
org.jboss.remoting.security.SSLSocketBuilderMBean#setKeyStorePassword(java.lang.String)
public String getTrustStoreURL()
org.jboss.remoting.security.SSLSocketBuilderMBean#getTrustStoreURL()
public URL getTrustStore()
org.jboss.remoting.security.SSLSocketBuilderMBean#getTrustStore()
public void setTrustStore(URL trustStore)
org.jboss.remoting.security.SSLSocketBuilderMBean#setTrustStore(java.net.URL)
public void setTrustStoreURL(String trustStoreFilePath)
org.jboss.remoting.security.SSLSocketBuilderMBean#setTrustStoreURL(java.lang.String)
public String getTrustStoreType()
org.jboss.remoting.security.SSLSocketBuilderMBean#getTrustStoreType()
public void setTrustStoreType(String trustStoreType)
org.jboss.remoting.security.SSLSocketBuilderMBean#setTrustStoreType(java.lang.String)
public String getTrustStoreAlgorithm()
org.jboss.remoting.security.SSLSocketBuilderMBean#getTrustStoreAlgorithm()
public void setTrustStoreAlgorithm(String algorithm)
org.jboss.remoting.security.SSLSocketBuilderMBean#setTrustStoreAlgorithm(java.lang.String)
public String getTrustStorePassword()
public void setTrustStorePassword(String trustStorePassword)
org.jboss.remoting.security.SSLSocketBuilderMBean#setTrustStorePassword(java.lang.String)
public String getKeyAlias()
org.jboss.remoting.security.SSLSocketBuilderMBean#getKeyAlias()
public void setKeyAlias(String alias)
org.jboss.remoting.security.SSLSocketBuilderMBean#setKeyAlias(java.lang.String)
public String getKeyPassword()
null
but
when this value is needed by this class, the value for the key store
password will be used instead.public void setKeyPassword(String keyPassword)
org.jboss.remoting.security.SSLSocketBuilderMBean#setKeyPassword(java.lang.String)
public boolean isSocketUseClientMode()
org.jboss.remoting.security.SSLSocketBuilderMBean#isSocketUseClientMode()
public boolean isServerSocketUseClientMode()
org.jboss.remoting.security.SSLSocketBuilderMBean#isServerSocketUseClientMode()
public void setSocketUseClientMode(boolean useClientMode)
org.jboss.remoting.security.SSLSocketBuilderMBean#setSocketUseClientMode(boolean)
public void setServerSocketUseClientMode(boolean useClientMode)
org.jboss.remoting.security.SSLSocketBuilderMBean#setServerSocketUseClientMode(boolean)
public boolean isServerAuthMode()
org.jboss.remoting.security.SSLSocketBuilderMBean#isServerAuthMode()
public void setServerAuthMode(boolean mode)
org.jboss.remoting.security.SSLSocketBuilderMBean#setServerAuthMode(boolean)
protected void createServerSocketFactorySSLContext() throws IOException
initializeServerSocketFactorySSLContext()
if you want
to create and initialize in one method call.
If the server socket factory SSL context was already created, this will create
a new one and remove the old one.IOException
protected void createSocketFactorySSLContext() throws IOException
initializeSocketFactorySSLContext()
if you want
to create and initialize in one method call.
If the socket factory SSL context was already created, this will create
a new one and remove the old one.IOException
protected void initializeServerSocketFactorySSLContext() throws IOException
IOException
protected void initializeSocketFactorySSLContext() throws IOException
IOException
protected TrustManager[] loadTrustManagers(boolean isClientMode) throws NoSuchProviderException, NoSuchAlgorithmException, IOException, CertificateException, KeyStoreException, SSLContextFactory.NullStoreURLException
NoSuchProviderException
NoSuchAlgorithmException
IOException
CertificateException
KeyStoreException
SSLContextFactory.NullStoreURLException
protected KeyManager[] loadKeyManagers() throws NoSuchProviderException, NoSuchAlgorithmException, IOException, CertificateException, KeyStoreException, UnrecoverableKeyException, SSLContextFactory.NullStoreURLException
NoSuchProviderException
NoSuchAlgorithmException
IOException
CertificateException
KeyStoreException
UnrecoverableKeyException
SSLContextFactory.NullStoreURLException
protected KeyStore loadKeyStore(String storeType, URL storePathURL, String storePassword) throws KeyStoreException, NoSuchProviderException, IOException, NoSuchAlgorithmException, CertificateException, SSLContextFactory.NullStoreURLException
storeType
- the type of store filestorePathURL
- the URL to the file - may be relative to the current thread's classloader
or may be absolute path to a file on the file system.storePassword
- password to gain access to the store fileKeyStoreException
NoSuchProviderException
IOException
NoSuchAlgorithmException
CertificateException
SSLContextFactory.NullStoreURLException
protected URL validateStoreURL(String storePath) throws IOException
storePath
- the path which can be a URL, path to a resource in classloader
or a file path on the file system.IOException
- if the store could not be foundCopyright © 2012 JBoss, by Red Hat. All Rights Reserved.