public abstract class CertPath
extends Object implements Serializable
| java.lang.Object | |
| java.security.cert.CertPath | |
一个不可变的证书序列(证书路径)。
这是一个抽象类,它定义了所有CertPath的方法。 子类可以处理不同种类的证书(X.509,PGP等)。
所有CertPath对象都有一个类型,一个Certificate的列表以及一个或多个支持的编码。 因为CertPath类是不可变的, CertPath在构建之后不能以任何外部可见的方式进行更改。 本规定适用于该类的所有公共字段和方法以及任何由子类添加或覆盖的内容。
该类型是String ,用于标识认证路径中的Certificate的类型。 对于每个证书cert证书路径certPath , cert.getType().equals(certPath.getType())必须是true 。
Certificate的列表是List个零个或更多的Certificate s。 这List和Certificate包含的所有Certificate必须是不可变的。
每个CertPath对象必须支持一个或多个编码,以便该对象可以转换为字节数组以便存储或传输给其他方。 优选地,这些编码应该有完整的文档标准(例如PKCS#7)。 其中一个CertPath支持的编码被认为是默认编码。 如果没有明确请求编码,则使用此编码(例如,对于getEncoded()方法)。
所有CertPath对象也是Serializable 。 CertPath对象在序列化过程中被解析为另一个CertPathRep对象。 这允许CertPath对象被序列化为等价的表示,而不管其基础实现如何。
CertPath对象可以用 CertificateFactory创建,或者可以由其他类返回,如 CertPathBuilder 。
按照惯例,X.509 CertPath (由X509Certificate组成)按照目标证书开始排序,并以信任锚点发布的证书结束。 也就是说,一个证书的签发人是下一个证书的主体。 代表TrustAnchor的证书不应包含在证书路径中。 未经验证的X.509 CertPath可能不遵循这些约定。 PKIX CertPathValidator会检测到这些公约的任何偏离,导致认证路径失效并抛出CertPathValidatorException 。
Java平台的每个实现都需要支持以下标准 CertPath编码:
并发访问
所有CertPath对象都必须是线程安全的。 也就是说,多个线程可以并发调用这个类中定义的单一的方法CertPath没有坏的影响的对象(或多于一个)。 对于由List返回的CertPath.getCertificates也是如此。
要求CertPath对象是不可变的并且是线程安全的,这使得它们可以传递给各种代码,而不用担心协调访问。 提供这种线程安全性通常并不困难,因为有问题的CertPath和List对象是不可变的。
Nested classes |
|
|---|---|
class |
CertPath.CertPathRep 替代 |
Protected constructors |
|
|---|---|
CertPath(String type) 创建指定类型的 |
|
公共方法(Public methods) |
|
|---|---|
boolean |
equals(Object other) 将该认证路径与指定对象进行比较来进行比较。 |
abstract List<? extends Certificate> |
getCertificates() 返回此认证路径中的证书列表。 |
abstract byte[] |
getEncoded(String encoding) 使用指定的编码返回此认证路径的编码形式。 |
abstract byte[] |
getEncoded() 使用默认编码返回此认证路径的编码形式。 |
abstract Iterator<String> |
getEncodings() 返回此认证路径所支持的编码的迭代,首先使用默认编码。 |
String |
getType() 返回此证书路径中的 |
int |
hashCode() 返回此认证路径的哈希码。 |
String |
toString() 返回此认证路径的字符串表示形式。 |
Protected methods |
|
|---|---|
Object |
writeReplace() 替换 |
继承方法(Inherited methods) |
|
|---|---|
java.lang.Object
|
|
CertPath (String type)
创建指定类型的 CertPath 。
这个构造函数受到保护,因为大多数用户应该使用 CertificateFactory来创建 CertPath 。
| 参数(Parameters) | |
|---|---|
type |
String: the standard name of the type of Certificates in this path |
boolean equals (Object other)
将该认证路径与指定对象进行比较来进行比较。 两个CertPath当且仅当它们的类型相等并且它们的证书List s(并且暗示Certificate s中的List s)是相等的。 CertPath永远不等于不是CertPath的对象。
该算法通过这种方法实现。 如果被覆盖,则必须保持此处指定的行为。
| 参数(Parameters) | |
|---|---|
other |
Object: the object to test for equality with this certification path |
| 返回(Returns) | |
|---|---|
boolean |
true if the specified object is equal to this certification path, false otherwise |
List<? extends Certificate> getCertificates ()
返回此认证路径中的证书列表。 返回的List必须是不可变且线程安全的。
| 返回(Returns) | |
|---|---|
List<? extends Certificate> |
an immutable List of Certificates (may be empty, but not null) |
byte[] getEncoded (String encoding)
使用指定的编码返回此认证路径的编码形式。
| 参数(Parameters) | |
|---|---|
encoding |
String: the name of the encoding to use |
| 返回(Returns) | |
|---|---|
byte[] |
the encoded bytes |
| 抛出异常(Throws) | |
|---|---|
CertificateEncodingException |
if an encoding error occurs or the encoding requested is not supported |
byte[] getEncoded ()
使用默认编码返回此认证路径的编码形式。
| 返回(Returns) | |
|---|---|
byte[] |
the encoded bytes |
| 抛出异常(Throws) | |
|---|---|
CertificateEncodingException |
if an encoding error occurs |
Iterator<String> getEncodings ()
返回此认证路径所支持的编码的迭代,首先使用默认编码。 试图通过其remove方法修改返回的Iterator导致UnsupportedOperationException 。
| 返回(Returns) | |
|---|---|
Iterator<String> |
an Iterator over the names of the supported encodings (as Strings) |
String getType ()
返回此证书路径中的Certificate的类型。 这是认证路径中所有Certificate将由cert.getType()返回的相同字符串。
| 返回(Returns) | |
|---|---|
String |
the type of Certificates in this certification path (never null) |
int hashCode ()
返回此认证路径的哈希码。 认证路径的哈希码被定义为以下计算的结果:
hashCode = path.getType().hashCode();
hashCode = 31*hashCode + path.getCertificates().hashCode();
This ensures that
path1.equals(path2) implies that
path1.hashCode()==path2.hashCode() for any two certification paths,
path1 and
path2, as required by the general contract of
Object.hashCode.
| 返回(Returns) | |
|---|---|
int |
the hashcode value for this certification path |
String toString ()
返回此认证路径的字符串表示形式。 这将调用toString在每个方法Certificate S IN的路径。
| 返回(Returns) | |
|---|---|
String |
a string representation of this certification path |
Object writeReplace ()
替换 CertPath以与 CertPathRep对象进行序列化。
| 返回(Returns) | |
|---|---|
Object |
the CertPathRep to be serialized |
| 抛出异常(Throws) | |
|---|---|
ObjectStreamException |
if a CertPathRep object representing this certification path could not be created |