org.springframework.ldap.core
Class LdapEncoder

java.lang.Object
  extended by org.springframework.ldap.core.LdapEncoder

public class LdapEncoder
extends java.lang.Object

Helper class to encode and decode ldap names and values.

Author:
Adam Skogman, Mattias Arthursson

Method Summary
static java.lang.String filterEncode(java.lang.String value)
          Escape a value for use in a filter.
static java.lang.String nameDecode(java.lang.String value)
          Decodes a value.
static java.lang.String nameEncode(java.lang.String value)
          LDAP Encodes a value for use with a DN.
protected static java.lang.String toTwoCharHex(char c)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

toTwoCharHex

protected static java.lang.String toTwoCharHex(char c)

filterEncode

public static java.lang.String filterEncode(java.lang.String value)
Escape a value for use in a filter.

Parameters:
value - the value to escape.
Returns:
a properly escaped representation of the supplied value.

nameEncode

public static java.lang.String nameEncode(java.lang.String value)
LDAP Encodes a value for use with a DN. Escapes for LDAP, not JNDI!
Escapes:
' ' [space] - "\ " [if first or last]
'#' [hash] - "\#"
',' [comma] - "\,"
';' [semicolon] - "\;"
'= [equals] - "\="
'+' [plus] - "\+"
'<' [less than] - "\<"
'>' [greater than] - "\>"
'"' [double quote] - "\""
'\' [backslash] - "\\"

Parameters:
value - the value to escape.
Returns:
The escaped value.

nameDecode

public static java.lang.String nameDecode(java.lang.String value)
                                   throws BadLdapGrammarException
Decodes a value. Converts escaped chars to ordinary chars.

Parameters:
value - Trimmed value, so no leading an trailing blanks, except an escaped space last.
Returns:
The decoded value as a string.
Throws:
BadLdapGrammarException


Copyright � 2002-2006. All Rights Reserved.