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