次のステートメントに従って、xades4j でエンベロープ署名を作成しています。
Element elemToSign = doc.getDocumentElement();
XadesSigner signer = new XadesTSigningProfile(...).newSigner();
new Enveloped(signer).sign(elemToSign);
しかし、署名には ProofOfApprova などの他のプロパティも含める必要があります...
xades4j の例では、さまざまな署名ステートメントを使用して、proofOfApprovalProperties がエンベロープ署名に追加されていることがわかります。次に例を示します。
AllDataObjsCommitmentTypeProperty globalCommitment = AllDataObjsCommitmentTypeProperty.proofOfApproval();
CommitmentTypeProperty commitment = CommitmentTypeProperty.proofOfCreation();
DataObjectDesc obj1 = new DataObjectReference('#' + elemToSign.getAttribute("Id"))
.withTransform(new EnvelopedSignatureTransform())
.withDataObjectFormat(new DataObjectFormatProperty("text/xml", "MyEncoding")
.withDescription("Isto é uma descrição do elemento raiz")
.withDocumentationUri("http://doc1.txt")
.withDocumentationUri("http://doc2.txt"))
.withIdentifier("http://elem.root"))
.withCommitmentType(commitment)
.withDataObjectTimeStamp(dataObjsTimeStamp)
SignedDataObjects dataObjs = new SignedDataObjects(obj1)
.withCommitmentType(globalCommitment);
signer.sign(dataObjs, elemToSign);
ここでは、署名の別の手順が使用されていることがわかります。より具体的には、ルートタグに「Id」属性を使用するという DataObjectreference を作成するステートメントは、入力ではあらゆる種類の xml ドキュメントを持つことができ、できないため、使用できませんルートタグを定義するために使用できる属性の種類(存在する場合)を知っています。
簡単に言えば、Enveloped 署名を作成し、"new Enveloped(signer).sign(elemToSign);" を使用して、またはとにかく xml ソース構造を知らずに、proofOfApproval プロパティを配置するサンプル コードを用意できますか?
ありがとう
M.