如何更改签名ID?

时间:2017-10-18 16:38:35

标签: java xml sign xades4j

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

<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);

1 个答案:

答案 0 :(得分:0)