Package com.nimbusds.common.ldap
Class LDAPConnectionFactory
java.lang.Object
com.nimbusds.common.ldap.LDAPConnectionFactory
- Direct Known Subclasses:
PresetLDAPConnectionFactory
Factory for establishing LDAP connections to a directory server.
-
Constructor Summary
ConstructorsConstructorDescriptionLDAPConnectionFactory
(CustomTrustStoreConfiguration customTrustStore, CustomKeyStoreConfiguration customKeyStore) Creates a new LDAP connection factory. -
Method Summary
Modifier and TypeMethodDescriptioncom.unboundid.ldap.sdk.LDAPConnection
createLDAPConnection
(com.unboundid.ldap.sdk.ServerSet ldapServerSet, LDAPConnectionSecurity security, boolean trustSelfSignedCerts) Creates a new LDAP connection to the specified directory server set.com.unboundid.ldap.sdk.LDAPConnection
createLDAPConnection
(String host, int port, LDAPConnectionSecurity security, int timeout, boolean trustSelfSignedCerts) Creates a new LDAP connection to the specified directory server.Gets the custom key store configuration.Gets the custom trust store configuration.static SocketFactory
getSocketFactory
(LDAPConnectionSecurity security, CustomTrustStoreConfiguration customTrustStore, CustomKeyStoreConfiguration customKeyStore, boolean trustSelfSignedCerts) Creates a new socket factory according to the specified LDAP connection security settings.static com.unboundid.util.ssl.SSLUtil
initSecureConnectionContext
(CustomTrustStoreConfiguration customTrustStore, CustomKeyStoreConfiguration customKeyStore, boolean trustSelfSignedCerts) Initialises the context for a secure LDAP connection by creating the required TLS/SSL trust and key managers.
-
Constructor Details
-
LDAPConnectionFactory
public LDAPConnectionFactory(CustomTrustStoreConfiguration customTrustStore, CustomKeyStoreConfiguration customKeyStore) Creates a new LDAP connection factory.- Parameters:
customTrustStore
- The custom trust store configuration. Must not benull
.customKeyStore
- The custom key store configuration. Must not benull
.
-
-
Method Details
-
getCustomTrustStoreConfiguration
Gets the custom trust store configuration.- Returns:
- The custom trust store configuration.
-
getCustomKeyStoreConfiguration
Gets the custom key store configuration.- Returns:
- The custom key store configuration.
-
initSecureConnectionContext
public static com.unboundid.util.ssl.SSLUtil initSecureConnectionContext(CustomTrustStoreConfiguration customTrustStore, CustomKeyStoreConfiguration customKeyStore, boolean trustSelfSignedCerts) throws KeyStoreException Initialises the context for a secure LDAP connection by creating the required TLS/SSL trust and key managers.- Parameters:
customTrustStore
- The custom trust store configuration. Must not benull
.customKeyStore
- The custom key store configuration. Must not benull
.trustSelfSignedCerts
- The trust policy for self-signed X.509 certificates presented by the LDAP server.- Returns:
- A helper for creating the SSL context and sockets.
- Throws:
KeyStoreException
- On a client key store exception.
-
getSocketFactory
public static SocketFactory getSocketFactory(LDAPConnectionSecurity security, CustomTrustStoreConfiguration customTrustStore, CustomKeyStoreConfiguration customKeyStore, boolean trustSelfSignedCerts) throws LDAPConnectionException Creates a new socket factory according to the specified LDAP connection security settings.- Parameters:
security
- The requested LDAP connection security. Must not benull
.customTrustStore
- The custom trust store configuration. Must not benull
.customKeyStore
- The custom key store configuration. Must not benull
.trustSelfSignedCerts
- The trust policy for self-signed X.509 certificates presented by the LDAP server.- Returns:
- A configured SSL socket factory,
null
for a plain connection. - Throws:
LDAPConnectionException
- On a failure to create an SSL socket factory.
-
createLDAPConnection
public com.unboundid.ldap.sdk.LDAPConnection createLDAPConnection(String host, int port, LDAPConnectionSecurity security, int timeout, boolean trustSelfSignedCerts) throws LDAPConnectionException Creates a new LDAP connection to the specified directory server.- Parameters:
host
- The LDAP server host name / IP address. Must not benull
.port
- The LDAP server port.security
- The LDAP connection security. Must not benull
.timeout
- The timeout in milliseconds for LDAP connect requests. If zero the underlying LDAP client library will determine this value.trustSelfSignedCerts
- The trust policy for self-signed X.509 certificates presented by the LDAP server.- Returns:
- A new established unauthenticated LDAP connection ready for use.
- Throws:
LDAPConnectionException
- If a new LDAP connection could not be created.
-
createLDAPConnection
public com.unboundid.ldap.sdk.LDAPConnection createLDAPConnection(com.unboundid.ldap.sdk.ServerSet ldapServerSet, LDAPConnectionSecurity security, boolean trustSelfSignedCerts) throws LDAPConnectionException Creates a new LDAP connection to the specified directory server set.- Parameters:
ldapServerSet
- The LDAP server set. Must not benull
.security
- The LDAP connection security. Must not benull
.trustSelfSignedCerts
- The trust policy for self-signed X.509 certificates presented by the LDAP server.- Returns:
- A new established unauthenticated LDAP connection ready for use.
- Throws:
LDAPConnectionException
- If a new LDAP connection could not be created.
-