|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.opends.admin.ads.util.ConnectionUtils
public class ConnectionUtils
Class providing some utilities to create LDAP connections using JNDI and to manage entries retrieved using JNDI.
| Method Summary | |
|---|---|
static boolean |
canConnectAsAdministrativeUser(java.lang.String ldapUrl,
java.lang.String dn,
java.lang.String pwd)
Method used to know if we can connect as administrator in a server with a given password and dn. |
static boolean |
connectedAsAdministrativeUser(javax.naming.ldap.InitialLdapContext ctx)
Method used to know if we are connected as administrator in a server with a given InitialLdapContext. |
static javax.naming.ldap.InitialLdapContext |
createLdapContext(java.lang.String ldapURL,
java.lang.String dn,
java.lang.String pwd,
int timeout,
java.util.Hashtable<java.lang.String,java.lang.String> env)
Creates a clear LDAP connection and returns the corresponding LdapContext. |
static javax.naming.ldap.InitialLdapContext |
createLdapsContext(java.lang.String ldapsURL,
java.lang.String dn,
java.lang.String pwd,
int timeout,
java.util.Hashtable<java.lang.String,java.lang.String> env,
javax.net.ssl.TrustManager trustManager,
javax.net.ssl.KeyManager keyManager)
Creates an LDAPS connection and returns the corresponding LdapContext. |
static javax.naming.ldap.InitialLdapContext |
createStartTLSContext(java.lang.String ldapURL,
java.lang.String dn,
java.lang.String pwd,
int timeout,
java.util.Hashtable<java.lang.String,java.lang.String> env,
javax.net.ssl.TrustManager trustManager,
javax.net.ssl.KeyManager keyManager,
javax.net.ssl.HostnameVerifier verifier)
Creates an LDAP+StartTLS connection and returns the corresponding LdapContext. |
static java.lang.String |
getBindDN(javax.naming.ldap.InitialLdapContext ctx)
Returns the bind DN used in the provided InitialLdapContext. |
static java.lang.String |
getBindPassword(javax.naming.ldap.InitialLdapContext ctx)
Returns the password used in the provided InitialLdapContext. |
static int |
getDefaultLDAPTimeout()
Returns the default LDAP timeout in milliseconds when we try to connect to a server. |
static java.lang.String |
getFirstValue(javax.naming.directory.SearchResult entry,
java.lang.String attrName)
Returns the String representation of the first value of an attribute in a LDAP entry. |
static java.lang.String |
getHostName(javax.naming.ldap.InitialLdapContext ctx)
Returns the host name used in the provided InitialLdapContext. |
static java.lang.String |
getHostNameForLdapUrl(java.lang.String host)
Returns the String that can be used to represent a given host name in a LDAP URL. |
static java.lang.String |
getHostPort(javax.naming.ldap.InitialLdapContext ctx)
Returns the host port representation of the server to which this context is connected. |
static java.lang.String |
getLdapUrl(javax.naming.ldap.InitialLdapContext ctx)
Returns the LDAP URL used in the provided InitialLdapContext. |
static java.lang.String |
getLDAPUrl(java.lang.String host,
int port,
boolean useSSL)
Returns the LDAP URL for the provided parameters. |
static int |
getPort(javax.naming.ldap.InitialLdapContext ctx)
Returns the port number used in the provided InitialLdapContext. |
static java.util.Set<java.lang.String> |
getValues(javax.naming.directory.SearchResult entry,
java.lang.String attrName)
Returns a Set with the String representation of the values of an attribute in a LDAP entry. |
static boolean |
isCertificateException(java.lang.Throwable t)
Tells whether the provided Throwable was caused because of a problem with a certificate while trying to establish a connection. |
static boolean |
isSSL(javax.naming.ldap.InitialLdapContext ctx)
Tells whether we are using SSL in the provided InitialLdapContext. |
static boolean |
isStartTLS(javax.naming.ldap.InitialLdapContext ctx)
Tells whether we are using StartTLS in the provided InitialLdapContext. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static javax.naming.ldap.InitialLdapContext createLdapContext(java.lang.String ldapURL,
java.lang.String dn,
java.lang.String pwd,
int timeout,
java.util.Hashtable<java.lang.String,java.lang.String> env)
throws javax.naming.NamingException
ldapURL - the target LDAP URLdn - passed as Context.SECURITY_PRINCIPAL if not nullpwd - passed as Context.SECURITY_CREDENTIALS if not nulltimeout - passed as com.sun.jndi.ldap.connect.timeout if > 0env - null or additional environment properties
javax.naming.NamingException - the exception thrown when instantiating InitialLdapContextContext,
InitialLdapContext
public static javax.naming.ldap.InitialLdapContext createLdapsContext(java.lang.String ldapsURL,
java.lang.String dn,
java.lang.String pwd,
int timeout,
java.util.Hashtable<java.lang.String,java.lang.String> env,
javax.net.ssl.TrustManager trustManager,
javax.net.ssl.KeyManager keyManager)
throws javax.naming.NamingException
ldapsURL - the target *LDAPS* URL.dn - passed as Context.SECURITY_PRINCIPAL if not null.pwd - passed as Context.SECURITY_CREDENTIALS if not null.timeout - passed as com.sun.jndi.ldap.connect.timeout if > 0.env - null or additional environment properties.trustManager - null or the trust manager to be invoked during SSL
negociation.keyManager - null or the key manager to be invoked during SSL
negociation.
javax.naming.NamingException - the exception thrown when instantiating
InitialLdapContext.Context,
InitialLdapContext,
TrustedSocketFactory
public static javax.naming.ldap.InitialLdapContext createStartTLSContext(java.lang.String ldapURL,
java.lang.String dn,
java.lang.String pwd,
int timeout,
java.util.Hashtable<java.lang.String,java.lang.String> env,
javax.net.ssl.TrustManager trustManager,
javax.net.ssl.KeyManager keyManager,
javax.net.ssl.HostnameVerifier verifier)
throws javax.naming.NamingException
ldapURL - the target *LDAP* URL.dn - passed as Context.SECURITY_PRINCIPAL if not null.pwd - passed as Context.SECURITY_CREDENTIALS if not null.timeout - passed as com.sun.jndi.ldap.connect.timeout if > 0.env - null or additional environment properties.trustManager - null or the trust manager to be invoked during SSL
negociation.keyManager - null or the key manager to be invoked during SSL
negociation.verifier - null or the hostname verifier to be setup in the
StartTlsResponse.
javax.naming.NamingException - the exception thrown when instantiating
InitialLdapContext.Context,
InitialLdapContext,
StartTlsRequest,
StartTlsResponse,
TrustedSocketFactorypublic static java.lang.String getLdapUrl(javax.naming.ldap.InitialLdapContext ctx)
ctx - the context to analyze.
public static java.lang.String getHostName(javax.naming.ldap.InitialLdapContext ctx)
ctx - the context to analyze.
public static int getPort(javax.naming.ldap.InitialLdapContext ctx)
ctx - the context to analyze.
public static java.lang.String getHostPort(javax.naming.ldap.InitialLdapContext ctx)
ctx - the context to analyze.
public static java.lang.String getBindDN(javax.naming.ldap.InitialLdapContext ctx)
ctx - the context to analyze.
public static java.lang.String getBindPassword(javax.naming.ldap.InitialLdapContext ctx)
ctx - the context to analyze.
public static boolean isSSL(javax.naming.ldap.InitialLdapContext ctx)
ctx - the context to analyze.
true if we are using SSL and false
otherwise.public static boolean isStartTLS(javax.naming.ldap.InitialLdapContext ctx)
ctx - the context to analyze.
true if we are using StartTLS and false
otherwise.
public static boolean canConnectAsAdministrativeUser(java.lang.String ldapUrl,
java.lang.String dn,
java.lang.String pwd)
ldapUrl - the ldap URL of the server.dn - the dn to be used.pwd - the password to be used.
true if we can connect and read the configuration and
false otherwise.public static boolean connectedAsAdministrativeUser(javax.naming.ldap.InitialLdapContext ctx)
ctx - the context.
true if we are connected and read the configuration
and false otherwise.public static int getDefaultLDAPTimeout()
public static java.lang.String getHostNameForLdapUrl(java.lang.String host)
host - the host name.
public static java.lang.String getLDAPUrl(java.lang.String host,
int port,
boolean useSSL)
host - the host name.port - the LDAP port.useSSL - whether to use SSL or not.
public static boolean isCertificateException(java.lang.Throwable t)
t - the Throwable to analyze.
true if the provided Throwable was caused because of a
problem with a certificate while trying to establish a connection and
false otherwise.
public static java.lang.String getFirstValue(javax.naming.directory.SearchResult entry,
java.lang.String attrName)
throws javax.naming.NamingException
entry - the entry.attrName - the attribute name.
javax.naming.NamingException - if there is an error processing the entry.
public static java.util.Set<java.lang.String> getValues(javax.naming.directory.SearchResult entry,
java.lang.String attrName)
throws javax.naming.NamingException
entry - the entry.attrName - the attribute name.
javax.naming.NamingException - if there is an error processing the entry.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||