JavaTM Platform
Standard Ed. 6

javax.xml.crypto.dsig.keyinfo
接口 KeyInfo

所有超级接口:
XMLStructure

public interface KeyInfo
     
extends XMLStructure

W3C Recommendation for XML-Signature Syntax and Processing 中定义的 XML KeyInfo 元素的表示形式。KeyInfo 包含 XMLStructure 的列表,其中每一个 XMLStructure 都包含支持接受方获取验证 XML 签名所需的密钥的信息。XML Schema Definition 的定义如下:

<element name="KeyInfo" type="ds:KeyInfoType"/> 
<complexType name="KeyInfoType" mixed="true">
<choice maxOccurs="unbounded">     
<element ref="ds:KeyName"/> 
<element ref="ds:KeyValue"/> 
<element ref="ds:RetrievalMethod"/>
<element ref="ds:X509Data"/>
<element ref="ds:PGPData"/>
<element ref="ds:SPKIData"/>
<element ref="ds:MgmtData"/>
<any processContents="lax" namespace="##other"/>
<!-- (1,1) elements from (0,unbounded) namespaces -->
</choice>
<attribute name="Id" type="ID" use="optional"/> 
</complexType>
 
通过调用 KeyInfoFactory 类的 newKeyInfo 方法之一,并向其传递一个或多个 XMLStructure 列表以及一个可选的 id 参数,可以创建 KeyInfo 实例,例如:
KeyInfoFactory factory = KeyInfoFactory.getInstance("DOM");
KeyInfo keyInfo = factory.newKeyInfo
        (Collections.singletonList(factory.newKeyName("Alice"), "keyinfo-1"));
 

还可以通过调用 marshal 方法将 KeyInfo 对象编组为 XML。

从以下版本开始:
1.6
另请参见:
KeyInfoFactory.newKeyInfo(List), KeyInfoFactory.newKeyInfo(List, String)

方法摘要
 List getContent()
          返回包含密钥信息的 unmodifiable list
 String getId()
          返回此 KeyInfo 的可选 Id 属性,这对于从其他 XML 结构引用此 KeyInfo 可能很有用。
 void marshal(XMLStructure parent, XMLCryptoContext context)
          将密钥信息编组为 XML。
 
从接口 javax.xml.crypto.XMLStructure 继承的方法
isFeatureSupported
 

方法详细信息

getContent

List getContent()
返回包含密钥信息的 unmodifiable list。列表中的每一项都是一个 XMLStructure

如果有一个表示 XMLStructure 类型的公共子类,那么它将作为该类的实例返回(比如:X509Data 元素将作为 X509Data 的实例返回)。

返回:
KeyInfo 中的一个或多个 XMLStructure 的不可修改列表。不会返回 null 或空列表。

getId

String getId()
返回此 KeyInfo 的可选 Id 属性,这对于从其他 XML 结构引用此 KeyInfo 可能很有用。

返回:
KeyInfo 的 Id 属性(如果未指定,则返回 null

marshal

void marshal(XMLStructure parent,
             XMLCryptoContext context)
             throws MarshalException
将密钥信息编组为 XML。

参数:
parent - 特定于机制的结构,包含将追加已编组密钥信息中的父节点
context - 包含其他上下文的 XMLCryptoContext(如果不适用,则为 null)
抛出:
ClassCastException - 如果 parentcontext 的类型与此密钥信息不兼容
MarshalException - 如果无法编组密钥信息
NullPointerException - 如果 parentnull

JavaTM Platform
Standard Ed. 6

提交错误或意见
有关更多的 API 参考资料和开发人员文档,请参阅 Java SE 开发人员文档。该文档包含更详细的、面向开发人员的描述,以及总体概述、术语定义、使用技巧和工作代码示例。

版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策