如何更改签名ID?

How to change the signature ID?

如何通过"SigFrs"更改签名ID "xmldsig-e8129bc4-957f-4e9c-b8dc-d0a3482bb97b"?

<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="xmldsig-e8129bc4-957f-4e9c-b8dc-d0a3482bb97b">

这是我的代码:

      XadesSigningProfile p = new XadesBesSigningProfile(kp);
      XadesSigner signer    = p.newSigner();        
      javax.xml.parsers.DocumentBuilderFactory factory = javax.xml.parsers.DocumentBuilderFactory.newInstance();
      factory.setNamespaceAware(true);
      javax.xml.parsers.DocumentBuilder builder = null;
      builder = factory.newDocumentBuilder();


      // XML FILE TO BE SIGNED
      Document doc1 = builder.parse(new File("FileNotSigned.xml"));


      // OBJ
      IndividualDataObjsTimeStampProperty dataObjsTimeStamp = new IndividualDataObjsTimeStampProperty();
      AllDataObjsCommitmentTypeProperty globalCommitment    = AllDataObjsCommitmentTypeProperty.proofOfApproval();
      CommitmentTypeProperty commitment                     = CommitmentTypeProperty.proofOfCreation();   

      // OBJECT
      DataObjectDesc obj1 = new DataObjectReference("");
      obj1.withTransform(XPath2Filter.intersect("InvoiceHeader"));
      SignedDataObjects dataObjs = new SignedDataObjects( obj1 );

      // SIGN
      signer.sign(dataObjs, nodeToAttachSignature);


      // TRANSFORMER
      Transformer transformer = TransformerFactory.newInstance().newTransformer();

      // XML SIGNED       
      Result output = new StreamResult(new File("FileSigned.xml"));
      Source input  = new DOMSource(doc1);
      transformer.transform(input, output);

目前无法更改这些 ID,因为它们是在内部自动生成的,以确保它们是唯一的。

源代码:https://github.com/luisgoncalves/xades4j/blob/master/src/main/java/xades4j/production/SignerBES.java#L154

类似问题:XADES4J - How to change <ds:Object Id="xmldsig-1ddcf1ab-7648-4039-b166-69e14da39982-object0"...> to something other id