Modify gateway class to generate a detached signature for a signed swidtag. Created new unit test and updated test resource files.

This commit is contained in:
chubtub 2023-04-13 00:14:15 -04:00
parent f464519235
commit 681fc92a3c
2 changed files with 3 additions and 12 deletions

View File

@ -656,17 +656,8 @@ public class SwidTagGateway {
}
KeyInfo keyinfo = kiFactory.newKeyInfo(keyInfoElements);
Document detachedSignature = null;
try {
detachedSignature = DocumentBuilderFactory.newInstance()
.newDocumentBuilder().newDocument();
} catch (ParserConfigurationException e) {
System.out.println("Error creating new document object: " + e.getMessage());
}
detachedSignature.setXmlVersion("1.0");
detachedSignature.appendChild(detachedSignature.createElement("root"));
DOMSignContext context = new DOMSignContext(privateKey,
detachedSignature.getDocumentElement());
Document detachedSignature = db.newDocument();
DOMSignContext context = new DOMSignContext(privateKey, detachedSignature);
context.setIdAttributeNS(softwareIdentity, null, "id");
XMLSignature signature = sigFactory.newXMLSignature(signedInfo, keyinfo);
try {
@ -675,7 +666,6 @@ public class SwidTagGateway {
System.out.println("Error while signing SoftwareIdentity");
e.printStackTrace();
}
System.out.println("Detached signature: " + detachedSignature);
return detachedSignature;
}

View File

@ -175,6 +175,7 @@ public class TestSwidTagGateway {
gateway.setDefaultCredentials(true);
Document doc = gateway.signXMLDocument(signFilePath);
gateway.writeSwidTagFile(doc, DEFAULT_OUTPUT);
validator.validateSwidTag(DEFAULT_OUTPUT, "DEFAULT");
} catch (Exception e) {
e.printStackTrace();
}