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 。 
             |  
          
isFeatureSupportedstatic 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.