public class LDAPSConfig
extends java.lang.Object
LDAPSTrustManager for the default EntrustSSLSocketFactory.
If a custom SSLSocketFactory has been specified, these certificates
will not be used.
Note:The certificates are stored in a static memory cache.
This means every certificate added or removed through this class
will be added/removed for every subsequent LDAPS connection
made with a JNDIDirectory instance.
User user = new User();
X509Certificate[] certificates = {new X509Certificate(new FileInputStream(trustedcert))};
JNDIDirectory directory = new JNDIDirectory(myldapshost.com,636);
LDAPSConfig config = new LDAPSConfig(true);
config.setTrustCerts(certificates);
Directory.setLDAPSConfig (config);
user.setConnections(directory, null);
.
.
user.login(CredentialReader,SecureStringBuffer);
Note: It is possible to have SSL Disabled for this directory, but still
allow LDAPS Referrals. In this case the LDAPSConfig may be configured with the
trusted certificates of any directory which may be referred. If a referred directory
using LDAPS is attached to the JNDIDirectory object then the trusted certificates
required for LDAPS to succeeded will already be configured. However, if
AllowLDAPSReferral is set to false, LDAPS will not be attempted for any referrals.| Constructor and Description |
|---|
LDAPSConfig()
The default constructor.
|
LDAPSConfig(boolean enabled)
Constructor which allows SSL to be enabled or disabled for this directory.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addTrustCerts(java.security.cert.X509Certificate[] trustcerts)
Adds the X509Certificates that are trusted for this SSL
configuration.
|
boolean |
getAllowLDAPSReferrals() |
JNDIDirectory |
getJNDIDirectory() |
boolean |
getSSLEnabled() |
java.lang.String |
getSSLSocketFactory() |
java.security.cert.X509Certificate[] |
getTrustCerts()
Return the array of certificates that were added for this
instance of LDAPSConfig.
|
LDAPSTrustStoreSingleton |
getTrustStoreSingleton()
Return the
LDAPSTrustStoreSingleton object that contains the
list of all certificates that will be used by
the EntrustSSLSocketFactory. |
void |
removeTrustCert(java.security.cert.X509Certificate trustcert)
Removes an X509Certificate from the list of trusted
certificates.
|
void |
setAllowLDAPSReferrals(boolean referrals)
Set whether LDAPS referrals should be used.
|
void |
setSSLEnabled(boolean SSL)
Sets whether SSL should be enabled.
|
void |
setSSLSocketFactory(java.lang.String SocketFactoryName)
Sets the name of a custom SSLSocketfactory that will be used to
create the SSLSocket of LDAP.
|
public LDAPSConfig()
public LDAPSConfig(boolean enabled)
enabled - sets whether SSL is enabled or disabled.public void setSSLEnabled(boolean SSL)
SSL - true indicates SSL enabled, false SSL disabledpublic boolean getSSLEnabled()
public void addTrustCerts(java.security.cert.X509Certificate[] trustcerts)
Note: Because JNDI creates an instance of an SSLSocketFactory
using the static getDefault() method, all trusted certificates
must be available from a static location. This method places
the certificates in LDAPSTrustStoreSingleton (as well as a local
instance). This means every certificate added through this method
will be trusted for every subsequent LDAPS connection
made with a JNDIDirectory instance.
trustcerts - LDAPSTrustStoreSingletonpublic void removeTrustCert(java.security.cert.X509Certificate trustcert)
Note: Because JNDI creates an instance of an SSLSocketFactory
using the static getDefault() method, all trusted certificates
must be available from a static location. This method removes
the certificate from LDAPSTrustStoreSingleton (as well as a local
instance). This means every certificate removed through this method
will be removed for every existing LDAPS connection
made with a JNDIDirectory instance.
trustcert - the trusted certificate that should be removedpublic java.security.cert.X509Certificate[] getTrustCerts()
X509Certificate. This method
will never return null.public LDAPSTrustStoreSingleton getTrustStoreSingleton()
LDAPSTrustStoreSingleton object that contains the
list of all certificates that will be used by
the EntrustSSLSocketFactory. When a trust cert is
added or removed using addTrustCerts(X509Certificate[])
or removeTrustCert(X509Certificate), it is automatically
added or removed from the LDAPSTrustStoreSingleton as well.
This method is provided to allow precise control over the Trusted certificates which are used to setup the SSLConection.
Note: The LDAPSTrustStoreSingleton can be returned from any context by calling:
LDAPSTrustStoreSingleton.getLDAPSTrustStoreSingleton();
public JNDIDirectory getJNDIDirectory()
public void setAllowLDAPSReferrals(boolean referrals)
referrals - true indicates LDAPS referrals allowed,
false indicates they are not allowed.public boolean getAllowLDAPSReferrals()
public void setSSLSocketFactory(java.lang.String SocketFactoryName)
throws java.lang.ClassNotFoundException
Note: The static SSLSocketFactory.getDefault() method will be used to create the socket, so any data such as certificates or keys used to initialize the SSLContext must be referenced from a static context.
String - SocketFactoryName the fully qualifiedjava.lang.ClassNotFoundExceptionpublic java.lang.String getSSLSocketFactory()