public final class LdifUtils
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private static int |
DEFAULT_LINE_LENGTH
The default length for a line in a ldif file
|
private static boolean[] |
LDIF_SAFE_OTHER_CHARS_ALPHABET
The array that will be used to match the other chars.
|
private static boolean[] |
LDIF_SAFE_STARTING_CHAR_ALPHABET
The array that will be used to match the first char.
|
private static java.lang.String |
LINE_SEPARATOR
The file separator
|
| Modifier | Constructor and Description |
|---|---|
private |
LdifUtils()
Private constructor.
|
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
convertAttributesToLdif(Entry entry)
Convert all the Entry's attributes to LDIF.
|
static java.lang.String |
convertAttributesToLdif(Entry entry,
int length)
Convert the Entry's attributes to LDIF.
|
static java.lang.String |
convertToLdif(Attribute attr)
Converts an EntryAttribute to LDIF
|
static java.lang.String |
convertToLdif(Attribute attr,
int length)
Converts an EntryAttribute as LDIF
|
static java.lang.String |
convertToLdif(javax.naming.directory.Attributes attrs)
Convert an Attributes as LDIF
|
static java.lang.String |
convertToLdif(javax.naming.directory.Attributes attrs,
Dn dn)
Convert an Attributes as LDIF.
|
static java.lang.String |
convertToLdif(javax.naming.directory.Attributes attrs,
Dn dn,
int length)
Convert an Attributes as LDIF.
|
static java.lang.String |
convertToLdif(javax.naming.directory.Attributes attrs,
int length)
Convert an Attributes as LDIF
|
static java.lang.String |
convertToLdif(Entry entry)
Convert an Entry to LDIF
|
static java.lang.String |
convertToLdif(Entry entry,
boolean includeVersionInfo)
Convert an Entry to LDIF including a version number at the top
|
static java.lang.String |
convertToLdif(Entry entry,
int length)
Convert an Entry as LDIF
|
static java.lang.String |
convertToLdif(LdifEntry entry)
Convert an LdifEntry to LDIF
|
static java.lang.String |
convertToLdif(LdifEntry entry,
int length)
Convert an LdifEntry to LDIF
|
static javax.naming.directory.Attributes |
createJndiAttributes(java.lang.Object... avas)
Build a new Attributes instance from a LDIF list of lines.
|
private static java.lang.String |
encodeBase64(java.lang.String str)
Base64 encode a String
|
static javax.naming.directory.Attributes |
getJndiAttributesFromLdif(java.lang.String ldif)
Convert a LDIF String to a JNDI attributes.
|
static boolean |
isLDIFSafe(java.lang.String str)
Checks if the input String contains only safe values, that is, the data
does not need to be encoded for use with LDIF.
|
static java.lang.String |
stripLineToNChars(java.lang.String str,
int nbChars)
Strips the String every n specified characters
|
private static final boolean[] LDIF_SAFE_STARTING_CHAR_ALPHABET
private static final boolean[] LDIF_SAFE_OTHER_CHARS_ALPHABET
private static final int DEFAULT_LINE_LENGTH
private static final java.lang.String LINE_SEPARATOR
public static boolean isLDIFSafe(java.lang.String str)
str - the String to be checkedpublic static java.lang.String convertToLdif(javax.naming.directory.Attributes attrs)
throws LdapException
attrs - the Attributes to convertLdapException - If a naming exception is encountered.public static java.lang.String convertToLdif(javax.naming.directory.Attributes attrs,
int length)
throws LdapException
attrs - the Attributes to convertlength - The ldif line lengthLdapException - If a naming exception is encountered.public static java.lang.String convertToLdif(javax.naming.directory.Attributes attrs,
Dn dn,
int length)
throws LdapException
attrs - the Attributes to convertdn - The Dn for this entrylength - The ldif line lengthLdapException - If a naming exception is encountered.public static java.lang.String convertToLdif(javax.naming.directory.Attributes attrs,
Dn dn)
throws LdapException
attrs - the Attributes to convertdn - The Dn for this entryLdapException - If a naming exception is encountered.public static java.lang.String convertToLdif(Entry entry) throws LdapException
entry - the Entry to convertLdapException - If a naming exception is encountered.public static java.lang.String convertToLdif(Entry entry, boolean includeVersionInfo) throws LdapException
entry - the Entry to convertincludeVersionInfo - flag to tell whether to include version number or notLdapException - If a naming exception is encountered.public static java.lang.String convertAttributesToLdif(Entry entry) throws LdapException
entry - the Entry to convertLdapException - If a naming exception is encountered.public static javax.naming.directory.Attributes getJndiAttributesFromLdif(java.lang.String ldif)
throws LdapLdifException
ldif - The LDIF string containing an attribute valueLdapLdifException - If the LDIF String cannot be converted to an Attributespublic static java.lang.String convertToLdif(Entry entry, int length) throws LdapException
entry - the Entry to convertlength - the expected line lengthLdapException - If a naming exception is encountered.public static java.lang.String convertAttributesToLdif(Entry entry, int length) throws LdapException
entry - the Entry to convertlength - the expected line lengthLdapException - If a naming exception is encountered.public static java.lang.String convertToLdif(LdifEntry entry) throws LdapException
entry - the LdifEntry to convertLdapException - If a naming exception is encountered.public static java.lang.String convertToLdif(LdifEntry entry, int length) throws LdapException
entry - the LdifEntry to convertlength - The maximum line's lengthLdapException - If a naming exception is encountered.private static java.lang.String encodeBase64(java.lang.String str)
str - The string to encodepublic static java.lang.String convertToLdif(Attribute attr) throws LdapException
attr - the >EntryAttribute to convertLdapException - If a naming exception is encountered.public static java.lang.String convertToLdif(Attribute attr, int length) throws LdapException
attr - the EntryAttribute to convertlength - the expected line lengthLdapException - If a naming exception is encountered.public static java.lang.String stripLineToNChars(java.lang.String str,
int nbChars)
str - the string to stripnbChars - the number of characterspublic static javax.naming.directory.Attributes createJndiAttributes(java.lang.Object... avas)
throws LdapException
Attribute attr = AttributeUtils.createAttributes(
"objectclass: top",
"cn", "My name",
"jpegPhoto", new byte[]{0x01, 0x02} );
avas - The AttributeType and Values, using a ldif format, or a couple of
Attribute ID/ValueLdapException - If the data are invalid