java.security.KeyStore
,java.security.cert
包,和java.security.Principal
。
@Deprecated public abstract class Identity extends Object implements Principal, Serializable
这个类代表身份:真实世界的对象,如人,公司或组织的身份可以通过他们的公共密钥进行身份验证。身份也可能是更抽象的(或混凝土)结构,如守护线程或智能卡。
所有的标识对象都有一个名称和一个公钥。名字是不可变的。身份也可能范围。也就是说,如果指定了一个身份有特定的范围,那么在该范围内的身份的名称和公钥是唯一的。
身份也有一组证书(所有证明其自己的公共密钥)。在这些证书中指定的主要名称不必是相同的,只有键。
一个身份可以定义,包括邮政地址、电子邮件地址、电话号码、面孔和徽标图像,等等。
IdentityScope
,
Signer
,
Principal
,
Serialized Form
Modifier | Constructor and Description |
---|---|
protected |
Identity()
过时的。
仅用于序列化的构造函数。
|
|
Identity(String name)
过时的。
用指定的名称和无作用域构造一个标识。
|
|
Identity(String name, IdentityScope scope)
过时的。
用指定的名称和范围构造一个标识。
|
Modifier and Type | Method and Description |
---|---|
void |
addCertificate(Certificate certificate)
过时的。
为这个身份添加一个证书。
|
Certificate[] |
certificates()
过时的。
返回此身份的所有证书的副本。
|
boolean |
equals(Object identity)
过时的。
指定对象和此标识之间的相等性的测试。
|
String |
getInfo()
过时的。
返回先前指定的此标识的一般信息。
|
String |
getName()
过时的。
返回此身份的名称。
|
PublicKey |
getPublicKey()
过时的。
返回此身份的公钥。
|
IdentityScope |
getScope()
过时的。
返回此标识的范围。
|
int |
hashCode()
过时的。
返回该身份的hashCode。
|
protected boolean |
identityEquals(Identity identity)
过时的。
指定的身份和该身份之间的平等性的测试。
|
void |
removeCertificate(Certificate certificate)
过时的。
从这个身份中移除一个证书。
|
void |
setInfo(String info)
过时的。
指定此标识的通用信息字符串。
|
void |
setPublicKey(PublicKey key)
过时的。
设置此身份的公共密钥。
|
String |
toString()
过时的。
返回一个简短的字符串来描述这个身份,告诉它的名称和它的范围(如果有的话)。
|
String |
toString(boolean detailed)
过时的。
返回该身份的字符串表示,随着更多的细节比随意的
toString 方法提供不带任何参数。
|
protected Identity()
public Identity(String name, IdentityScope scope) throws KeyManagementException
name
-标识名称。
scope
-身份的范围。
KeyManagementException
如果范围中具有相同名称的身份已经有了。
public Identity(String name)
name
-标识名称。
public final IdentityScope getScope()
public PublicKey getPublicKey()
setPublicKey(java.security.PublicKey)
public void setPublicKey(PublicKey key) throws KeyManagementException
首先,如果存在安全管理器,它的checkSecurityAccess
方法被称为"setIdentityPublicKey"
来看看是否可以设置公钥参数。
key
-这种身份的公钥。
KeyManagementException
-如果在身份范围的另一个身份具有相同的公共密钥,或者如果一个异常发生。
SecurityException
-如果存在一个安全管理及其
checkSecurityAccess
方法不允许设置公钥。
getPublicKey()
,
SecurityManager.checkSecurityAccess(java.lang.String)
public void setInfo(String info)
首先,如果存在安全管理器,它的checkSecurityAccess
方法被称为"setIdentityInfo"
来看看是否可以指定信息的字符串参数。
info
-信息的字符串。
SecurityException
-如果存在一个安全管理及其
checkSecurityAccess
方法不允许设置信息的字符串。
getInfo()
,
SecurityManager.checkSecurityAccess(java.lang.String)
public String getInfo()
setInfo(java.lang.String)
public void addCertificate(Certificate certificate) throws KeyManagementException
首先,如果存在安全管理器,它的checkSecurityAccess
方法被称为"addIdentityCertificate"
来看看是否可以将证书添加参数。
certificate
-证书被添加。
KeyManagementException
-如果证书是无效的,如果在证书中加入冲突,这种身份的公共密钥的公钥,或者另一个例外发生。
SecurityException
-如果存在一个安全管理及其
checkSecurityAccess
方法不允许添加证书。
SecurityManager.checkSecurityAccess(java.lang.String)
public void removeCertificate(Certificate certificate) throws KeyManagementException
首先,如果存在安全管理器,它的checkSecurityAccess
方法被称为"removeIdentityCertificate"
作为是否可以删除证书的说法。
certificate
-证书被删除。
KeyManagementException
-如果证书丢失,或者如果一个异常发生。
SecurityException
-如果存在一个安全管理及其
checkSecurityAccess
方法不允许删除证书。
SecurityManager.checkSecurityAccess(java.lang.String)
public Certificate[] certificates()
public final boolean equals(Object identity)
identityEquals
,这类应重写。
equals
接口
Principal
equals
方法重写,继承类
Object
identity
-与此身份平等的测试对象。
identityEquals(java.security.Identity)
protected boolean identityEquals(Identity identity)
identity
-身份与身份平等的测试。
equals(java.lang.Object)
public String toString()
首先,如果存在安全管理器,它的checkSecurityAccess
方法被称为"printIdentity"
作为是否可以返回字符串参数。
toString
接口
Principal
toString
方法重写,继承类
Object
SecurityException
-如果存在一个安全管理及其
checkSecurityAccess
方法不允许返回一个描述这个身份字符串。
SecurityManager.checkSecurityAccess(java.lang.String)
public String toString(boolean detailed)
toString
方法提供不带任何参数。
首先,如果存在安全管理器,它的checkSecurityAccess
方法被称为"printIdentity"
作为是否可以返回字符串参数。
detailed
-是否提供详细的信息。
detailed
是真的,那么这个方法返回于
toString
方法提供不带任何参数的更多信息。
SecurityException
-如果存在一个安全管理及其
checkSecurityAccess
方法不允许返回一个描述这个身份字符串。
toString()
,
SecurityManager.checkSecurityAccess(java.lang.String)
public int hashCode()
hashCode
接口
Principal
hashCode
方法重写,继承类
Object
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.