Serializable
, Principal
IdentityScope
, Signer
@Deprecated(since="1.2", forRemoval=true) public abstract class Identity extends Object implements Principal, Serializable
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.
Modifier | Constructor | Description |
---|---|---|
protected |
Deprecated, for removal: This API element is subject to removal in a future version. Constructor for serialization only. |
|
Deprecated, for removal: This API element is subject to removal in a future version. Constructs an Identity with the specified name and no scope. |
||
Deprecated, for removal: This API element is subject to removal in a future version. Constructs an Identity with the specified name and scope. |
Modifier and Type | Method | Description |
---|---|---|
void |
addCertificate |
Deprecated, for removal: This API element is subject to removal in a future version. Adds a certificate for this Identity . |
Certificate[] |
certificates() |
Deprecated, for removal: This API element is subject to removal in a future version. Returns a copy of all the certificates for this Identity . |
final boolean |
equals |
Deprecated, for removal: This API element is subject to removal in a future version. Tests for equality between the specified object and this Identity . |
String |
getInfo() |
Deprecated, for removal: This API element is subject to removal in a future version. Returns general information previously specified for this Identity . |
final String |
getName() |
Deprecated, for removal: This API element is subject to removal in a future version. Returns this identity's name. |
PublicKey |
getPublicKey() |
Deprecated, for removal: This API element is subject to removal in a future version. Returns this identity's public key. |
final IdentityScope |
getScope() |
Deprecated, for removal: This API element is subject to removal in a future version. Returns this identity's scope. |
int |
hashCode() |
Deprecated, for removal: This API element is subject to removal in a future version. Returns a hashcode for this Identity . |
protected boolean |
identityEquals |
Deprecated, for removal: This API element is subject to removal in a future version. Tests for equality between the specified Identity and this Identity . |
void |
removeCertificate |
Deprecated, for removal: This API element is subject to removal in a future version. Removes a certificate from this Identity . |
void |
setInfo |
Deprecated, for removal: This API element is subject to removal in a future version. Specifies a general information string for this Identity . |
void |
setPublicKey |
Deprecated, for removal: This API element is subject to removal in a future version. Sets this identity's public key. |
String |
toString() |
Deprecated, for removal: This API element is subject to removal in a future version. Returns a short string describing this Identity , telling its name and its scope (if any). |
String |
toString |
Deprecated, for removal: This API element is subject to removal in a future version. Returns a string representation of this Identity , with optionally more details than that provided by the toString method without any arguments. |
protected Identity()
public Identity(String name, IdentityScope scope) throws KeyManagementException
Identity
with the specified name and scope.name
- the Identity
name.scope
- the scope of the Identity
.KeyManagementException
- if there is already an Identity
with the same name in the scope.public Identity(String name)
Identity
with the specified name and no scope.name
- the identity name.public final String getName()
public final IdentityScope getScope()
Identity
.public PublicKey getPublicKey()
Identity
.public void setPublicKey(PublicKey key) throws KeyManagementException
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.
key
- the public key for this Identity
.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.public void setInfo(String info)
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.
info
- the information string.SecurityException
- if a security manager exists and its checkSecurityAccess
method doesn't allow setting the information string.public String getInfo()
Identity
.Identity
.public void addCertificate(Certificate certificate) throws KeyManagementException
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.
certificate
- the certificate to be added.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.public void removeCertificate(Certificate certificate) throws KeyManagementException
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.
certificate
- the certificate to be removed.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.public Certificate[] certificates()
Identity
.Identity
.public final boolean equals(Object identity)
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.protected boolean identityEquals(Identity identity)
Identity
and this Identity
. This method should be overridden by subclasses to test for equality. The default behavior is to return true
if the names and public keys are equal.identity
- the identity to test for equality with this identity
.true
if the identities are considered equal, false
otherwise.public String toString()
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.
toString
in interface Principal
toString
in class Object
Identity
, such as its name and the name of its scope (if any).SecurityException
- if a security manager exists and its checkSecurityAccess
method doesn't allow returning a string describing this Identity
.public String toString(boolean detailed)
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.
detailed
- whether or not to provide detailed information.Identity
. If detailed
is true
, then this method returns more information than that provided by the toString
method without any arguments.SecurityException
- if a security manager exists and its checkSecurityAccess
method doesn't allow returning a string describing this Identity
.public int hashCode()
Identity
.
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/security/Identity.html
java.security.KeyStore
, thejava.security.cert
package, andjava.security.Principal
.