public abstract class Identity
extends Object implements Principal, Serializable
| java.lang.Object | |
| java.security.Identity | |
| |
此类已在API级别1中弃用。
这个类不再使用。 它的功能已经被替换为java.security.KeyStore ,该java.security.cert包, java.security.Principal 。
这个类表示身份:真实世界的对象,如人员,公司或组织,其身份可以使用公钥进行身份验证。 身份也可能是更抽象的(或具体的)结构,例如守护线程或智能卡。
所有Identity对象都有一个名称和一个公钥。 名字是不可变的。 身份也可能是有限的。 也就是说,如果Identity被指定为具有特定范围,那么Identity的名称和公钥在该范围内是唯一的。
一个身份证也有一套证书(全部证明自己的公钥)。 这些证书中指定的主体名称不必相同,只能是密钥。
身份可以分类,包括邮政地址和电子邮件地址,电话号码,脸部图像和徽标等。
也可以看看:
Public constructors |
|
|---|---|
Identity(String name, IdentityScope scope) 用指定的名称和范围构造标识。 |
|
Identity(String name) 使用指定的名称和范围构造一个标识。 |
|
Protected constructors |
|
|---|---|
Identity() 仅用于序列化的构造函数。 |
|
公共方法(Public methods) |
|
|---|---|
void |
addCertificate(Certificate certificate) 为此标识添加证书。 |
Certificate[] |
certificates() 返回此标识的所有证书的副本。 |
final boolean |
equals(Object identity) 测试指定对象和此标识之间的相等性。 |
String |
getInfo() 返回之前为此标识指定的一般信息。 |
final String |
getName() 返回此身份的名称。 |
PublicKey |
getPublicKey() 返回此身份的公钥。 |
final IdentityScope |
getScope() 返回此标识的范围。 |
int |
hashCode() 返回此标识的哈希码。 |
void |
removeCertificate(Certificate certificate) 从此身份中移除证书。 |
void |
setInfo(String info) 为此标识指定一个通用信息字符串。 |
void |
setPublicKey(PublicKey key) 设置此身份的公钥。 |
String |
toString() 返回描述此标识的短字符串,告诉其名称及其范围(如果有)。 |
String |
toString(boolean detailed) 返回此标识的字符串表示形式,可选的详细信息比没有任何参数的 |
Protected methods |
|
|---|---|
boolean |
identityEquals(Identity identity) 测试指定的身份和此身份之间的平等。 |
继承方法(Inherited methods) |
|
|---|---|
java.lang.Object
|
|
java.security.Principal
|
|
Identity (String name, IdentityScope 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 (String name)
使用指定的名称和范围构造一个标识。
| 参数(Parameters) | |
|---|---|
name |
String: the identity name. |
void addCertificate (Certificate certificate)
为此标识添加证书。 如果身份拥有公钥,则证书中的公钥必须相同,如果身份没有公钥,则身份的公钥将被设置为在证书中指定的公钥。
首先,如果存在安全管理器, checkSecurityAccess "addIdentityCertificate"作为参数调用其 checkSecurityAccess方法,以查看是否可以添加证书。
| 参数(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. |
也可以看看:
Certificate[] certificates ()
返回此标识的所有证书的副本。
| 返回(Returns) | |
|---|---|
Certificate[] |
a copy of all the certificates for this identity. |
boolean equals (Object identity)
测试指定对象和此标识之间的相等性。 这首先测试以查看实体是否实际引用同一个对象,在这种情况下它将返回true。 接下来,它检查实体是否具有相同的名称和相同的范围。 如果他们这样做,该方法返回true。 否则,它会调用identityEquals ,该子类应该覆盖。
| 参数(Parameters) | |
|---|---|
identity |
Object: the object to test for equality with this identity. |
| 返回(Returns) | |
|---|---|
boolean |
true if the objects are considered equal, false otherwise. |
也可以看看:
String getInfo ()
返回之前为此标识指定的一般信息。
| 返回(Returns) | |
|---|---|
String |
general information about this identity. |
也可以看看:
String getName ()
返回此身份的名称。
| 返回(Returns) | |
|---|---|
String |
the name of this identity. |
PublicKey getPublicKey ()
返回此身份的公钥。
| 返回(Returns) | |
|---|---|
PublicKey |
the public key for this identity. |
也可以看看:
IdentityScope getScope ()
返回此标识的范围。
| 返回(Returns) | |
|---|---|
IdentityScope |
the scope of this identity. |
int hashCode ()
返回此标识的哈希码。
| 返回(Returns) | |
|---|---|
int |
a hashcode for this identity. |
void removeCertificate (Certificate certificate)
从此身份中移除证书。
首先,如果存在安全管理器, checkSecurityAccess "removeIdentityCertificate"作为参数调用其 checkSecurityAccess方法,以查看是否可以删除证书。
| 参数(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. |
也可以看看:
void setInfo (String info)
为此标识指定一个通用信息字符串。
首先,如果存在安全管理器, checkSecurityAccess "setIdentityInfo"作为参数调用其 checkSecurityAccess方法,以查看是否可以指定信息字符串。
| 参数(Parameters) | |
|---|---|
info |
String: the information string. |
| 抛出异常(Throws) | |
|---|---|
SecurityException |
if a security manager exists and its checkSecurityAccess method doesn't allow setting the information string. |
void setPublicKey (PublicKey key)
设置此身份的公钥。 此操作将删除旧密钥和所有此身份证书。
首先,如果有安全管理器, checkSecurityAccess "setIdentityPublicKey"作为参数调用其 checkSecurityAccess方法,以查看是否可以设置公钥。
| 参数(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. |
String toString ()
返回描述此标识的短字符串,告诉其名称及其范围(如果有)。
首先,如果存在安全管理器,则使用 "printIdentity"作为参数调用其 checkSecurityAccess方法,以查看返回字符串是否 "printIdentity" 。
| 返回(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. |
也可以看看:
String toString (boolean detailed)
返回此标识的字符串表示形式,可选的详细信息比没有任何参数的 toString方法提供的更多。
首先,如果存在安全管理器, checkSecurityAccess "printIdentity"作为参数调用其 checkSecurityAccess方法,以查看是否可以返回该字符串。
| 参数(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. |
boolean identityEquals (Identity identity)
测试指定的身份和此身份之间的平等。 这个方法应该被子类重写以测试相等性。 默认行为是如果名称和公钥相等,则返回true。
| 参数(Parameters) | |
|---|---|
identity |
Identity: the identity to test for equality with this identity. |
| 返回(Returns) | |
|---|---|
boolean |
true if the identities are considered equal, false otherwise. |
也可以看看: