public class DnUtils
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
VAR_DN
Placeholder used in methods that do value substitution in distinguished
names.
|
static java.lang.String |
VAR_RDN
Placeholder used in methods that do value substitution in distinguished
names.
|
| Modifier and Type | Method and Description |
|---|---|
static int |
calculateLevelDif(java.lang.String parentDn,
java.lang.String childDn)
Given a parent DN and a child DN, returns the difference in depth between
those two DNs.
|
static java.lang.String[] |
cutDN(java.lang.String dnToCut,
java.lang.String rdnNameDivision)
Splits a DN into three parts based on a given RDN name.
|
static boolean |
equalsDN(java.lang.String dn1,
java.lang.String dn2)
Indicates whether the two given distinguished names are equal (note:
comparison is case-insensitive).
|
static boolean |
equalsDN(java.lang.String dn1,
java.lang.String dn2,
boolean isMetaDN)
Indicates whether the two given distinguished names are equal (note:
comparison is case-insensitive).
|
static java.lang.String[][] |
explodeDN_ArrayNameValue(java.lang.String dn)
Given a DN, returns an array where each element is a two-element String
array (first element is the RDN name, second element is the RDN value)
representing the RDN that composes the DN.
|
static java.lang.String[] |
explodeDN(java.lang.String dn)
Given a DN, returns an array where each element is an RDN that composes
the DN.
|
static java.lang.String[] |
explodeRDN_fromDN(java.lang.String dn)
Returns a two-element String array containing two elements: the name and
the value of the RDN for the given DN.
|
static java.lang.String[] |
explodeRDN(java.lang.String rdn)
Returns a two-element String array containing two elements: the name and
the value of the given RDN.
|
static java.lang.String |
extractNamingContext(java.lang.String dn)
Given a DN, returns the naming context associated with the DN.
|
static java.lang.String |
findValueInDn(java.lang.String dn,
java.lang.String attrName)
Returns the value of the given attribute if it is found in the DN.
|
static java.lang.String |
getDnFromDvxCatalog(java.lang.String externalDn)
For Radiant Logic Internal Use.
|
static java.lang.String |
getDNPattern(java.lang.String dn)
Returns the original DN with the value part from each RDN removed.
|
static java.lang.String |
getFirstValueForComposite(java.lang.String compositeName,
java.lang.String dn)
For Radiant Logic Internal Use.
|
static java.lang.String |
getIdValueFromRdnValue(java.lang.String rdnValue)
Given an RDN value that has format 'value1 {value2}' returns the value
between brackets.
|
static java.lang.String |
getLabelInBetween(java.lang.String dn)
Note: method intended for Radiant internal use.
|
static java.lang.String |
getLastRdnValue(java.lang.String dn)
Returns the string value of left-most RDN value for the specified DN.
|
static java.lang.String |
getParentDNstr_UsingDN(java.lang.String dn)
Returns the parent DN of the given DN.
|
static java.lang.String |
getParentDNstr(java.lang.String dn)
Returns the parent DN of the given DN.
|
static java.lang.String |
getRdnAttrAndValueStr_UnJndi(java.lang.String dn)
Returns the RDN for the given DN.
|
static java.lang.String |
getRdnAttrAndValueStr(java.lang.String dn)
Returns the RDN for the given DN.
|
static java.lang.String[] |
getRdnAttributesFromRdnValue(java.lang.String rdnValue)
This method splits the values found in the given RDN value based on
whitespace and removes any value found between brackets.
Given an RDN value that has format 'value1 value2 value3 {value4}' returns an array of strings containing ["value1", "value2", value3"]. |
static java.lang.String |
getRdnIdValue(java.lang.String dn)
Returns the value of the RDN (after the '=' sign) for the given DN.
|
static java.lang.String |
getRdnIdValue(java.lang.String dn,
boolean isDNJndiEncoded)
Returns the value of the RDN (after the '=' sign) for the given DN.
|
static java.lang.String |
getRdnName(java.lang.String dn)
Returns the the attribute portion (before the '=' sign) of the RDN for
the specified DN.
|
static java.lang.String |
getRdnValue(java.lang.String dn)
Returns the value of the RDN (after the '=' sign) for the given DN.
|
static java.lang.String |
getRdnValue(java.lang.String dn,
boolean isDnJndiEncoded)
Returns the value of the RDN (after the '=' sign) for the given DN.
|
static boolean |
hasParent(java.lang.String dnChild,
java.lang.String dnParent)
Indicates if the DN given in the second parameter is a parent of the DN
given in the first parameter.
|
static boolean |
hasSameRdnIdValue(java.lang.String dn1,
java.lang.String dn2)
Given two DNs that have the format "attribute=value1 {value2},..."
returns
true if both DNs have the same bracketed value. |
static boolean |
isDescendantOf(java.lang.String dnDown,
java.lang.String dnTop)
Returns
true if the DN specified in the first argument is a
descendant of the DN specified in second argument. |
static boolean |
isDN(java.lang.String s)
Indicates if the given String is a distinguished name.
|
static void |
main(java.lang.String[] args) |
static java.lang.String |
normalizeDN(java.lang.String dn)
Returns the specified DN with the characters '=', ' ', '\', '/' replaced
by an underscore '_'.
|
static java.lang.String |
removeIdValueFromRdnValue(java.lang.String rdnValue)
Given an RDN value that has format 'value1 {value2}' returns 'value1'.
|
static java.lang.String |
removeSuffix(java.lang.String dn,
java.lang.String suffixToRemove)
Returns the DN with the given suffix removed from the original DN (if it
is found).
|
static java.lang.String |
replaceDNWithAttributesValue(java.lang.String dnWithAttributesToReplace,
AttributesEnumeration attrsEnu)
This method is used to populate parts of a DN based on variables
specified in a Map.
|
static java.lang.String |
updateBaseDNSuffix(java.lang.String value,
java.lang.String dnTemplate)
Returns a DN with the placeholders %rdn and %dn found in the DN template
given in the second parameter, replaced by the value given in the first
parameter.
|
static java.lang.String |
updateStringWithRdnDnTag(java.lang.String str,
java.lang.String value)
Updates the given string with the given value where certain placeholders
are found.
|
static java.lang.String |
updateSuffix(java.lang.String dn,
java.lang.String dnSuffixToUpdate,
java.lang.String dnSuffixNewValue)
Returns the DN with the given suffix updated with a new value.
|
static java.lang.String |
updateSuffix(java.lang.String dn,
java.lang.String dnSuffixToUpdate,
java.lang.String dnSuffixNewValue,
java.lang.String rules) |
public static final java.lang.String VAR_RDN
public static final java.lang.String VAR_DN
public static java.lang.String getLastRdnValue(java.lang.String dn)
dn - a distinguished namepublic static final java.lang.String getFirstValueForComposite(java.lang.String compositeName,
java.lang.String dn)
compositeName - dn - public static java.lang.String getDnFromDvxCatalog(java.lang.String externalDn)
externalDn - public static java.lang.String normalizeDN(java.lang.String dn)
dn - a distinguished name.public static void main(java.lang.String[] args)
public static boolean equalsDN(java.lang.String dn1,
java.lang.String dn2)
dn1 - a distinguished name.dn2 - a distinguished name.true if the two distinguished names are equal, false
otherwise.public static boolean equalsDN(java.lang.String dn1,
java.lang.String dn2,
boolean isMetaDN)
dn1 - a distinguished name.dn2 - a distinguished name.isMetaDN - if true, uses a comparison algorithm specific to
meta DNs, should be set to false otherwise.true if the two given distinguished names are equal,
false otherwise.public static int calculateLevelDif(java.lang.String parentDn,
java.lang.String childDn)
parentDn - the parent DN.childDn - the child DN, a descendant of the given parent DN.public static java.lang.String getParentDNstr(java.lang.String dn)
null if it
does not exist. dn - a distinguished name.null if it does not exist.public static java.lang.String getParentDNstr_UsingDN(java.lang.String dn)
null if it
does not exist. dn - a distinguished name.null if it does not exist.public static java.lang.String getRdnName(java.lang.String dn)
dn - a distinguished name.public static java.lang.String getRdnAttrAndValueStr_UnJndi(java.lang.String dn)
dn - a distinguished name.public static java.lang.String getRdnAttrAndValueStr(java.lang.String dn)
dn - a distinguished name.public static java.lang.String getRdnValue(java.lang.String dn)
dn - a distinguished name.public static java.lang.String getRdnIdValue(java.lang.String dn)
dn - a distinguished name.public static java.lang.String getRdnValue(java.lang.String dn,
boolean isDnJndiEncoded)
dn - a distinguished name.isDnJndiEncoded - set to true to indicate that the DN is JNDI
encoded, false otherwise.public static java.lang.String getRdnIdValue(java.lang.String dn,
boolean isDNJndiEncoded)
dn - a distinguished name.isDNJndiEncoded - set to true to indicate that the DN is JNDI
encoded, false otherwise.public static java.lang.String getIdValueFromRdnValue(java.lang.String rdnValue)
rdnValue - the value of an RDN (after the '=' sign).public static java.lang.String removeIdValueFromRdnValue(java.lang.String rdnValue)
rdnValue - the value of an RDN (after the '=' sign).public static java.lang.String[] getRdnAttributesFromRdnValue(java.lang.String rdnValue)
rdnValue - an RDN value.public static boolean hasSameRdnIdValue(java.lang.String dn1,
java.lang.String dn2)
true if both DNs have the same bracketed value.dn1 - a distinguished name with a bracketed value.dn2 - a distinguished name with a bracketed value.true if both DNs have the same bracketed
value, false otherwise.public static boolean isDescendantOf(java.lang.String dnDown,
java.lang.String dnTop)
true if the DN specified in the first argument is a
descendant of the DN specified in second argument.dnDown - a distinguished name.dnTop - a distinguished name.true if the DN specified in the first argument is a
descendant of the DN specified in second argument,
false otherwise.public static java.lang.String replaceDNWithAttributesValue(java.lang.String dnWithAttributesToReplace,
AttributesEnumeration attrsEnu)
dnWithAttributesToReplace - a distinguished name with '@' signs where values will be
inserted.mapAttributes - a map of attributes (keys) and their values.public static java.lang.String[] cutDN(java.lang.String dnToCut,
java.lang.String rdnNameDivision)
dnToCut - the distinguished name that we are splitting.rdnNameDivision - the RDN name used to determine where the DN is split.public static boolean isDN(java.lang.String s)
s - a Stringtrue if the given String is a distinguished name,
false otherwise.public static java.lang.String extractNamingContext(java.lang.String dn)
dn - a distinguished name.public static java.lang.String[] explodeDN(java.lang.String dn)
dn - a distinguished name.public static java.lang.String[][] explodeDN_ArrayNameValue(java.lang.String dn)
dn - a distinguished name.public static java.lang.String[] explodeRDN_fromDN(java.lang.String dn)
dn - a distinguished name.public static java.lang.String[] explodeRDN(java.lang.String rdn)
rdn - a relative distinguished name.public static java.lang.String getLabelInBetween(java.lang.String dn)
dn - a meta DN.public static java.lang.String updateSuffix(java.lang.String dn,
java.lang.String dnSuffixToUpdate,
java.lang.String dnSuffixNewValue)
dn - a distinguished name.dnSuffixToUpdate - a suffix to update.dnSuffixNewValue - a value to replace the suffix.public static java.lang.String updateSuffix(java.lang.String dn,
java.lang.String dnSuffixToUpdate,
java.lang.String dnSuffixNewValue,
java.lang.String rules)
public static java.lang.String removeSuffix(java.lang.String dn,
java.lang.String suffixToRemove)
dn - a distinguished name.suffixToRemove - the suffix to remove from the DN.public static java.lang.String updateBaseDNSuffix(java.lang.String value,
java.lang.String dnTemplate)
value - a value that will be used to replace the placeholders.dnTemplate - a distinguished name template (a DN that can contain %rdn or
%dn as placeholders).public static java.lang.String updateStringWithRdnDnTag(java.lang.String str,
java.lang.String value)
str - a string containing %rdn or %dn where values will be
substituted.value - the value that will be inserted anywhere %rdn or %dn are found
in the string.public static java.lang.String getDNPattern(java.lang.String dn)
dn - a distinguished name.public static boolean hasParent(java.lang.String dnChild,
java.lang.String dnParent)
dnChild - a distinguished name.dnParent - a distinguished name.true if the DN given in the second parameter is a
parent of the DN given in the first parameter, false
otherwise.public static java.lang.String findValueInDn(java.lang.String dn,
java.lang.String attrName)
dn - a distinguished name.attrName - the name of an attribute to search for in the DN.null otherwise.