2017-10-30 3 views
0

私はXADES-BESとスマートカードを使ってXML文書に署名しようとしています。 私の必要に応じてSignerBES.javaクラスにいくつか変更を加えました。署名の作成はうまくいっています!UnsignedPropertiesを追加するにはどうすればよいですか?

私の質問:

   <SignerRole> 
      <ClaimedRoles> 
      <ClaimedRole>EST</ClaimedRole> 
      </ClaimedRoles> 
     </SignerRole> 
     </SignedSignatureProperties> 
     <SignedDataObjectProperties> 
     <DataObjectFormat ObjectReference="#sigId"> 
      <Description>des</Description> 
      <MimeType>text/xml</MimeType> 
      <Encoding>base64</Encoding> 
     </DataObjectFormat> 
     <CommitmentTypeIndication> 
      <CommitmentTypeId> 
      <Identifier/> 
      </CommitmentTypeId> 
      <AllSignedDataObjects/> 
      <CommitmentTypeQualifiers> 
      <CommitmentTypeQualifier>commitment</CommitmentTypeQualifier> 
      </CommitmentTypeQualifiers> 
     </CommitmentTypeIndication> 
     </SignedDataObjectProperties> 
    </SignedProperties> 
    <UnsignedProperties> 
     <UnsignedSignatureProperties> 
     <SignatureTimeStamp> 
      <EncapsulatedTimeStamp>noTimStampToken</EncapsulatedTimeStamp> 
     </SignatureTimeStamp> 
     <CounterSignature/> 
     <CompleteCertificateRefs/> 
     <CompleteRevocationRefs/> 
     <SigAndRefsTimeStamp/> 
     <RefsOnlyTimeStamp/> 
     <CertificatesValues/> 
     <RevocationValues/> 
     <ArchiveTimeStamp/> 
     </UnsignedSignatureProperties> 
    </UnsignedProperties> 
    </QualifyingProperties> 
</ds:Object> 

これはコードスニペットSignerBES.javaです:

Collection<SignedSignatureProperty> fsssp = new ArrayList<SignedSignatureProperty>(2); 
Collection<UnsignedSignatureProperty> fsusp = new ArrayList<UnsignedSignatureProperty>(2); 


getFormatSpecificSignatureProperties(fsssp, fsusp, signingCertificateChain); 
// Gather all the signature and data objects properties. 
QualifyingProperties qualifProps = qualifPropsProcessor.getQualifyingProperties(
     signedDataObjects, fsssp, fsusp); 

// LOG 
System.out.println("fsusp"+fsusp.size()); 

私が追加しようとしましたどのように私はこのような何かを得るためにUnsignedPropertiesを追加することができますそれはSignerBES.javaとDefaultSignaturePropertiesProvider.javaにありますが、私はそれをどのように追加できるのか分かりません:

public class DefaultSignaturePropertiesProvider implements SignaturePropertiesProvider 
{ 
@Override 
public void provideProperties(SignaturePropertiesCollector signaturePropsCol) 
{ 
signaturePropsCol.setSigningTime(new SigningTimeProperty()); 
signaturePropsCol.setSignerRole(new SignerRoleProperty("EST")); 

// UnsignedProperty 
// OtherUnsignedSignatureProperty otherUnsignedProp=null;  
// signaturePropsCol.addOtherSignatureProperty(otherUnsignedProp); 
}} 

答えて

0

私は完全にあなたが何をしようとしているとは思わない、あなたはlibのソースコードをめちゃくちゃにしているようだから。とにかく、this page on the project docsをチェックしてください。

もし署名プロファイルのいずれかを(あなたがXAdesCSigningProfileを使用する場合、例えば、CompleteCertificateRefs/CompleteRevocationRefsが追加される)を使用する場合、符号なし適格特性がxades4jによって自動的に追加されている多くの。

その他のプロパティは、高度なフォームの一部であり、既存の署名の検証中にのみ追加できます。詳細については、this wiki pageと[this javadocs page](http://luisgoncalves.github.io/xades4j/javadocs/1.4.0/reference/xades4j/verification/XadesVerifier.html#verify(org.w3c.dom.Element、xades4j.verification.SignatureSpecificVerificationOptions、xades4j.production.XadesSignatureFormatExtender、xades4j.verification.XAdESForm)を参照してください。

最後に、いくつかの特性(例えば副署)は、任意の特定の形態に縛られず、使用している署名プロファイルに登録カスタムSignaturePropertiesProviderを使用して、任意の署名に追加することができます。

+0

ありがとうございます。私はスマートカードでサインする初心者です。次のようなものを追加することもできます:signaturePropsCol.addOtherSignatureProperty(otherUnsignedProp) 追加するUnsignedPropertiesがいくつかあり、それらが進められています(私にはわかりません)? ブロックを手動で追加すると、署名チェックが無効になりますか? 。 –

+0

私が応答で言ったように、xades4jを使用すると、リストのように追加することはありません。対応する署名プロファイルを使用すると、特定のフォームの署名されていない署名プロパティが自動的に追加されます。その他の署名されていないプロパティは、カスタムSignaturePropertiesProvider – lgoncalves

関連する問題