Spring LDAP Framework

org.springframework.ldap.support
Class LdapUtils

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

public final class LdapUtils
extends Object

Generic utility methods for working with LDAP. Mainly for internal use within the framework, but also useful for custom code.

Since:
1.2
Author:
Ulrik Sandberg

Method Summary
static void closeContext(DirContext context)
          Close the given JNDI Context and ignore any thrown exception.
static void collectAttributeValues(Attributes attributes, String name, Collection collection)
          Collect all the values of a the specified attribute from the supplied Attributes.
static String convertCompositeNameToString(CompositeName compositeName)
          Converts a CompositeName to a String in a way that avoids escaping problems, such as the dreaded "triple backslash" problem.
static NamingException convertLdapException(NamingException ex)
          Convert the specified checked NamingException to a Spring LDAP runtime NamingException equivalent.
static Class getActualTargetClass(DirContext context)
          Get the actual class of the supplied DirContext instance; LdapContext or DirContext.
static void iterateAttributeValues(Attribute attribute, AttributeValueCallbackHandler callbackHandler)
          Iterate through all the values of the specified Attribute calling back to the specified callbackHandler.
 
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(DirContext context)
Close the given JNDI Context and ignore any thrown exception. This is useful for typical finally blocks in JNDI code.

Parameters:
context - the JNDI Context to close (may be null)

convertLdapException

public static NamingException convertLdapException(NamingException ex)
Convert the specified checked NamingException to a Spring LDAP runtime NamingException equivalent.

Parameters:
ex - the original checked NamingException to convert
Returns:
the Spring LDAP runtime NamingException wrapping the given exception

getActualTargetClass

public static Class getActualTargetClass(DirContext context)
Get the actual class of the supplied DirContext instance; LdapContext or DirContext.

Parameters:
context - the DirContext instance to check.
Returns:
LdapContext.class if context is an LdapContext, DirContext.class otherwise.

collectAttributeValues

public static void collectAttributeValues(Attributes attributes,
                                          String name,
                                          Collection collection)
Collect all the values of a the specified attribute from the supplied Attributes.

Parameters:
attributes - The Attributes; not null.
name - The name of the Attribute to get values for.
collection - the collection to collect the values in.
Throws:
NoSuchAttributeException - if no attribute with the specified name exists.
Since:
1.3

iterateAttributeValues

public static void iterateAttributeValues(Attribute attribute,
                                          AttributeValueCallbackHandler callbackHandler)
Iterate through all the values of the specified Attribute calling back to the specified callbackHandler.

Parameters:
attribute - the Attribute to work with; not null.
callbackHandler - the callbackHandler; not null.
Since:
1.3

convertCompositeNameToString

public static String convertCompositeNameToString(CompositeName compositeName)
Converts a CompositeName to a String in a way that avoids escaping problems, such as the dreaded "triple backslash" problem.

Parameters:
compositeName - The CompositeName to convert
Returns:
String containing the String representation of name

Spring LDAP Framework

Copyright © 2006-2009 The Spring LDAP Framework. All Rights Reserved.