org.springframework.ldap.support
Class LdapEncoder

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

public class LdapEncoder
extends java.lang.Object

Helper class to encode and decode ldap names and values.

Author:
Adam Skogman

Method Summary
static java.lang.String filterEncode(java.lang.String value)
           
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)

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 -
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.