//doc.appendChild(assertionElement);
// Create a DOMSignContext and specify the DSA PrivateKey and
// location of the resulting XMLSignature's parent element
DOMSignContext dsc = null;
KeySelector ks = KeySelector.singletonKeySelector(privKey);
NodeList nl = assertionElement.getElementsByTagNameNS(assertionElement.getNamespaceURI(), "Issuer");
Node issuer = null;
if (nl != null && nl.getLength() > 0) {
issuer = nl.item(0);
}
Node nextSibling = (issuer != null) ? issuer.getNextSibling():null;
if (nextSibling != null) {
dsc = new DOMSignContext(ks, assertionElement, nextSibling);
} else {
dsc = new DOMSignContext(privKey, assertionElement);
}
HashMap map = new HashMap();
map.put(this.getID(),assertionElement);
dsc.setURIDereferencer(new DSigResolver(map,assertionElement));
XMLSignature signature = fac.newXMLSignature(si, ki);
dsc.putNamespacePrefix("http://www.w3.org/2000/09/xmldsig#", "ds");
// Marshal, generate (and sign) the enveloped signature
signature.sign(dsc);
signedAssertion = assertionElement;