public abstract class CertPath extends Object implements Serializable
这是一个抽象类,定义了所有CertPaths方法常见。子类可以处理不同类型的证书(X.509,PGP,等)。
所有的CertPath对象都有类型,Certificates列表,以及一个或多个支持的编码。因为CertPath类是不可变的,一个CertPath无法改变任何外部可见的方式建成后。这一规定适用于所有公共字段和方法这一类的任何增加或由子类重写。
该类型是String标识证书路径中Certificates类型。每个证书的证书路径cert在certPath,cert.getType().equals(certPath.getType())必须true。
对Certificates列表是一个有序的List零个或多个Certificates。这List和所有的Certificates包含在它必须是不变的。
每个CertPath对象必须支持一个或多个编码,使对象可以转化为一个存储或传输到其他各方的字节数组。优选地,这些编码应该是证据充分的标准(如蛋白# 7)。一个由CertPath支持的编码是默认编码。该编码编码是没有明确要求使用(为getEncoded()方法,例如)。
所有的CertPath对象也Serializable。CertPath对象分解成另一种CertPathRep对象序列化期间。这允许一个CertPath对象被序列化为一个等价的表示无论其底层的实现。
CertPath对象可以创建一个CertificateFactory或者他们可以被其他类返回,如CertPathBuilder。
按照惯例,X.509 CertPaths(包括X509Certificates),是有序的开始和结束的目标证书的颁发证书的信任锚。也就是说,一个证书的发行人是以下一个主题。代表TrustAnchor证书不应包括在认证路径。未经验证的X.509 CertPaths可能不遵循这些约定。PKIX CertPathValidators将检测任何背离本公约,使认证路径无效,扔CertPathValidatorException。
java平台的每种实现都要求支持以下标准CertPath编码:
PKCS7PkiPath并发访问
所有的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 | Constructor and Description |
|---|---|
protected |
CertPath(String type)
创建一个指定类型的
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()
返回此证书路径
Certificates类型。
|
int |
hashCode()
返回此证书路径hashCode。
|
String |
toString()
返回此证书路径的字符串表示形式。
|
protected Object |
writeReplace()
取代
CertPath是一个
CertPathRep对象序列化。
|
protected CertPath(String type)
CertPath。
这个构造函数是保护因为大多数用户应该使用一个CertificateFactory创造CertPaths。
type -在这条
Certificates类型标准名称
public String getType()
Certificates类型(没空)
public abstract Iterator<String> getEncodings()
Iterator通过在
UnsupportedOperationException其
remove方法结果。
Iterator的名称(字符串)
public boolean equals(Object other)
CertPaths相等当且仅当它们的类型都是平等的,他们的证书
Lists(隐含在这些
Lists的
Certificates)都是平等的。一个
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()
Certificates的
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必须一成不变和线程安全。
List
Certificates(可能是空的,但不为空)
protected Object writeReplace() throws ObjectStreamException
CertPath是一个
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.