|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecteu.emi.security.authn.x509.impl.X500NameUtils
public class X500NameUtils
Contains utility static methods which are helpful in manipulating X.500 Distinguished Names, especially encoded in String form using RFC 2253.
| Constructor Summary | |
|---|---|
X500NameUtils()
|
|
| Method Summary | |
|---|---|
static boolean |
equal(String rfc2253dn1,
String rfc2253dn2)
Convenience method, based on the standard JDK algorithm for DNs comparison. |
static boolean |
equal(X500Principal dn,
String rfc2253dn2)
Convenience method for DN comparison. |
static Set<ASN1ObjectIdentifier> |
getAttributeNames(String srcDn)
Returns a set with all attribute identifiers which are present in the passed DN. |
static Set<ASN1ObjectIdentifier> |
getAttributeNames(X500Principal srcDn)
Returns a set with all attribute identifiers which are present in the passed DN. |
static String[] |
getAttributeValues(String srcDn,
ASN1ObjectIdentifier attribute)
Returns an array of values of a provided attribute from the DN. |
static String[] |
getAttributeValues(X500Principal srcDn,
ASN1ObjectIdentifier attribute)
Returns an array of values of a provided attribute from the DN. |
static String |
getComparableForm(String srcDn)
Returns a form of the source DN in RFC 2253 form (or similar - some minor format violations are properly handled) which is suitable for string comparison. |
static String |
getPortableRFC2253Form(String srcDn)
Returns a form of the source DN in RFC 2253 form (or similar - some minor format violations are properly handled) which is strictly RFC2253 and is guaranteed to be correctly parsed by the JDK methods. |
static String |
getReadableForm(String srcDn)
Returns a human-readable representation of this DN. |
static String |
getReadableForm(X500Principal srcDn)
Returns a human-readable representation of this DN. |
static X500Principal |
getX500Principal(String rfcDn)
Constructs a X500Principal object from a RFC 2253 string. |
static boolean |
rfc3280Equal(X500Principal dn,
X500Principal dn2)
Uses the strict RFC 3280 algorithm to compare two DNs. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public X500NameUtils()
| Method Detail |
|---|
public static boolean equal(String rfc2253dn1,
String rfc2253dn2)
throws IllegalArgumentException
rfc2253dn1 - to be compared (need not to strictly follow the RFC encoding)rfc2253dn2 - to be compared (need not to strictly follow the RFC encoding)
IllegalArgumentException - if at least one of the DNs can not be parsed
public static boolean equal(X500Principal dn,
String rfc2253dn2)
throws IllegalArgumentException
equal(String, String), after retrieving a String representation of
the first argument.
dn - to be comparedrfc2253dn2 - to be compared
IllegalArgumentException - if the String DN can not be parsed
public static boolean rfc3280Equal(X500Principal dn,
X500Principal dn2)
Note 1: that in certain situations it is possible to get a false answer when comparing DNs with this method, while other DN equality tests from this class (operating on String DN representations) return true.
Note 2: it is nearly always wrong to convert a string representation of a DN to the X500Principal object and then to compare it against another using this method. In such a case always use the other equal methods from this class with one or two String arguments.
Note 3: this implementation is actually delegating to the JDK's X500Principal
equals method, which seems to follow (one of the versions of) the rules of the RFC.
dn - to be compareddn2 - to be compared
public static String getReadableForm(String srcDn)
throws IllegalArgumentException
Note: it may happen that output of this method won't be parseable by the X500Principal constructor.
srcDn - to be output
IllegalArgumentException - if the source DN can not be parsedpublic static String getReadableForm(X500Principal srcDn)
Note: it may happen that output of this method won't be parseable by the X500Principal constructor.
srcDn - to be output
public static String getPortableRFC2253Form(String srcDn)
srcDn - to be reformatted
public static String getComparableForm(String srcDn)
srcDn - input to be reformatted
public static String[] getAttributeValues(String srcDn,
ASN1ObjectIdentifier attribute)
throws IllegalArgumentException
srcDn - DN to be parsed in RFC 2253 formattribute - to be retrieved. JavaAndBCStyle class and its parent
contain useful constants.
IllegalArgumentException - if the provided DN can not be parsed
public static String[] getAttributeValues(X500Principal srcDn,
ASN1ObjectIdentifier attribute)
getAttributeValues(String, ASN1ObjectIdentifier) for details.
srcDn - DN to be parsed in RFC 2253 formattribute - to be retrieved JavaAndBCStyle class and its parent contain
useful constants.
public static Set<ASN1ObjectIdentifier> getAttributeNames(String srcDn)
srcDn - DN to be examined
public static Set<ASN1ObjectIdentifier> getAttributeNames(X500Principal srcDn)
srcDn - DN to be examined
public static X500Principal getX500Principal(String rfcDn)
throws IOException
X500Principal object from a RFC 2253 string. This
method can handle DNs with attributes not supported by the X500Principal
constructor.
rfcDn - RFC 2253 DN
IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||