「W3C Recommendation for XML-Signature Syntax and Processing」で定義されているXML 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>
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);
このクラスは、型DSAPublicKey
およびRSAPublicKey
のオブジェクトとして、それぞれDSAKeyValue
およびRSAKeyValue
要素を返します。 スキーマ内のすべてのフィールドが、これらの型のパラメータとしてアクセス可能であるわけではありません。