Class LDAPConnectionFactory

java.lang.Object
com.nimbusds.common.ldap.LDAPConnectionFactory
Direct Known Subclasses:
PresetLDAPConnectionFactory

public class LDAPConnectionFactory extends Object
Factory for establishing LDAP connections to a directory server.
  • Constructor Details

  • 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 be null.
      customKeyStore - The custom key store configuration. Must not be null.
      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 be null.
      customTrustStore - The custom trust store configuration. Must not be null.
      customKeyStore - The custom key store configuration. Must not be null.
      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 be null.
      port - The LDAP server port.
      security - The LDAP connection security. Must not be null.
      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 be null.
      security - The LDAP connection security. Must not be null.
      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.