X500Principalpublic final class X500Principal extends Object implements Serializable, PrincipalRepresents an X.500 principal, which holds the distinguished name of some
network entity. An example of a distinguished name is {@code "O=Google,
OU=Android, C=US"}. The class can be instantiated from a byte representation
of an object identifier (OID), an ASN.1 DER-encoded version, or a simple
string holding the distinguished name. The representations must follow either
RFC 2253, RFC 1779, or RFC2459. |
Fields Summary |
---|
private static final long | serialVersionUID | public static final String | CANONICALDefines a constant for the canonical string format of distinguished
names. | public static final String | RFC1779Defines a constant for the RFC 1779 string format of distinguished
names. | public static final String | RFC2253Defines a constant for the RFC 2253 string format of distinguished
names. | private transient org.apache.harmony.security.x501.Name | dn |
Constructors Summary |
---|
public X500Principal(byte[] name)Creates a new X500Principal from a given ASN.1 DER encoding of a
distinguished name.
super();
if (name == null) {
throw new IllegalArgumentException(Messages.getString("auth.00")); //$NON-NLS-1$
}
try {
// FIXME dn = new Name(name);
dn = (Name) Name.ASN1.decode(name);
} catch (IOException e) {
IllegalArgumentException iae = new IllegalArgumentException(Messages
.getString("auth.2B")); //$NON-NLS-1$
iae.initCause(e);
throw iae;
}
| public X500Principal(InputStream in)Creates a new X500Principal from a given ASN.1 DER encoding of a
distinguished name.
super();
if (in == null) {
throw new NullPointerException(Messages.getString("auth.2C")); //$NON-NLS-1$
}
try {
// FIXME dn = new Name(is);
dn = (Name) Name.ASN1.decode(in);
} catch (IOException e) {
IllegalArgumentException iae = new IllegalArgumentException(Messages
.getString("auth.2B")); //$NON-NLS-1$
iae.initCause(e);
throw iae;
}
| public X500Principal(String name)Creates a new X500Principal from a string representation of a
distinguished name.
super();
if (name == null) {
throw new NullPointerException(Messages.getString("auth.00")); //$NON-NLS-1$
}
try {
dn = new Name(name);
} catch (IOException e) {
IllegalArgumentException iae = new IllegalArgumentException(Messages
.getString("auth.2D")); //$NON-NLS-1$
iae.initCause(e);
throw iae;
}
|
Methods Summary |
---|
public boolean | equals(java.lang.Object o)
if (this == o) {
return true;
}
if (o == null || this.getClass() != o.getClass()) {
return false;
}
X500Principal principal = (X500Principal) o;
return dn.getName(CANONICAL).equals(principal.dn.getName(CANONICAL));
| public byte[] | getEncoded()Returns an ASN.1 DER-encoded representation of the distinguished name
contained in this X.500 principal.
byte[] src = dn.getEncoded();
byte[] dst = new byte[src.length];
System.arraycopy(src, 0, dst, 0, dst.length);
return dst;
| public java.lang.String | getName()Returns a human-readable string representation of the distinguished name
contained in this X.500 principal.
return dn.getName(RFC2253);
| public java.lang.String | getName(java.lang.String format)Returns a string representation of the distinguished name contained in
this X.500 principal. The format of the representation can be chosen.
Valid arguments are {@link #RFC1779}, {@link #RFC2253}, and
{@link #CANONICAL}. The representations are specified in RFC 1779 and RFC
2253, respectively. The canonical form is based on RFC 2253, but adds
some canonicalizing operations like removing leading and trailing
whitespace, lower-casing the whole name, and bringing it into a
normalized Unicode representation.
return dn.getName(format);
| public int | hashCode()
return dn.getName(CANONICAL).hashCode();
| private void | readObject(java.io.ObjectInputStream in)
dn = (Name) Name.ASN1.decode((byte[]) in.readObject());
| public java.lang.String | toString()
return dn.getName(RFC1779);
| private void | writeObject(java.io.ObjectOutputStream out)
out.writeObject(dn.getEncoded());
|
|