|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectjava.security.cert.CertPath
public abstract class CertPath
不可变的证书序列(证书路径)。
这是一个抽象类,定义了常用于所有 CertPath 的方法。其子类可处理不同类型的证书(X.509、PGP 等等)。
所有 CertPath 对象都包含类型、Certificate 列表及其支持的一种或多种编码。由于 CertPath 类是不可变的,所以构造 CertPath 后无法以任何外部可见的方式更改它。此规定适用于此类的所有公共字段和方法,以及由子类添加或重写的所有公共字段和方法。
类型是标识证书路径中 Certificate 类型的一个 String。对于证书路径 certPath 中的每个证书 cert 而言,cert.getType().equals(certPath.getType()) 必须为 true。
Certificate 列表是零个或多个 Certificate 的有序 List。此 List 和其中所包含的所有 Certificate 都必须是不可变的。
每个 CertPath 对象必须支持一种或多种编码方式,这样可将对象转换成 byte 数组进行存储,或传输给其他方。这些编码最好应该具有记录良好的标准(例如 PKCS#7)。将 CertPath 支持的某种编码视为默认编码。如果没有显式地请求编码(例如,getEncoded() 方法),则使用此编码。
所有 CertPath 对象都是 Serializable。在序列化期间将 CertPath 对象解析为一个替换的 CertPathRep 对象。这就允许不管 CertPath 对象的基础实现如何,都可以将该对象序列化为等效的表示形式。
可使用 CertificateFactory 创建 CertPath 对象,或者可通过其他类(如 CertPathBuilder)返回这些对象。
按照惯例,X.509 CertPath(由 X509Certificate 组成)的顺序按照从目标证书开始,从信任的定位点所发布的证书结束。也就是说,证书的发布方是以下某个主体。表示 TrustAnchor 的证书不应包括在证书路径中。未验证的 X.509 CertPath 可能不遵循这些约定。PKIX CertPathValidator 将检测任何与这些约定的偏差,这些偏差会导致证书路径无效并且抛出 CertPathValidatorException。
并发访问
所有 CertPath 对象必须是线程安全的。也就是说,多个线程在单个 CertPath 对象(或多个对象)上并发调用此类中所定义的各种方法不会产生坏的影响。对于 CertPath.getCertificates 返回的 List 也应如此。
要求 CertPath 对象是不可变的并且是线程安全的,就允许将其传递到各种代码片断中,而无需担心协调访问。通常提供此种线程安全性并不难,因为相关的 CertPath 和 List 对象都是不可变的。
CertificateFactory,
CertPathBuilder,
序列化表格| 嵌套类摘要 | |
|---|---|
protected static class |
CertPath.CertPathRep
用于序列化的替换 CertPath 类。 |
| 构造方法摘要 | |
|---|---|
protected |
CertPath(String type)
创建指定类型的 CertPath。 |
| 方法摘要 | |
|---|---|
boolean |
equals(Object other)
比较此证书路径与指定对象的相等性。 |
abstract List<? extends Certificate> |
getCertificates()
返回此证书路径中的证书列表。 |
abstract byte[] |
getEncoded()
返回此证书路径的编码形式,使用默认的编码。 |
abstract byte[] |
getEncoded(String encoding)
返回此证书路径的编码形式,使用指定的编码。 |
abstract Iterator<String> |
getEncodings()
返回此证书路径支持的编码的迭代,默认编码方式优先。 |
String |
getType()
返回此证书路径中的 Certificate 类型。 |
int |
hashCode()
返回此证书路径的哈希码。 |
String |
toString()
返回此证书路径的字符串表示形式。 |
protected Object |
writeReplace()
使用 CertPathRep 对象替换要被序列化的 CertPath。 |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| 构造方法详细信息 |
|---|
protected CertPath(String type)
CertPath。
此构造方法是受保护的,因为大多数用户应该使用 CertificateFactory 来创建 CertPath。
type - 此路径中 Certificate 类型的标准名称| 方法详细信息 |
|---|
public String getType()
Certificate 类型。这与 cert.getType() 为证书路径中的所有 Certificate 所返回的字符串相同。
Certificate 类型(从不为 null)public abstract Iterator<String> getEncodings()
Iterator(通过其 remove 方法)会导致抛出 UnsupportedOperationException。
Iteratorpublic boolean equals(Object other)
CertPath 的类型相等并且其证书 List(通过模拟这些 List 中的 Certificate)相等时,这两个 CertPath 才相等。CertPath 不会等于一个非 CertPath 对象。
此方法实现此种算法。如果重写此方法,则必须维护在此指定的行为。
Object 中的 equalsother - 要与此证书路径进行相等性测试的对象
Object.hashCode(),
Hashtablepublic int hashCode()
hashCode = path.getType().hashCode();
hashCode = 31*hashCode + path.getCertificates().hashCode();
这确保对于任意两个证书路径 path1 和 path2 而言,path1.equals(path2) 就意味着 path1.hashCode()==path2.hashCode(),正如 Object.hashCode 的常规协定所要求的那样。
Object 中的 hashCodeObject.equals(java.lang.Object),
Hashtablepublic String toString()
Certificate 上调用 toString 方法。
Object 中的 toString
public abstract byte[] getEncoded()
throws CertificateEncodingException
CertificateEncodingException - 如果发生编码错误
public abstract byte[] getEncoded(String encoding)
throws CertificateEncodingException
encoding - 要使用的编码名称
CertificateEncodingException - 如果发生编码错误或者编码请求不受支持public abstract List<? extends Certificate> getCertificates()
List 必须是不可变的和线程安全的。
Certificate List(可以为空,但是不能为 null)
protected Object writeReplace()
throws ObjectStreamException
CertPathRep 对象替换要被序列化的 CertPath。
CertPathRep
ObjectStreamException - 如果不能创建表示此证书路径的 CertPathRep 对象
|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策。