public abstract class CertPath extends Object implements Serializable
这是一个抽象类,它定义了所有CertPath的共同方法。 子类可以处理不同类型的证书(X.509,PGP等)。
所有CertPath对象都有一个类型,一个Certificate的列表,以及一个或多个支持的编码。 由于CertPath类是不可变的,一个CertPath不能任何外部可见的方式被构造后更改英寸 这个规定适用于这个类的所有公共领域和方法,以及任何由子类添加或覆盖的规则。
类型是String标识的类型Certificate S IN的证书路径。 对于每个证书cert证书路径certPath , cert.getType().equals(certPath.getType())必须是true 。
Certificate的列表是订购的List零个或多个Certificate s。 这List和所有的Certificate包含的s必须是不可变的。
每个CertPath对象必须支持一个或多个编码,以便可以将对象转换为字节数组以存储或传输给其他方。 优选地,这些编码应该是有良好记录的标准(例如PKCS#7)。 CertPath支持的编码CertPath被认为是默认编码。 如果没有显式请求编码,则使用此编码(例如,对于getEncoded()方法)。
全部CertPath对象也是Serializable 。 CertPath对象在序列化期间被解析为备用CertPathRep对象。 这样可以将CertPath对象序列化为等效表示,而不管其底层实现。
CertPath对象可以使用CertificateFactory创建,也可以由其他类返回,例如CertPathBuilder 。
根据惯例,X.509 CertPath (由X509Certificate s组成)从目标证书开始排序,并以信任锚发出的证书结束。 也就是说,一个证书的颁发者是下面的一个证书的主题。 代表TrustAnchor的证书不应包含在认证路径中。 未验证的X.509 CertPath可能不遵循这些约定。 PKIX CertPathValidator将检测到这些约定的任何偏离,导致认证路径无效并抛出CertPathValidatorException 。
Java平台的每个实现都需要支持以下标准的CertPath编码:
PKCS7 PkiPath 并发访问
所有CertPath对象必须是线程安全的。 也就是说,多个线程可以在没有不良影响的单个CertPath对象(或多个)上同时调用此类中定义的方法。 对于List返回的CertPath.getCertificates也是如此。
要求CertPath对象是不可变的和线程安全的,可以让它们传递到各种代码段,而不用担心协调访问。 提供这种线程安全性通常并不困难,因为所CertPath和List对象是不可变的。
CertificateFactory , CertPathBuilder , Serialized Form
| Modifier and Type | Class and Description |
|---|---|
protected static class |
CertPath.CertPathRep
候补
CertPath类用于序列化。
|
| Modifier and Type | Method and Description |
|---|---|
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()
替换
CertPath成与被序列
CertPathRep对象。
|
protected CertPath(String type)
CertPath指定类型的。
此构造函数受到保护,因为大多数用户应使用CertificateFactory创建CertPath s。
type - 此路径中
Certificate的类型的标准名称
public String getType()
Certificate的类型。
这是cert.getType()对于认证路径中的所有Certificate都将返回的字符串。
Certificate (从不为null)
public abstract Iterator<String> getEncodings()
remove方法修改返回的Iterator会导致UnsupportedOperationException 。
Iterator的名称(作为字符串)
public boolean equals(Object other)
CertPath s为相等的,当且仅当它们的类型都是平等的,他们的证书List S(和含蓄的Certificate S IN那些List S)是相等的。
A CertPath从不等于不是CertPath的对象。
该算法由该方法实现。 如果被覆盖,则必须维护此处指定的行为。
equals在
Object
other - 测试与此认证路径相等的对象
Object.hashCode() , HashMap
public int hashCode()
hashCode = path.getType().hashCode(); hashCode = 31*hashCode + path.getCertificates().hashCode();
这确保了path1.equals(path2)意味着path1.hashCode()==path2.hashCode()对于任何两个证书路径, path1和path2 ,所要求的的常规协定Object.hashCode 。
hashCode在
Object
Object.equals(java.lang.Object) ,
System.identityHashCode(java.lang.Object)
public String toString()
toString在每个方法Certificate S IN的路径。
public abstract byte[] getEncoded()
throws CertificateEncodingException
CertificateEncodingException - 如果发生编码错误
public abstract byte[] getEncoded(String encoding) throws CertificateEncodingException
encoding - 要使用的编码的名称
CertificateEncodingException - 如果发生编码错误或不支持请求的编码
public abstract List<? extends Certificate> getCertificates()
List必须是不可变的和线程安全的。
List的
Certificate s(可能是空的,但不是null)
protected Object writeReplace() throws ObjectStreamException
CertPath替换为
CertPathRep对象
CertPathRep 。
CertPathRep要序列化
ObjectStreamException - 如果无法创建表示此认证路径的
CertPathRep对象
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.