Here is the sample code.Does any one have any thoughts on this
String providerName = System.getProperty("jsr105Provider", "org.jcp.xml.dsig.internal.dom.XMLDSigRI");
XMLSignatureFactory fac = XMLSignatureFactory.getInstance("DOM",(Provider) Class.forName(providerName).newInstance());
// Create a Reference to the enveloped document (in this case we are
// signing the whole document, so a URI of "" signifies that) and
// also specify the SHA1 digest algorithm and the ENVELOPED Transform.
Reference ref = fac.newReference ("#main", fac.newDigestMethod(DigestMethod.SHA1, null),
Collections.singletonList(fac.newTransform(Transform.ENVELOPED, (TransformParameterSpec) null)),null, null);
XMLStructure content = new DOMStructure(conElement);
XMLObject obj = fac.newXMLObject
(Collections.singletonList(content), "main", null, null);
// Create the SignedInfo
Signe dInfo si = fac.newSignedInfo(fac.newCanonicalizationMethod(CanonicalizationMethod.INCLUSIVE_WITH_COMMENTS,(C14NMethodParameterSpec) null),fac.newSignatureMethod(SignatureMethod.RSA_SHA1, null),Collections.singletonList(ref));
// Create a DSA KeyPair
KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");kpg.initialize(512);
KeyPair kp = kpg.generateKeyPair();
// Create a KeyValue containing the DSA PublicKey that was generated
KeyInfoFactory kif = fac.getKeyInfoFactory();
KeyValue kv = kif.newKeyValue(kp.getPublic());
// Create a KeyInfo and add the KeyValue to it
KeyInfo ki = kif.newKeyInfo(Collections.singletonList(kv));
/*NodeList nl = doc.getElementsByTagNameNS(XMLSignature.XMLNS, "SignDocument");
if (nl.getLength() == 0) {
throw new Exception("Cannot find Signature element");
}*/
//System.out.println("signature node found"+nl.item(0));
gain knowledge <[EMAIL PROTECTED]> wrote:
XMLSignatureFactory fac = XMLSignatureFactory.getInstance("DOM",(Provider) Class.forName(providerName).newInstance());
// Create a Reference to the enveloped document (in this case we are
// signing the whole document, so a URI of "" signifies that) and
// also specify the SHA1 digest algorithm and the ENVELOPED Transform.
Reference ref = fac.newReference ("#main", fac.newDigestMethod(DigestMethod.SHA1, null),
Collections.singletonList(fac.newTransform(Transform.ENVELOPED, (TransformParameterSpec) null)),null, null);
XMLStructure content = new DOMStructure(conElement);
XMLObject obj = fac.newXMLObject
(Collections.singletonList(content), "main", null, null);
// Create the SignedInfo
Signe dInfo si = fac.newSignedInfo(fac.newCanonicalizationMethod(CanonicalizationMethod.INCLUSIVE_WITH_COMMENTS,(C14NMethodParameterSpec) null),fac.newSignatureMethod(SignatureMethod.RSA_SHA1, null),Collections.singletonList(ref));
// Create a DSA KeyPair
KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");kpg.initialize(512);
KeyPair kp = kpg.generateKeyPair();
// Create a KeyValue containing the DSA PublicKey that was generated
KeyInfoFactory kif = fac.getKeyInfoFactory();
KeyValue kv = kif.newKeyValue(kp.getPublic());
// Create a KeyInfo and add the KeyValue to it
KeyInfo ki = kif.newKeyInfo(Collections.singletonList(kv));
/*NodeList nl = doc.getElementsByTagNameNS(XMLSignature.XMLNS, "SignDocument");
if (nl.getLength() == 0) {
throw new Exception("Cannot find Signature element");
}*/
//System.out.println("signature node found"+nl.item(0));
gain knowledge <[EMAIL PROTECTED]> wrote:
I tried the XML signature with JSR10.5 (JWSDP).It doesn't use any keystore.I don't undestand how it generates a private to sign the document..But it pulls the URI content from the origianl place in the XML and pushs along with the signature element.It doesn't retain the content where it was in the XML file.Has any one explored JSR10.5 to see how it gets the private key?If so can you share your experience pls
Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2¢/min or less.
Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2¢/min or less.
- JCR10.5 gain knowledge
- Re: JCR10.5 gain knowledge
- Re: JCR10.5 Sean Mullan
- Re: JCR10.5 Sean Mullan
Reply via email to