java.security
java.security.KeyStore
, the
java.security.cert
package, and
java.security.Principal
.public abstract class Identity extends Object implements Principal, Serializable
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.
IdentityScope
,
Signer
,
Principal
,
Serialized FormModifier | Constructor and Description |
---|---|
protected |
Identity()
Deprecated.
Constructor for serialization only.
|
|
Identity(String name)
Deprecated.
Constructs a new instance of
Identity with the specified
name and no scope. |
|
Identity(String name,
IdentityScope scope)
Deprecated.
Constructs a new instance of
Identity with the specified
name and scope. |
Modifier and Type | Method and Description |
---|---|
void |
addCertificate(Certificate certificate)
Deprecated.
Adds a certificate to the list of ceritificates for this identity.
|
Certificate[] |
certificates()
Deprecated.
|
boolean |
equals(Object identity)
Deprecated.
Checks for equality between this Identity and a specified object.
|
String |
getInfo()
Deprecated.
|
String |
getName()
Deprecated.
This method returns a
String that names this
Principal . |
PublicKey |
getPublicKey()
Deprecated.
|
IdentityScope |
getScope()
Deprecated.
|
int |
hashCode()
Deprecated.
Get a value that represents this Object, as uniquely as
possible within the confines of an int.
|
protected boolean |
identityEquals(Identity identity)
Deprecated.
Checks for equality between this Identity and a specified object.
|
void |
removeCertificate(Certificate certificate)
Deprecated.
Removes a certificate from the list of ceritificates for this identity.
|
void |
setInfo(String info)
Deprecated.
Sets the general information string.
|
void |
setPublicKey(PublicKey key)
Deprecated.
Sets the public key for this identity.
|
String |
toString()
Deprecated.
Returns a string representation of this Identity.
|
String |
toString(boolean detailed)
Deprecated.
Returns a detailed string representation of this Identity.
|
protected Identity()
public Identity(String name, IdentityScope scope) throws KeyManagementException
Identity
with the specified
name and scope.name
- the name to use.scope
- the scope to use.KeyManagementException
- if the identity is already present.public final String getName()
Principal
String
that names this
Principal
.public final IdentityScope getScope()
public PublicKey getPublicKey()
setPublicKey(java.security.PublicKey)
public void setPublicKey(PublicKey key) throws KeyManagementException
key
- the public key to use.KeyManagementException
- if this public key is used by another identity in the current
scope.SecurityException
- if a SecurityManager
is installed which disallows this
operation.public void setInfo(String info)
info
- the general information string.SecurityException
- if a SecurityManager
is installed which disallows this
operation.public String getInfo()
setInfo(String)
public void addCertificate(Certificate certificate) throws KeyManagementException
certificate
- the certificate to add.KeyManagementException
- if the certificate is invalid, or the public key conflicts.SecurityException
- if a SecurityManager
is installed which disallows this
operation.public void removeCertificate(Certificate certificate) throws KeyManagementException
certificate
- the certificate to remove.KeyManagementException
- if the certificate is invalid.SecurityException
- if a SecurityManager
is installed which disallows this
operation.public Certificate[] certificates()
Certificate
s for this identity.public final boolean equals(Object identity)
true
if successful. If these tests fail, the
identityEquals(Identity)
method is called.equals
in interface Principal
equals
in class Object
identity
- the Object to compare totrue
if they are equal, false
otherwise.Object.hashCode()
protected boolean identityEquals(Identity identity)
true
if the public key and names match.true
if they are equal, false
otherwise.public String toString()
toString
in interface Principal
toString
in class Object
SecurityException
- if a SecurityManager
is installed which disallows this
operation.Object.getClass()
,
Object.hashCode()
,
Class.getName()
,
Integer.toHexString(int)
public String toString(boolean detailed)
detailed
- indicates whether or detailed information is desired.SecurityException
- if a SecurityManager
is installed which disallows this
operation.public int hashCode()
Object
There are some requirements on this method which
subclasses must follow:
a.equals(b)
is true, then
a.hashCode() == b.hashCode()
must be as well.
However, the reverse is not necessarily true, and two
objects may have the same hashcode without being equal.Notice that since hashCode
is used in
Hashtable
and other hashing classes,
a poor implementation will degrade the performance of hashing
(so don't blindly implement it as returning a constant!). Also,
if calculating the hash is time-consuming, a class may consider
caching the results.
The default implementation returns
System.identityHashCode(this)
hashCode
in interface Principal
hashCode
in class Object
Object.equals(Object)
,
System.identityHashCode(Object)