java.security

Class Identity

public abstract class Identity extends Object implements Principal, Serializable

Deprecated: Replaced by java.security.KeyStore, the java.security.cert package, and java.security.Principal.

The Identity class is used to represent people and companies that can be authenticated using public key encryption. The identities can also be abstract objects such as smart cards.

Identity objects store a name and public key for each identity. The names cannot be changed and the identities can be scoped. Each identity (name and public key) within a scope are unique to that scope.

Each identity has a set of ceritificates which all specify the same public key, but not necessarily the same name.

The Identity class can be subclassed to allow additional information to be attached to it.

See Also: IdentityScope Signer Principal

Constructor Summary
protected Identity()
Constructor for serialization only.
Identity(String name, IdentityScope scope)
Constructs a new instance of Identity with the specified name and scope.
Identity(String name)
Constructs a new instance of Identity with the specified name and no scope.
Method Summary
voidaddCertificate(Certificate certificate)
Adds a certificate to the list of ceritificates for this identity.
Certificate[]certificates()
booleanequals(Object identity)
Checks for equality between this Identity and a specified object.
StringgetInfo()
StringgetName()
PublicKeygetPublicKey()
IdentityScopegetScope()
inthashCode()
protected booleanidentityEquals(Identity identity)
Checks for equality between this Identity and a specified object.
voidremoveCertificate(Certificate certificate)
Removes a certificate from the list of ceritificates for this identity.
voidsetInfo(String info)
Sets the general information string.
voidsetPublicKey(PublicKey key)
Sets the public key for this identity.
StringtoString()
Returns a string representation of this Identity.
StringtoString(boolean detailed)
Returns a detailed string representation of this Identity.

Constructor Detail

Identity

protected Identity()
Constructor for serialization only.

Identity

public Identity(String name, IdentityScope scope)
Constructs a new instance of Identity with the specified name and scope.

Parameters: name the name to use. scope the scope to use.

Throws: KeyManagementException if the identity is already present.

Identity

public Identity(String name)
Constructs a new instance of Identity with the specified name and no scope.

Parameters: name the name to use.

Method Detail

addCertificate

public void addCertificate(Certificate certificate)
Adds a certificate to the list of ceritificates for this identity. The public key in this certificate must match the existing public key if it exists.

Parameters: certificate the certificate to add.

Throws: KeyManagementException if the certificate is invalid, or the public key conflicts. SecurityException if a {@link SecurityManager} is installed which disallows this operation.

certificates

public Certificate[] certificates()

Returns: an array of {@link Certificate}s for this identity.

equals

public final boolean equals(Object identity)
Checks for equality between this Identity and a specified object. It first checks if they are the same object, then if the name and scope match and returns true if successful. If these tests fail, the {@link #identityEquals(Identity)} method is called.

Returns: true if they are equal, false otherwise.

getInfo

public String getInfo()

Returns: the general information string of this identity.

See Also: setInfo

getName

public final String getName()

Returns: the name of this identity.

getPublicKey

public PublicKey getPublicKey()

Returns: the public key of this identity.

See Also: setPublicKey

getScope

public final IdentityScope getScope()

Returns: the scope of this identity.

hashCode

public int hashCode()

Returns: a hashcode of this identity.

identityEquals

protected boolean identityEquals(Identity identity)
Checks for equality between this Identity and a specified object. A subclass should override this method. The default behavior is to return true if the public key and names match.

Returns: true if they are equal, false otherwise.

removeCertificate

public void removeCertificate(Certificate certificate)
Removes a certificate from the list of ceritificates for this identity.

Parameters: certificate the certificate to remove.

Throws: KeyManagementException if the certificate is invalid. SecurityException if a {@link SecurityManager} is installed which disallows this operation.

setInfo

public void setInfo(String info)
Sets the general information string.

Parameters: info the general information string.

Throws: SecurityException if a {@link SecurityManager} is installed which disallows this operation.

setPublicKey

public void setPublicKey(PublicKey key)
Sets the public key for this identity. The old key and all certificates are removed.

Parameters: key the public key to use.

Throws: KeyManagementException if this public key is used by another identity in the current scope. SecurityException if a {@link SecurityManager} is installed which disallows this operation.

toString

public String toString()
Returns a string representation of this Identity.

Returns: a string representation of this Identity.

Throws: SecurityException if a {@link SecurityManager} is installed which disallows this operation.

toString

public String toString(boolean detailed)
Returns a detailed string representation of this Identity.

Parameters: detailed indicates whether or detailed information is desired.

Returns: a string representation of this Identity.

Throws: SecurityException if a {@link SecurityManager} is installed which disallows this operation.