Most visited

Recently visited

Added in API level 1
Deprecated since API level 1

Identity

public abstract class Identity
extends Object implements Principal, Serializable

java.lang.Object
   ↳ java.security.Identity
Known Direct Subclasses


This class was deprecated in API level 1.
This class is no longer used. Its functionality has been replaced by java.security.KeyStore, the java.security.cert package, and java.security.Principal.

This class represents identities: real-world objects such as people, companies or organizations whose identities can be authenticated using their public keys. Identities may also be more abstract (or concrete) constructs, such as daemon threads or smart cards.

All Identity objects have a name and a public key. Names are immutable. Identities may also be scoped. That is, if an Identity is specified to have a particular scope, then the name and public key of the Identity are unique within that scope.

An Identity also has a set of certificates (all certifying its own public key). The Principal names specified in these certificates need not be the same, only the key.

An Identity can be subclassed, to include postal and email addresses, telephone numbers, images of faces and logos, and so on.

See also:

Summary

Public constructors

Identity(String name, IdentityScope scope)

Constructs an identity with the specified name and scope.

Identity(String name)

Constructs an identity with the specified name and no scope.

Protected constructors

Identity()

Constructor for serialization only.

Public methods

void addCertificate(Certificate certificate)

Adds a certificate for this identity.

Certificate[] certificates()

Returns a copy of all the certificates for this identity.

final boolean equals(Object identity)

Tests for equality between the specified object and this identity.

String getInfo()

Returns general information previously specified for this identity.

final String getName()

Returns this identity's name.

PublicKey getPublicKey()

Returns this identity's public key.

final IdentityScope getScope()

Returns this identity's scope.

int hashCode()

Returns a hashcode for this identity.

void removeCertificate(Certificate certificate)

Removes a certificate from this identity.

void setInfo(String info)

Specifies a general information string for this identity.

void setPublicKey(PublicKey key)

Sets this identity's public key.

String toString()

Returns a short string describing this identity, telling its name and its scope (if any).

String toString(boolean detailed)

Returns a string representation of this identity, with optionally more details than that provided by the toString method without any arguments.

Protected methods

boolean identityEquals(Identity identity)

Tests for equality between the specified identity and this identity.

Inherited methods

From class java.lang.Object
From interface java.security.Principal

Public constructors

Identity

Added in API level 1
Identity (String name, 
                IdentityScope scope)

Constructs an identity with the specified name and scope.

Parameters
name String: the identity name.
scope IdentityScope: the scope of the identity.
Throws
KeyManagementException if there is already an identity with the same name in the scope.

Identity

Added in API level 1
Identity (String name)

Constructs an identity with the specified name and no scope.

Parameters
name String: the identity name.

Protected constructors

Identity

Added in API level 1
Identity ()

Constructor for serialization only.

Public methods

addCertificate

Added in API level 1
void addCertificate (Certificate certificate)

Adds a certificate for this identity. If the identity has a public key, the public key in the certificate must be the same, and if the identity does not have a public key, the identity's public key is set to be that specified in the certificate.

First, if there is a security manager, its checkSecurityAccess method is called with "addIdentityCertificate" as its argument to see if it's ok to add a certificate.

Parameters
certificate Certificate: the certificate to be added.
Throws
KeyManagementException if the certificate is not valid, if the public key in the certificate being added conflicts with this identity's public key, or if another exception occurs.
SecurityException if a security manager exists and its checkSecurityAccess method doesn't allow adding a certificate.

See also:

certificates

Added in API level 1
Certificate[] certificates ()

Returns a copy of all the certificates for this identity.

Returns
Certificate[] a copy of all the certificates for this identity.

equals

Added in API level 1
boolean equals (Object identity)

Tests for equality between the specified object and this identity. This first tests to see if the entities actually refer to the same object, in which case it returns true. Next, it checks to see if the entities have the same name and the same scope. If they do, the method returns true. Otherwise, it calls identityEquals, which subclasses should override.

Parameters
identity Object: the object to test for equality with this identity.
Returns
boolean true if the objects are considered equal, false otherwise.

See also:

getInfo

Added in API level 1
String getInfo ()

Returns general information previously specified for this identity.

Returns
String general information about this identity.

See also:

getName

Added in API level 1
String getName ()

Returns this identity's name.

Returns
String the name of this identity.

getPublicKey

Added in API level 1
PublicKey getPublicKey ()

Returns this identity's public key.

Returns
PublicKey the public key for this identity.

See also:

getScope

Added in API level 1
IdentityScope getScope ()

Returns this identity's scope.

Returns
IdentityScope the scope of this identity.

hashCode

Added in API level 1
int hashCode ()

Returns a hashcode for this identity.

Returns
int a hashcode for this identity.

removeCertificate

Added in API level 1
void removeCertificate (Certificate certificate)

Removes a certificate from this identity.

First, if there is a security manager, its checkSecurityAccess method is called with "removeIdentityCertificate" as its argument to see if it's ok to remove a certificate.

Parameters
certificate Certificate: the certificate to be removed.
Throws
KeyManagementException if the certificate is missing, or if another exception occurs.
SecurityException if a security manager exists and its checkSecurityAccess method doesn't allow removing a certificate.

See also:

setInfo

Added in API level 1
void setInfo (String info)

Specifies a general information string for this identity.

First, if there is a security manager, its checkSecurityAccess method is called with "setIdentityInfo" as its argument to see if it's ok to specify the information string.

Parameters
info String: the information string.
Throws
SecurityException if a security manager exists and its checkSecurityAccess method doesn't allow setting the information string.

See also:

setPublicKey

Added in API level 1
void setPublicKey (PublicKey key)

Sets this identity's public key. The old key and all of this identity's certificates are removed by this operation.

First, if there is a security manager, its checkSecurityAccess method is called with "setIdentityPublicKey" as its argument to see if it's ok to set the public key.

Parameters
key PublicKey: the public key for this identity.
Throws
KeyManagementException if another identity in the identity's scope has the same public key, or if another exception occurs.
SecurityException if a security manager exists and its checkSecurityAccess method doesn't allow setting the public key.

See also:

toString

Added in API level 1
String toString ()

Returns a short string describing this identity, telling its name and its scope (if any).

First, if there is a security manager, its checkSecurityAccess method is called with "printIdentity" as its argument to see if it's ok to return the string.

Returns
String information about this identity, such as its name and the name of its scope (if any).
Throws
SecurityException if a security manager exists and its checkSecurityAccess method doesn't allow returning a string describing this identity.

See also:

toString

Added in API level 1
String toString (boolean detailed)

Returns a string representation of this identity, with optionally more details than that provided by the toString method without any arguments.

First, if there is a security manager, its checkSecurityAccess method is called with "printIdentity" as its argument to see if it's ok to return the string.

Parameters
detailed boolean: whether or not to provide detailed information.
Returns
String information about this identity. If detailed is true, then this method returns more information than that provided by the toString method without any arguments.
Throws
SecurityException if a security manager exists and its checkSecurityAccess method doesn't allow returning a string describing this identity.

See also:

Protected methods

identityEquals

Added in API level 1
boolean identityEquals (Identity identity)

Tests for equality between the specified identity and this identity. This method should be overriden by subclasses to test for equality. The default behavior is to return true if the names and public keys are equal.

Parameters
identity Identity: the identity to test for equality with this identity.
Returns
boolean true if the identities are considered equal, false otherwise.

See also:

Hooray!