public interface KeyValue extends XMLStructure
KeyValue
元素的表示 。
KeyValue
对象包含一个单一的公钥,可用于验证签名。
XML模式定义定义为:
<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
方法创建一个KeyValue
实例,并传递一个表示公钥值的PublicKey
。
以下是一个KeyValue
从DSAPublicKey
创建的Certificate
存储在KeyStore
中的示例 :
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
,分别。
请注意,并非模式中的所有字段都可以作为这些类型的参数访问。
KeyInfoFactory.newKeyValue(PublicKey)
Modifier and Type | Field and Description |
---|---|
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。
|
Modifier and Type | Method and Description |
---|---|
PublicKey |
getPublicKey()
返回此
KeyValue 。
|
isFeatureSupported
static final String DSA_TYPE
RetrievalMethod
类的type
参数的值来描述远程DSAKeyValue
结构。
static final String RSA_TYPE
type
参数的RetrievalMethod
类来描述远程RSAKeyValue
结构的值。
PublicKey getPublicKey() throws KeyException
KeyValue
。
KeyValue
KeyException
- 如果这
KeyValue
不能转换为
PublicKey
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.