目录搜索
文字
分享


JavaTM 2 Platform
Standard Ed. 6

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

所有超级接口:
XMLStructure

1

public interface <b>KeyValue</b>

extends XMLStructure

W3C Recommendation for XML-Signature Syntax and Processing 中定义的 XML KeyValue 元素的表示形式。KeyValue 对象包含一个在验证签名时很有用的公钥。XML Schema Definition 的定义如下:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

<element name="KeyValue" type="ds:KeyValueType"/>

<complexType name="KeyValueType" mixed="true">

  <choice>

    <element ref="ds:DSAKeyValue"/>

    <element ref="ds:RSAKeyValue"/>

    <any namespace="##other" processContents="lax"/>

  </choice>

</complexType>

 

<element name="DSAKeyValue" type="ds:DSAKeyValueType"/>

<complexType name="DSAKeyValueType">

  <sequence>

    <sequence minOccurs="0">

      <element name="P" type="ds:CryptoBinary"/>

      <element name="Q" type="ds:CryptoBinary"/>

    </sequence>

    <element name="G" type="ds:CryptoBinary" minOccurs="0"/>

    <element name="Y" type="ds:CryptoBinary"/>

    <element name="J" type="ds:CryptoBinary" minOccurs="0"/>

    <sequence minOccurs="0">

      <element name="Seed" type="ds:CryptoBinary"/>

      <element name="PgenCounter" type="ds:CryptoBinary"/>

    </sequence>

  </sequence>

</complexType>

 

<element name="RSAKeyValue" type="ds:RSAKeyValueType"/>

<complexType name="RSAKeyValueType">

  <sequence>

    <element name="Modulus" type="ds:CryptoBinary"/>

    <element name="Exponent" type="ds:CryptoBinary"/>

  </sequence>

</complexType>

通过调用 KeyInfoFactory 类的 newKeyValue 方法,并向其传递表示公钥值的 PublicKey,可以创建 KeyValue 实例。下面是一个示例,该示例根据 KeyStore 中存储的 CertificateDSAPublicKey 创建了一个 KeyValue

1

2

3

4

KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());

PublicKey dsaPublicKey = keyStore.getCertificate("myDSASigningCert").getPublicKey();

KeyInfoFactory factory = KeyInfoFactory.getInstance("DOM");

KeyValue keyValue = factory.newKeyValue(dsaPublicKey);

此类将分别以类型 DSAPublicKeyRSAPublicKey 对象的形式返回 DSAKeyValueRSAKeyValue 元素。注意,并非模式中的所有字段都可以作为这些类型的参数进行访问。

从以下版本开始:
1.6
另请参见:
KeyInfoFactory.newKeyValue(PublicKey)

字段摘要
static String DSA_TYPE
          标识 DSA KeyValue KeyInfo 类型的 URI:http://www.w3.org/2000/09/xmldsig#DSAKeyValue。
static String RSA_TYPE
          标识 RSA KeyValue KeyInfo 类型的 URI:http://www.w3.org/2000/09/xmldsig#RSAKeyValue。
 
方法摘要
 PublicKey getPublicKey()
          返回此 KeyValue 的公钥。
 
从接口 javax.xml.crypto.XMLStructure 继承的方法
isFeatureSupported
 

字段详细信息

DSA_TYPE

1

static final String <b>DSA_TYPE</b>

标识 DSA KeyValue KeyInfo 类型的 URI:http://www.w3.org/2000/09/xmldsig#DSAKeyValue。可以将其指定为 RetrievalMethod 类的 type 参数值,以描述远程 DSAKeyValue 结构。

另请参见:
常量字段值

RSA_TYPE

1

static final String <b>RSA_TYPE</b>

标识 RSA KeyValue KeyInfo 类型的 URI:http://www.w3.org/2000/09/xmldsig#RSAKeyValue。可以将其指定为 RetrievalMethod 类的 type 参数值,以描述远程 RSAKeyValue 结构。

另请参见:
常量字段值
方法详细信息

getPublicKey

1

2

PublicKey <b>getPublicKey</b>()

                       throws KeyException

返回此 KeyValue 的公钥。

返回:
KeyValue 的公钥
抛出:
KeyException - 如果无法将此 KeyValue 转换为 PublicKey

JavaTM 2 Platform
Standard Ed. 6

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

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

上一篇:下一篇: