### Question:
XmlSignatureHelper { public Document signSamlAssertion(Document document) throws TransformerException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, KeyException, MarshalException, XMLSignatureException { if (document != null) { PrivateKeyEntry entry = getPrivateKeyEntryFromKeystore(); PrivateKey privateKey = entry.getPrivateKey(); X509Certificate certificate = (X509Certificate) entry.getCertificate(); Element signedElement = signSamlAssertion(document, privateKey, certificate); return signedElement.getOwnerDocument(); } return null; }  Document signSamlAssertion(Document document); Document convertDocumentToDocumentDom(org.jdom.Document doc); Element convertElementToElementDom(org.jdom.Element element); Element convertDocumentToElementDom(org.jdom.Document document);  }### Answer:
@Ignore @Test public void signSamlArtifactResolve() throws JDOMException, TransformerException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, KeyException, MarshalException, XMLSignatureException, KeyStoreException, CertificateException { Document unsignedDocument = getDocument("artifact-resolve-unsigned.xml"); Document signedDom = signatureHelper.signSamlAssertion(unsignedDocument); Assert.assertNotNull(signedDom); boolean foundSignedInfo = false; boolean foundSignatureValue = false; boolean foundKeyInfo = false; NodeList list = signedDom.getChildNodes(); if (list.item(0).getNodeName().equals("samlp:ArtifactResolve")) { NodeList sublist = list.item(0).getChildNodes(); for (int i = 0; i < sublist.getLength(); i++) { if (sublist.item(i).getNodeName().equals("Signature")) { NodeList signatureList = sublist.item(i).getChildNodes(); for (int j = 0; j < signatureList.getLength(); j++) { if (signatureList.item(j).getNodeName().equals("SignedInfo")) { foundSignedInfo = true; } else if (signatureList.item(j).getNodeName().equals("SignatureValue")) { foundSignatureValue = true; } else if (signatureList.item(j).getNodeName().equals("KeyInfo")) { foundKeyInfo = true; } } } } } Assert.assertTrue("Should be true if Signature contains SignedInfo tag", foundSignedInfo); Assert.assertTrue("Should be true if Signature contains SignatureValue tag", foundSignatureValue); Assert.assertTrue("Should be true if Signature contains KeyInfo tag", foundKeyInfo); Assert.assertTrue(validator.isDocumentTrusted(signedDom, "CN=*.slidev.org,OU=Domain Control Validated,O=*.slidev.org")); }