Class ConnectionWrapper

  • All Implemented Interfaces:
    Closeable, AutoCloseable

    public class ConnectionWrapper
    extends Object
    implements Closeable
    Wraps a connection to a directory, either relying on JNDI or relying on OpenDJ Connection.

    You can either:

    • call getLdapContext() method to obtain an InitialLdapContext for JNDI.
    • or call the getConnection() method to obtain a Connection object.
    • Constructor Detail

      • ConnectionWrapper

        public ConnectionWrapper​(HostPort hostPort,
                                 PreferredConnection.Type connectionType,
                                 DN bindDn,
                                 String bindPwd,
                                 int connectTimeout,
                                 TrustManager trustManager)
                          throws LdapException
        Creates a connection wrapper.
        Parameters:
        hostPort - the host name and port number to connect to
        connectionType - the type of connection (LDAP, LDAPS, START_TLS)
        bindDn - the bind DN
        bindPwd - the bind password
        connectTimeout - connect timeout to use for the connection
        trustManager - trust manager to use for a secure connection
        Throws:
        LdapException - If an error occurs
      • ConnectionWrapper

        public ConnectionWrapper​(HostPort hostPort,
                                 PreferredConnection.Type connectionType,
                                 DN bindDn,
                                 String bindPwd,
                                 int connectTimeout,
                                 TrustManager trustManager,
                                 KeyManager keyManager)
                          throws LdapException
        Creates a connection wrapper.
        Parameters:
        hostPort - the host name and port number to connect to
        connectionType - the type of connection (LDAP, LDAPS, START_TLS)
        bindDn - the bind DN
        bindPwd - the bind password
        connectTimeout - connect timeout to use for the connection
        trustManager - trust manager to use for a secure connection
        keyManager - key manager to use for a secure connection
        Throws:
        LdapException - If an error occurs
    • Method Detail

      • getBindDn

        public DN getBindDn()
        Returns the bind DN used by this connection.
        Returns:
        the bind DN used by this connection.
      • getBindPassword

        public String getBindPassword()
        Returns the bind password used by this connection.
        Returns:
        the bind password used by this connection.
      • getLdapUrl

        public String getLdapUrl()
        Returns the LDAP URL used by this connection.
        Returns:
        the LDAP URL used by this connection.
      • isLdaps

        public boolean isLdaps()
        Returns whether this connection uses LDAPS.
        Returns:
        true if this connection uses LDAPS, false otherwise.
      • isStartTls

        public boolean isStartTls()
        Returns whether this connection uses StartTLS.
        Returns:
        true if this connection uses StartTLS, false otherwise.
      • getConnection

        public Connection getConnection()
        Returns the connection.
        Returns:
        the connection
      • getConnectionType

        public PreferredConnection.Type getConnectionType()
        Returns the connection type used by this connection wrapper.
        Returns:
        the connection type used by this connection wrapper
      • getHostPort

        public HostPort getHostPort()
        Returns the host name and port number of this connection.
        Returns:
        the hostPort of this connection
      • getRootConfiguration

        public RootCfgClient getRootConfiguration()
        Returns the root configuration client by using the inrnal Connection.
        Returns:
        the root configuration client