org.pf.directory.ldap
Class LDAPUtil

java.lang.Object
  extended by org.pf.directory.ldap.LDAPUtil

public class LDAPUtil
extends java.lang.Object

Provides utility and convenience methods for LDAP directory data.

Version:
1.1
Author:
Manfred Duchrow

Field Summary
static java.lang.String DISTINGUISHED_NAME
          The distinguished name identifier (i.e.
static StringPattern ENCRYPTION_PATTERN
          The pattern that an encrypted string usually matches (e.g.
 
Method Summary
 java.lang.Object asEncryptedStringIfApplicable(java.lang.Object value)
          Returns the given value as a String if it is a byte array containing an encrypted string.
 java.lang.String createTimestamp()
          Creates an LDAP syntax compliant timestamp for the current date.
 java.lang.String createTimestamp(java.util.Date date)
          Creates an LDAP syntax compliant timestamp for the given date.
static LDAPUtil current()
          Returns the only instance this class supports (design pattern "Singleton")
 java.lang.String encodeToBase64(java.lang.Object obj)
          Encodes the given object to BASE64 encoding
 boolean needsEncoding(java.lang.Object value)
          Returns true if the given value must be BASE64 encoding if used in a contex with limited character representation.
 java.lang.String normalizeDN(java.lang.String dn)
          Removes all unnecessary spaces from the given DN.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DISTINGUISHED_NAME

public static final java.lang.String DISTINGUISHED_NAME
The distinguished name identifier (i.e. "dn")

See Also:
Constant Field Values

ENCRYPTION_PATTERN

public static final StringPattern ENCRYPTION_PATTERN
The pattern that an encrypted string usually matches (e.g. "{SHA}rFg5TesR3F==")

Method Detail

current

public static LDAPUtil current()
Returns the only instance this class supports (design pattern "Singleton")


normalizeDN

public java.lang.String normalizeDN(java.lang.String dn)
Removes all unnecessary spaces from the given DN.

Example:
normalizeDN( "cn= Peter Pan, ou=people, dcx = examples , dc=com " )
==> "cn=Peter Pan,ou=people,dcx=examples,dc=com"

Parameters:
dn - The dn to remove the spaces from

needsEncoding

public boolean needsEncoding(java.lang.Object value)
Returns true if the given value must be BASE64 encoding if used in a contex with limited character representation.


asEncryptedStringIfApplicable

public java.lang.Object asEncryptedStringIfApplicable(java.lang.Object value)
Returns the given value as a String if it is a byte array containing an encrypted string. Otherwise the value is returned unchanged.


encodeToBase64

public java.lang.String encodeToBase64(java.lang.Object obj)
Encodes the given object to BASE64 encoding


createTimestamp

public java.lang.String createTimestamp(java.util.Date date)
Creates an LDAP syntax compliant timestamp for the given date. That is "YYYYMMDDhhmmssZ". Example: June 4, 2003 10:45 pm and 17 seconds is "20030604224517Z"

Parameters:
date - The date to convert to an LDAP timestamp string

createTimestamp

public java.lang.String createTimestamp()
Creates an LDAP syntax compliant timestamp for the current date.

See Also:
createTimestamp(Date)