|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.internet2.middleware.ldappc.util.LdapUtil
public final class LdapUtil
This provides utility methods for interacting with a LDAP directory.
| Field Summary | |
|---|---|
static String |
EMPTY_NAME
Empty name string for name parser. |
static String |
MULTIVALUED_RDN_DELIMITER
Delimiter for multivalued RDNs. |
static String |
OBJECT_CLASS_ATTRIBUTE
Object class attribute name. |
| Method Summary | |
|---|---|
static String |
canonicalizeDn(String dn)
Normalize LDAP DN using LdapDN. |
static String |
convertParameterToAsterisk(String filter,
int parameterIndex)
Converts a "{i}" ldap query filter parameter to "*" where i >= 0. |
static void |
delete(Ldappc ldappc,
Name dn)
This deletes the object identified by the given dn and any child objects. |
static String |
escapeForwardSlash(String dn)
Escape all forward slashes "/" with "\/". |
static List<String> |
getChildDNs(String dn,
edu.vt.middleware.ldap.Ldap ldap)
Return a list of child DNs under the given DN, in (reverse) order suitable for deletion. |
static List<String> |
getChildDNs(String dn,
LdapContext ldap)
Return a list of child DNs under the given DN, in (reverse) order suitable for deletion. |
static String |
getLdif(Attribute attribute)
Create an LDIF representation. |
static String |
getLdif(Attributes attributes)
Create an LDIF representation. |
static String |
getLdifAdd(org.apache.directory.shared.ldap.name.LdapDN dn,
Attributes attributes)
|
static String |
getLdifDelete(org.apache.directory.shared.ldap.name.LdapDN dn)
|
static String |
getLdifModify(org.apache.directory.shared.ldap.name.LdapDN dn,
ModificationItem[] modificationItems)
|
static Name |
getName(NameParser parser,
SearchResult searchResult)
Return the Name of a SearchResult via getName(). |
static String |
getParentDn(String dn)
|
static String |
makeLdapFilterValueSafe(String value)
This method converts '*','(',')' and the "null" character (i.e., 0x00) to be a forward slash (i.e., \) and the two hex character value as defined in RFC2254. |
static String |
makeLdapNameSafe(String value)
This method escapes all LDAP special characters in the value. |
static BufferedReader |
openReader(File file)
Open file for reading. |
static BufferedWriter |
openWriter(File file)
Open the file for writing. |
static Attributes |
searchAttributes(edu.vt.middleware.ldap.Ldap ldap,
String dn)
Returns all attributes. |
static Attributes |
searchAttributes(edu.vt.middleware.ldap.Ldap ldap,
String dn,
String[] retAttrs)
Returns the attributes of a given LDAP dn. |
static Iterator<SearchResult> |
searchEntryDn(edu.vt.middleware.ldap.Ldap ldap,
String dn,
String[] retAttrs)
Perform a search for a given LDAP entry. |
static String |
unescapeForwardSlash(String dn)
Remove the escape character "\" from all escaped forward slashes "\/", returning "/". |
static void |
writeLdif(BufferedWriter writer,
String ldif)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String OBJECT_CLASS_ATTRIBUTE
public static final String EMPTY_NAME
public static final String MULTIVALUED_RDN_DELIMITER
| Method Detail |
|---|
public static void delete(Ldappc ldappc,
Name dn)
throws NamingException
ldappc - dn - the DN to delete
NamingExceptionpublic static String makeLdapFilterValueSafe(String value)
value - String to make safe
public static String makeLdapNameSafe(String value)
value. This way
it is safe to use as part of an LDAP DN.
value - String to make safe
public static String convertParameterToAsterisk(String filter,
int parameterIndex)
filter - Ldap query filterparameterIndex - Index of the parameter to alter
public static Name getName(NameParser parser,
SearchResult searchResult)
throws NamingException
parser - the Context's NameParsersearchResult - the SearchResult
NamingException
public static String getLdif(Attribute attribute)
throws NamingException
attribute -
NamingException
public static String getLdif(Attributes attributes)
throws NamingException
attributes -
NamingException
public static String getLdifModify(org.apache.directory.shared.ldap.name.LdapDN dn,
ModificationItem[] modificationItems)
throws NamingException
NamingException
public static String getLdifAdd(org.apache.directory.shared.ldap.name.LdapDN dn,
Attributes attributes)
throws NamingException
NamingException
public static String getLdifDelete(org.apache.directory.shared.ldap.name.LdapDN dn)
throws NamingException
NamingException
public static void writeLdif(BufferedWriter writer,
String ldif)
public static BufferedWriter openWriter(File file)
throws LdappcException
file - File to write to.
LdappcException - thrown if the file cannot be opened.
public static BufferedReader openReader(File file)
throws LdappcException
file - File to read from.
LdappcException - thrown if the file cannot be opened.
public static List<String> getChildDNs(String dn,
edu.vt.middleware.ldap.Ldap ldap)
throws NamingException
dn - the dn to delete, as well as all childrenldap - the ldap connection
NamingException
public static List<String> getChildDNs(String dn,
LdapContext ldap)
throws NamingException
dn - the dn to delete, as well as all childrenldap - the ldap connection
NamingException
public static Attributes searchAttributes(edu.vt.middleware.ldap.Ldap ldap,
String dn)
throws NamingException,
LdappcException
searchAttributes(Ldap, String, String[])
NamingException
LdappcException
public static Attributes searchAttributes(edu.vt.middleware.ldap.Ldap ldap,
String dn,
String[] retAttrs)
throws NamingException,
LdappcException
ldap - the vt-ldap connectiondn - the dn to search forretAttrs - the attr names to return
NamingException
LdappcException - if one and only one matching dn is not found
public static Iterator<SearchResult> searchEntryDn(edu.vt.middleware.ldap.Ldap ldap,
String dn,
String[] retAttrs)
throws NamingException
ldap - dn - retAttrs -
NamingExceptionpublic static String escapeForwardSlash(String dn)
dn -
public static String unescapeForwardSlash(String dn)
dn -
public static String canonicalizeDn(String dn)
throws InvalidNameException
LdapDN. This
will convert RDN attributeTypes to lowercase, which is of interest since Active
Directory usually (?) returns attributeTypes uppercased.
dn -
InvalidNameException
public static String getParentDn(String dn)
throws InvalidNameException
InvalidNameException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||