private void signDOM(Node node, PrivateKey privateKey, Certificate origCert) {
XMLSignatureFactory fac = initXMLSigFactory();
X509Certificate cert = (X509Certificate) origCert;
// Create the KeyInfo containing the X509Data.
KeyInfoFactory kif = fac.getKeyInfoFactory();
List<Object> x509Content = null;//new ArrayList<Object>();
List<X509Data> data = new ArrayList<X509Data>();
if (map.containsKey(SIGNATURE_OPTION_CERT_INCLUSION_SUBJECTDN)) {
x509Content = new ArrayList<Object>();
x509Content.add(cert.getSubjectDN().getName());
// x509Content.add(cert);
//x509Content.add(cert.getSubjectDN().getName());
X509Data xd = kif.newX509Data(x509Content);
data.add(xd);
}
// if (map.containsKey(SIGNATURE_OPTION_CERT_INCLUSION_X500_PRINICPAL)) {
// }
if (map.containsKey(SIGNATURE_OPTION_CERT_INCLUSION_BASE64)) {
x509Content = new ArrayList<Object>();
x509Content.add(cert);
//x509Content.add(cert.getSubjectX500Principal().getName());
X509Data xd = kif.newX509Data(x509Content);
data.add(xd);
}
if (map.containsKey(SIGNATURE_OPTION_CERT_INCLUSION_SERIAL)) {
x509Content = new ArrayList<Object>();
X509IssuerSerial issuer = kif.newX509IssuerSerial(cert.getIssuerX500Principal().getName(), cert.getSerialNumber());
x509Content.add(issuer);
X509Data xd = kif.newX509Data(x509Content);
data.add(xd);
}
//
//x509Content.add(cert);
KeyInfo ki = kif.newKeyInfo(data);
// Create a DOMSignContext and specify the RSA PrivateKey and
// location of the resulting XMLSignature's parent element.
DOMSignContext dsc = new DOMSignContext(privateKey, node);
dsc.putNamespacePrefix(XML_DIGSIG_NS, "ns2");