- 所有超级接口:
-
XMLStructure
代表XML
KeyValue
元素的表示,如W3C XML签名语法和处理推荐标准中定义的。一个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>请参阅W3C推荐标准的第4.5.2.3.1节,了解ECParametersType的定义。
可以通过调用KeyInfoFactory
类的newKeyValue
方法,并传递代表公钥值的PublicKey
来创建KeyValue
实例。以下是从存储在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 Summary
Modifier and TypeFieldDescriptionstatic 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。 -
Method Summary
Methods declared in interface javax.xml.crypto.XMLStructure
isFeatureSupported
-
Field Details
-
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
结构。- 参见:
-
-
Method Details
-
getPublicKey
返回此KeyValue
的公钥。- 返回:
-
此
KeyValue
的公钥 - 抛出:
-
KeyException
- 如果无法将此KeyValue
转换为PublicKey
-