Package org.ldaptive.ssl
Class KeyStoreSSLContextInitializer
- java.lang.Object
-
- org.ldaptive.ssl.AbstractSSLContextInitializer
-
- org.ldaptive.ssl.KeyStoreSSLContextInitializer
-
- All Implemented Interfaces:
SSLContextInitializer
public class KeyStoreSSLContextInitializer extends AbstractSSLContextInitializer
Provides an SSL context initializer which can use java KeyStores to create key and trust managers.- Author:
- Middleware Services
-
-
Field Summary
-
Fields inherited from class org.ldaptive.ssl.AbstractSSLContextInitializer
logger, trustManagers
-
-
Constructor Summary
Constructors Constructor Description KeyStoreSSLContextInitializer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected javax.net.ssl.TrustManager[]
createTrustManagers()
Creates any trust managers specific to this context initializer.java.lang.String[]
getAuthenticationAliases()
Returns the aliases of the entries to use in the authentication keystorejava.security.KeyStore
getAuthenticationKeystore()
Returns the keystore to use for creating the key managers.char[]
getAuthenticationPassword()
Returns the password used for accessing the authentication keystore.protected javax.net.ssl.KeyManagerFactory
getKeyManagerFactory(java.security.KeyStore keystore, char[] password, java.lang.String... aliases)
Creates a new key manager factory.javax.net.ssl.KeyManager[]
getKeyManagers()
Returns the key managers used when creating SSL contexts.java.lang.String[]
getTrustAliases()
Returns the aliases of the entries to use in the trust keystorejava.security.KeyStore
getTrustKeystore()
Returns the keystore to use for creating the trust managers.protected javax.net.ssl.TrustManagerFactory
getTrustManagerFactory(java.security.KeyStore keystore, java.lang.String... aliases)
Creates a new trust manager factory.void
setAuthenticationAliases(java.lang.String... aliases)
Sets the aliases of the entries to use in the authentication keystore.void
setAuthenticationKeystore(java.security.KeyStore keystore)
Sets the keystore to use for creating the key managers.void
setAuthenticationPassword(char[] password)
Sets the password used for accessing the authentication keystore.void
setTrustAliases(java.lang.String... aliases)
Sets the aliases of the entries to use in the trust keystore.void
setTrustKeystore(java.security.KeyStore keystore)
Sets the keystore to use for creating the trust managers.java.lang.String
toString()
-
Methods inherited from class org.ldaptive.ssl.AbstractSSLContextInitializer
aggregateTrustManagers, getTrustManagers, initSSLContext, setTrustManagers
-
-
-
-
Method Detail
-
getTrustKeystore
public java.security.KeyStore getTrustKeystore()
Returns the keystore to use for creating the trust managers.- Returns:
- keystore
-
setTrustKeystore
public void setTrustKeystore(java.security.KeyStore keystore)
Sets the keystore to use for creating the trust managers.- Parameters:
keystore
- to set
-
getTrustAliases
public java.lang.String[] getTrustAliases()
Returns the aliases of the entries to use in the trust keystore- Returns:
- trust aliases
-
setTrustAliases
public void setTrustAliases(java.lang.String... aliases)
Sets the aliases of the entries to use in the trust keystore.- Parameters:
aliases
- to use
-
getAuthenticationKeystore
public java.security.KeyStore getAuthenticationKeystore()
Returns the keystore to use for creating the key managers.- Returns:
- keystore
-
setAuthenticationKeystore
public void setAuthenticationKeystore(java.security.KeyStore keystore)
Sets the keystore to use for creating the key managers.- Parameters:
keystore
- to set
-
getAuthenticationAliases
public java.lang.String[] getAuthenticationAliases()
Returns the aliases of the entries to use in the authentication keystore- Returns:
- authentication aliases
-
setAuthenticationAliases
public void setAuthenticationAliases(java.lang.String... aliases)
Sets the aliases of the entries to use in the authentication keystore.- Parameters:
aliases
- to use
-
getAuthenticationPassword
public char[] getAuthenticationPassword()
Returns the password used for accessing the authentication keystore.- Returns:
- authentication password
-
setAuthenticationPassword
public void setAuthenticationPassword(char[] password)
Sets the password used for accessing the authentication keystore.- Parameters:
password
- to use for authentication
-
createTrustManagers
protected javax.net.ssl.TrustManager[] createTrustManagers() throws java.security.GeneralSecurityException
Description copied from class:AbstractSSLContextInitializer
Creates any trust managers specific to this context initializer.- Specified by:
createTrustManagers
in classAbstractSSLContextInitializer
- Returns:
- trust managers
- Throws:
java.security.GeneralSecurityException
- if an errors occurs while loading the TrustManagers
-
getTrustManagerFactory
protected javax.net.ssl.TrustManagerFactory getTrustManagerFactory(java.security.KeyStore keystore, java.lang.String... aliases) throws java.security.GeneralSecurityException
Creates a new trust manager factory.- Parameters:
keystore
- to initialize the trust manager factoryaliases
- to include from the supplied keystore or null to include all entries- Returns:
- trust manager factory
- Throws:
java.security.GeneralSecurityException
- if the trust manager factory cannot be initialized
-
getKeyManagers
public javax.net.ssl.KeyManager[] getKeyManagers() throws java.security.GeneralSecurityException
Description copied from interface:SSLContextInitializer
Returns the key managers used when creating SSL contexts.- Returns:
- key managers
- Throws:
java.security.GeneralSecurityException
- if an errors occurs while loading the KeyManagers
-
getKeyManagerFactory
protected javax.net.ssl.KeyManagerFactory getKeyManagerFactory(java.security.KeyStore keystore, char[] password, java.lang.String... aliases) throws java.security.GeneralSecurityException
Creates a new key manager factory.- Parameters:
keystore
- to initialize the key manager factorypassword
- to unlock the supplied keystorealiases
- to include from the supplied keystore or null to include all entries- Returns:
- key manager factory
- Throws:
java.security.GeneralSecurityException
- if the key manager factory cannot be initialized
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-