Package org.ldaptive.ssl
Class X509SSLContextInitializer
- java.lang.Object
-
- org.ldaptive.ssl.AbstractSSLContextInitializer
-
- org.ldaptive.ssl.X509SSLContextInitializer
-
- All Implemented Interfaces:
SSLContextInitializer
public class X509SSLContextInitializer extends AbstractSSLContextInitializer
Provides an SSL context initializer which can use X.509 certificates 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 X509SSLContextInitializer()
-
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.security.cert.X509Certificate
getAuthenticationCertificate()
Returns the certificate to use for creating the key managers.java.security.PrivateKey
getAuthenticationKey()
Returns the private key associated with the authentication certificate.protected javax.net.ssl.KeyManagerFactory
getKeyManagerFactory(java.security.cert.X509Certificate cert, java.security.PrivateKey key)
Creates a new key manager factory.javax.net.ssl.KeyManager[]
getKeyManagers()
Returns the key managers used when creating SSL contexts.java.security.cert.X509Certificate[]
getTrustCertificates()
Returns the certificates to use for creating the trust managers.protected javax.net.ssl.TrustManagerFactory
getTrustManagerFactory(java.security.cert.X509Certificate[] certs)
Creates a new trust manager factory.void
setAuthenticationCertificate(java.security.cert.X509Certificate cert)
Sets the certificate to use for creating the key managers.void
setAuthenticationKey(java.security.PrivateKey key)
Sets the private key associated with the authentication certificate.void
setTrustCertificates(java.security.cert.X509Certificate... certs)
Sets the certificates 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
-
getTrustCertificates
public java.security.cert.X509Certificate[] getTrustCertificates()
Returns the certificates to use for creating the trust managers.- Returns:
- X.509 certificates
-
setTrustCertificates
public void setTrustCertificates(java.security.cert.X509Certificate... certs)
Sets the certificates to use for creating the trust managers.- Parameters:
certs
- X.509 certificates
-
getAuthenticationCertificate
public java.security.cert.X509Certificate getAuthenticationCertificate()
Returns the certificate to use for creating the key managers.- Returns:
- X.509 certificate
-
setAuthenticationCertificate
public void setAuthenticationCertificate(java.security.cert.X509Certificate cert)
Sets the certificate to use for creating the key managers.- Parameters:
cert
- X.509 certificate
-
getAuthenticationKey
public java.security.PrivateKey getAuthenticationKey()
Returns the private key associated with the authentication certificate.- Returns:
- private key
-
setAuthenticationKey
public void setAuthenticationKey(java.security.PrivateKey key)
Sets the private key associated with the authentication certificate.- Parameters:
key
- private key
-
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.cert.X509Certificate[] certs) throws java.security.GeneralSecurityException
Creates a new trust manager factory.- Parameters:
certs
- to add as trusted material- 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.cert.X509Certificate cert, java.security.PrivateKey key) throws java.security.GeneralSecurityException
Creates a new key manager factory.- Parameters:
cert
- to initialize the key manager factorykey
- to initialize the key manager factory- 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
-
-