public class X500NameUtils
extends java.lang.Object
Constructor and Description |
---|
X500NameUtils() |
Modifier and Type | Method and Description |
---|---|
static boolean |
equal(java.lang.String rfc2253dn1,
java.lang.String rfc2253dn2)
Convenience method, based on the standard JDK algorithm for DNs comparison.
|
static boolean |
equal(javax.security.auth.x500.X500Principal dn,
java.lang.String rfc2253dn2)
Convenience method for DN comparison.
|
static java.util.Set<org.bouncycastle.asn1.ASN1ObjectIdentifier> |
getAttributeNames(java.lang.String srcDn)
Returns a set with all attribute identifiers which are present in the passed DN.
|
private static java.util.Set<org.bouncycastle.asn1.ASN1ObjectIdentifier> |
getAttributeNames(org.bouncycastle.asn1.x500.X500Name dn) |
static java.util.Set<org.bouncycastle.asn1.ASN1ObjectIdentifier> |
getAttributeNames(javax.security.auth.x500.X500Principal srcDn)
Returns a set with all attribute identifiers which are present in the passed DN.
|
static java.lang.String[] |
getAttributeValues(java.lang.String srcDn,
org.bouncycastle.asn1.ASN1ObjectIdentifier attribute)
Returns an array of values of a provided attribute from the DN.
|
private static java.lang.String[] |
getAttributeValues(org.bouncycastle.asn1.x500.X500Name x500Name,
org.bouncycastle.asn1.ASN1ObjectIdentifier attribute) |
static java.lang.String[] |
getAttributeValues(javax.security.auth.x500.X500Principal srcDn,
org.bouncycastle.asn1.ASN1ObjectIdentifier attribute)
Returns an array of values of a provided attribute from the DN.
|
static java.lang.String |
getComparableForm(java.lang.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 java.lang.String |
getPortableRFC2253Form(java.lang.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 java.lang.String |
getReadableForm(java.lang.String srcDn)
Returns a human-readable representation of this DN.
|
static java.lang.String |
getReadableForm(javax.security.auth.x500.X500Principal srcDn)
Returns a human-readable representation of this DN.
|
static javax.security.auth.x500.X500Principal |
getX500Principal(java.lang.String rfcDn)
Constructs a
X500Principal object from a RFC 2253 string. |
static boolean |
rfc3280Equal(javax.security.auth.x500.X500Principal dn,
javax.security.auth.x500.X500Principal dn2)
Uses the strict RFC 3280 algorithm to compare two DNs.
|
public static boolean equal(java.lang.String rfc2253dn1, java.lang.String rfc2253dn2) throws java.lang.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)java.lang.IllegalArgumentException
- if at least one of the DNs can not be parsedpublic static boolean equal(javax.security.auth.x500.X500Principal dn, java.lang.String rfc2253dn2) throws java.lang.IllegalArgumentException
equal(String, String)
, after retrieving a String representation of
the first argument.dn
- to be comparedrfc2253dn2
- to be comparedjava.lang.IllegalArgumentException
- if the String DN can not be parsedpublic static boolean rfc3280Equal(javax.security.auth.x500.X500Principal dn, javax.security.auth.x500.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 comparedpublic static java.lang.String getReadableForm(java.lang.String srcDn) throws java.lang.IllegalArgumentException
Note: it may happen that output of this method won't be parseable by the X500Principal constructor.
srcDn
- to be outputjava.lang.IllegalArgumentException
- if the source DN can not be parsedpublic static java.lang.String getReadableForm(javax.security.auth.x500.X500Principal srcDn)
Note: it may happen that output of this method won't be parseable by the X500Principal constructor.
srcDn
- to be outputpublic static java.lang.String getPortableRFC2253Form(java.lang.String srcDn)
srcDn
- to be reformattedpublic static java.lang.String getComparableForm(java.lang.String srcDn)
srcDn
- input to be reformattedpublic static java.lang.String[] getAttributeValues(java.lang.String srcDn, org.bouncycastle.asn1.ASN1ObjectIdentifier attribute) throws java.lang.IllegalArgumentException
srcDn
- DN to be parsed in RFC 2253 formattribute
- to be retrieved. JavaAndBCStyle
class and its parent
contain useful constants.java.lang.IllegalArgumentException
- if the provided DN can not be parsedpublic static java.lang.String[] getAttributeValues(javax.security.auth.x500.X500Principal srcDn, org.bouncycastle.asn1.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.private static java.lang.String[] getAttributeValues(org.bouncycastle.asn1.x500.X500Name x500Name, org.bouncycastle.asn1.ASN1ObjectIdentifier attribute)
public static java.util.Set<org.bouncycastle.asn1.ASN1ObjectIdentifier> getAttributeNames(java.lang.String srcDn)
srcDn
- DN to be examinedpublic static java.util.Set<org.bouncycastle.asn1.ASN1ObjectIdentifier> getAttributeNames(javax.security.auth.x500.X500Principal srcDn)
srcDn
- DN to be examinedprivate static java.util.Set<org.bouncycastle.asn1.ASN1ObjectIdentifier> getAttributeNames(org.bouncycastle.asn1.x500.X500Name dn)
public static javax.security.auth.x500.X500Principal getX500Principal(java.lang.String rfcDn) throws java.io.IOException
X500Principal
object from a RFC 2253 string. This
method can handle DNs with attributes not supported by the X500Principal
constructor.rfcDn
- RFC 2253 DNjava.io.IOException
- IO exception