org.springframework.security.ldap
Class LdapUtils

java.lang.Object
  extended by org.springframework.security.ldap.LdapUtils

public final class LdapUtils
extends java.lang.Object

LDAP Utility methods.


Method Summary
static void closeContext(javax.naming.Context ctx)
           
static void closeEnumeration(javax.naming.NamingEnumeration ne)
           
static java.lang.String convertPasswordToString(java.lang.Object passObj)
           
static org.springframework.ldap.core.DistinguishedName getFullDn(org.springframework.ldap.core.DistinguishedName dn, javax.naming.Context baseCtx)
          Gets the full dn of a name by prepending the name of the context it is relative to.
static java.lang.String getRelativeName(java.lang.String fullDn, javax.naming.Context baseCtx)
          Obtains the part of a DN relative to a supplied base context.
static byte[] getUtf8Bytes(java.lang.String s)
           
static java.lang.String getUtf8BytesAsString(byte[] utf8)
           
static java.lang.String parseRootDnFromUrl(java.lang.String url)
          Works out the root DN for an LDAP URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

closeContext

public static void closeContext(javax.naming.Context ctx)

closeEnumeration

public static void closeEnumeration(javax.naming.NamingEnumeration ne)

getRelativeName

public static java.lang.String getRelativeName(java.lang.String fullDn,
                                               javax.naming.Context baseCtx)
                                        throws javax.naming.NamingException
Obtains the part of a DN relative to a supplied base context.

If the DN is "cn=bob,ou=people,dc=springframework,dc=org" and the base context name is "ou=people,dc=springframework,dc=org" it would return "cn=bob".

Parameters:
fullDn - the DN
baseCtx - the context to work out the name relative to.
Returns:
the
Throws:
javax.naming.NamingException - any exceptions thrown by the context are propagated.

getFullDn

public static org.springframework.ldap.core.DistinguishedName getFullDn(org.springframework.ldap.core.DistinguishedName dn,
                                                                        javax.naming.Context baseCtx)
                                                                 throws javax.naming.NamingException
Gets the full dn of a name by prepending the name of the context it is relative to. If the name already contains the base name, it is returned unaltered.

Throws:
javax.naming.NamingException

getUtf8Bytes

public static byte[] getUtf8Bytes(java.lang.String s)

getUtf8BytesAsString

public static java.lang.String getUtf8BytesAsString(byte[] utf8)

convertPasswordToString

public static java.lang.String convertPasswordToString(java.lang.Object passObj)

parseRootDnFromUrl

public static java.lang.String parseRootDnFromUrl(java.lang.String url)
Works out the root DN for an LDAP URL.

For example, the URL ldap://monkeymachine:11389/dc=springframework,dc=org has the root DN "dc=springframework,dc=org".

Parameters:
url - the LDAP URL
Returns:
the root DN