Skip to content

Commit

Permalink
Proyecto comentado
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgcastellano committed Aug 28, 2019
1 parent 5ec6f89 commit 09e88e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions xades4j-signer-col/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public SignaturePolicyBase getSignaturePolicy() {
false
);

// SignaturePolicyInfoProvider spi = new
XadesSigningProfile p = new XadesEpesSigningProfile(kp, policyInfoProvider);

// open file
Expand All @@ -72,15 +71,18 @@ public SignaturePolicyBase getSignaturePolicy() {

Document doc = builder.parse(new File(xmlInPath));

// Se establece el punto donde se requiere la firma (segundo elemento ext:ExtensionContent del XML)
// Se establece el punto donde se requiere la firma (segundo elemento ext:ExtensionContent del XML)
NodeList tag = doc.getElementsByTagName("ext:ExtensionContent");
Node elemToSign = tag.item(1); // encuentra el nodo en la lista anterior
DataObjectDesc dataObjRef = new DataObjectReference("").withTransform(new EnvelopedSignatureTransform());//crea un dataobject del xml para firmar

XadesSigner signer = p.newSigner();
// Crea un DataObject del xml para firmar
DataObjectDesc dataObjRef = new DataObjectReference("").withTransform(new EnvelopedSignatureTransform());

// Firmo
XadesSigner signer = p.newSigner();
signer.sign(new SignedDataObjects( dataObjRef ), elemToSign, SignatureAppendingStrategies.AsFirstChild);

// Transformo, creo archivo destino con la firma
Transformer transformer = TransformerFactory.newInstance().newTransformer();
Result output = new StreamResult(xmlOutPath);
Source input = new DOMSource(doc);
Expand Down

0 comments on commit 09e88e9

Please sign in to comment.