2017-10-10 15 views
0

私たちのXMLのうちの1つは将来的に署名ブロックを持つ予定です。XSDに署名要素の定義を追加する方法

私はそれの定義をどこのXSDファイルに入れるべきかわかりません。

私は(<xs:schem>を閉じる前に)最後に次を入れてみました:私は、次のしているスキーマタグで

<element name="Signature" type="ds:SignatureType"/> 
<complexType name="SignatureType"> 
    <sequence> 
     <element ref="ds:SignedInfo"/> 
     <element ref="ds:SignatureValue"/> 
    </sequence> 
    <attribute name="Id" type="ID" use="optional"/> 
</complexType> 

<element name="SignatureValue" type="ds:SignatureValueType"/> 
<complexType name="SignatureValueType"> 
    <simpleContent> 
     <extension base="base64Binary"> 
      <attribute name="Id" type="ID" use="optional"/> 
     </extension> 
    </simpleContent> 
</complexType> 

<element name="SignedInfo" type="ds:SignedInfoType"/> 
<complexType name="SignedInfoType"> 
    <sequence> 
     <element ref="ds:CanonicalizationMethod"/> 
     <element ref="ds:SignatureMethod"/> 
     <element ref="ds:Reference" maxOccurs="unbounded"/> 
    </sequence> 
    <attribute name="Id" type="ID" use="optional"/> 
</complexType> 

<element name="CanonicalizationMethod" type="ds:CanonicalizationMethodType"/> 
<complexType name="CanonicalizationMethodType" mixed="true"> 
    <sequence> 
     <any namespace="##any" minOccurs="0" maxOccurs="unbounded"/> 
     <!-- (0,unbounded) elements from (1,1) namespace --> 
    </sequence> 
    <attribute name="Algorithm" type="anyURI" use="required"/> 
</complexType> 

<element name="SignatureMethod" type="ds:SignatureMethodType"/> 
<complexType name="SignatureMethodType" mixed="true"> 
    <sequence> 
     <element name="HMACOutputLength" minOccurs="0" 
      type="ds:HMACOutputLengthType"/> 
      <any namespace="##other" minOccurs="0" maxOccurs="unbounded"/> 
     <!-- (0,unbounded) elements from (1,1) external namespace --> 
     </sequence> 
    <attribute name="Algorithm" type="anyURI" use="required"/> 
</complexType> 

<element name="Reference" type="ds:ReferenceType"/> 
<complexType name="ReferenceType"> 
    <sequence> 
     <element ref="ds:Transforms" minOccurs="0"/> 
     <element ref="ds:DigestMethod"/> 
     <element ref="ds:DigestValue"/> 
    </sequence> 
    <attribute name="Id" type="ID" use="optional"/> 
    <attribute name="URI" type="anyURI" use="optional"/> 
    <attribute name="Type" type="anyURI" use="optional"/> 
</complexType> 

<element name="Transforms" type="ds:TransformsType"/> 
<complexType name="TransformsType"> 
    <sequence> 
     <element ref="ds:Transform" maxOccurs="unbounded"/> 
    </sequence> 
</complexType> 

<element name="Transform" type="ds:TransformType"/> 
<complexType name="TransformType" mixed="true"> 
    <choice minOccurs="0" maxOccurs="unbounded"> 
     <any namespace="##other" processContents="lax"/> 
     <!-- (1,1) elements from (0,unbounded) namespaces --> 
     <element name="XPath" type="string"/> 
    </choice> 
    <attribute name="Algorithm" type="anyURI" use="required"/> 
</complexType> 

<element name="DigestMethod" type="ds:DigestMethodType"/> 
<complexType name="DigestMethodType" mixed="true"> 
    <sequence> 
     <any namespace="##other" processContents="lax" 
      minOccurs="0" maxOccurs="unbounded"/> 
    </sequence>  
    <attribute name="Algorithm" type="anyURI" use="required"/> 
</complexType> 

<element name="DigestValue" type="ds:DigestValueType"/> 
    <simpleType name="DigestValueType"> 
    <restriction base="base64Binary"/> 
</simpleType> 

<xs:schema xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" 
      xmlns:xs="http://www.w3.org/2001/XMLSchema" 
      xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> 

W3Cのチェッカーが私に語っあります名前空間に関するいくつかの問題。しかし、私は、XMLでの署名の一部は、私が追加する必要がありますどのような変更(右ルートノードを閉じる前に)次

<Signature xmlns="http://www.w3.org/2000/09/xmldsig#"> 
<SignedInfo> 
    <CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" /> 
    <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" /> 
    <Reference URI=""> 
    <Transforms> 
     <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" /> 
    </Transforms> 
    <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /> 
    <DigestValue>[the digest value]</DigestValue> 
    </Reference> 
</SignedInfo> 
<SignatureValue>[the generated signature]</SignatureValue> 
</Signature> 

ように見えるため、XSD

についての知識の私の不足のためにここに迷ってしまいました自分のXSDに署名ブロックを持つXMLがXSDに対して真正であることを検証するようにしますか?

+1

から全体の定義を貼り付けコピーします。表示される名前空間宣言は、表示するスキーマフラグメントの名前空間の使用法とよく一致しません。つまり、XML名前空間に関するチュートリアルやその動作方法を読む必要があるかもしれません。がんばろう! –

+0

ありがとう!ネームスペースの基本的な理解で、私は有効なXSDを作成することができました(下記の私の答えを見てください) – Woncker

答えて

0

"xs" -namespaceを署名定義のすべての要素と型に追加し、すべての要素と型から "ds" -namespaceを削除して有効なXSDを作成しました。

私は&はあなたがXSDにいくつかの入門チュートリアルを読んで数時間を過ごす場合は、おそらくより多くの成功を持っていますhttps://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd

関連する問題