Package org.opends.admin.ads.util
Class ConnectionWrapper
- java.lang.Object
-
- org.opends.admin.ads.util.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 anInitialLdapContextfor JNDI. - or call the
getConnection()method to obtain aConnectionobject.
-
-
Constructor Summary
Constructors Constructor Description ConnectionWrapper(ConnectionWrapper other)Creates a connection wrapper by copying the provided one.ConnectionWrapper(HostPort hostPort, PreferredConnection.Type connectionType, DN bindDn, String bindPwd, int connectTimeout, TrustManager trustManager)Creates a connection wrapper.ConnectionWrapper(HostPort hostPort, PreferredConnection.Type connectionType, DN bindDn, String bindPwd, int connectTimeout, TrustManager trustManager, KeyManager keyManager)Creates a connection wrapper.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()DNgetBindDn()Returns the bind DN used by this connection.StringgetBindPassword()Returns the bind password used by this connection.ConnectiongetConnection()Returns the connection.PreferredConnection.TypegetConnectionType()Returns the connection type used by this connection wrapper.HostPortgetHostPort()Returns the host name and port number of this connection.StringgetLdapUrl()Returns the LDAP URL used by this connection.RootCfgClientgetRootConfiguration()Returns the root configuration client by using the inrnal Connection.booleanisLdaps()Returns whether this connection uses LDAPS.booleanisStartTls()Returns whether this connection uses StartTLS.StringtoString()
-
-
-
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 toconnectionType- the type of connection (LDAP, LDAPS, START_TLS)bindDn- the bind DNbindPwd- the bind passwordconnectTimeout- connect timeout to use for the connectiontrustManager- trust manager to use for a secure connection- Throws:
LdapException- If an error occurs
-
ConnectionWrapper
public ConnectionWrapper(ConnectionWrapper other) throws LdapException
Creates a connection wrapper by copying the provided one.- Parameters:
other- theConnectionWrapperto copy- 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 toconnectionType- the type of connection (LDAP, LDAPS, START_TLS)bindDn- the bind DNbindPwd- the bind passwordconnectTimeout- connect timeout to use for the connectiontrustManager- trust manager to use for a secure connectionkeyManager- 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:
trueif this connection uses LDAPS,falseotherwise.
-
isStartTls
public boolean isStartTls()
Returns whether this connection uses StartTLS.- Returns:
trueif this connection uses StartTLS,falseotherwise.
-
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
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
-