- 所有父级接口:
XMLStructure
W3C 对 XML 签名语法和处理的推荐 中定义的 XML
KeyValue
元素的表示。 KeyValue
对象包含一个公钥,可用于验证签名。 XML 模式定义定义为:
<element name="KeyValue" type="ds:KeyValueType"/> <complexType name="KeyValueType" mixed="true"> <choice> <element ref="ds:DSAKeyValue"/> <element ref="ds:RSAKeyValue"/> <!-- <element ref="dsig11:ECKeyValue"/> --> <!-- ECC keys (XMLDsig 1.1) will use the any element --> <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> <complexType name="ECKeyValueType"> <sequence> <choice> <element name="ECParameters" type="dsig11:ECParametersType" /> <element name="NamedCurve" type="dsig11:NamedCurveType" /> </choice> <element name="PublicKey" type="dsig11:ECPointType" /> </sequence> <attribute name="Id" type="ID" use="optional" /> </complexType> <complexType name="NamedCurveType"> <attribute name="URI" type="anyURI" use="required" /> </complexType> <simpleType name="ECPointType"> <restriction base="ds:CryptoBinary" /> </simpleType>ECParametersType 的定义参见 W3C Recommendation 的 4.5.2.3.1 节。
KeyValue
实例可以通过调用 KeyInfoFactory
类的 newKeyValue
方法创建,并向其传递一个代表公钥值的 PublicKey
。以下是从存储在 KeyStore
中的 Certificate
的 DSAPublicKey
创建 KeyValue
的示例:
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); PublicKey dsaPublicKey = keyStore.getCertificate("myDSASigningCert").getPublicKey(); KeyInfoFactory factory = KeyInfoFactory.getInstance("DOM"); KeyValue keyValue = factory.newKeyValue(dsaPublicKey);此类返回
DSAKeyValue
和 RSAKeyValue
元素,分别作为 DSAPublicKey
和 RSAPublicKey
类型的对象。请注意,并非模式中的所有字段都可以作为这些类型的参数访问。
- 自从:
- 1.6
- 参见:
-
字段摘要
字段修饰符和类型Field描述static final String
标识 DSA KeyValue KeyInfo 类型的 URI:http://www.w3.org/2000/09/xmldsig#DSAKeyValue。static final String
标识 EC KeyValue KeyInfo 类型的 URI:http://www.w3.org/2009/xmldsig11#ECKeyValue。static final String
标识 RSA KeyValue KeyInfo 类型的 URI:http://www.w3.org/2000/09/xmldsig#RSAKeyValue。 -
方法总结
在接口 javax.xml.crypto.XMLStructure 中声明的方法
isFeatureSupported
-
字段详细信息
-
DSA_TYPE
标识 DSA KeyValue KeyInfo 类型的 URI:http://www.w3.org/2000/09/xmldsig#DSAKeyValue。这可以指定为RetrievalMethod
类的type
参数的值来描述远程DSAKeyValue
结构。- 参见:
-
RSA_TYPE
标识 RSA KeyValue KeyInfo 类型的 URI:http://www.w3.org/2000/09/xmldsig#RSAKeyValue。这可以指定为RetrievalMethod
类的type
参数的值来描述远程RSAKeyValue
结构。- 参见:
-
EC_TYPE
标识 EC KeyValue KeyInfo 类型的 URI:http://www.w3.org/2009/xmldsig11#ECKeyValue。这可以指定为RetrievalMethod
类的type
参数的值来描述远程ECKeyValue
结构。- 参见:
-
-
方法详情
-
getPublicKey
返回此KeyValue
的公钥。- 返回:
-
这个
KeyValue
的公钥 - 抛出:
KeyException
- 如果此KeyValue
无法转换为PublicKey
-