JavaTM 2 Platform
Standard Ed. 6

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

所有超级接口:
XMLStructure

public interface KeyValue
extends XMLStructure

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

    <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
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

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

另请参见:
常量字段值

RSA_TYPE

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

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

getPublicKey

PublicKey getPublicKey()
                       throws KeyException
返回此 KeyValue 的公钥。

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

JavaTM 2 Platform
Standard Ed. 6

提交错误或意见

版权所有 2008 Sun Microsystems, Inc. 保留所有权利。请遵守GNU General Public License, version 2 only