aspose file tools*
The moose likes Security and the fly likes problem in Digitally Signing a particular element of an XML Document Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » Security
Bookmark "problem in Digitally Signing a particular element of an XML Document" Watch "problem in Digitally Signing a particular element of an XML Document" New topic
Author

problem in Digitally Signing a particular element of an XML Document

ragunath Mariappan
Greenhorn

Joined: Oct 29, 2007
Posts: 8
hi all!!
Happy to start with my first post in JavaRanch..
----------------------------------------------------------
I was trying to sign a particular element of an XML document using JSR105 (XML Digital Signatures) API.
For which i used #xpointer(id('idvalue')) and #idvalue as the URI for the reference i create as below :

NOTE: Here 123 is the value of the attribute 'id' of the element i wish to sign in the input XML document.

But when i try to digest and sign the the above created reference, i get the following exception (which is strange! atleast for me!)

Exception in thread "main" javax.xml.crypto.dsig.XMLSignatureException: javax.xml.crypto.URIReferenceException: Can't resolve ID: '123' in ''
at com.ibm.xml.crypto.dsig.dom.ReferenceImpl.calculateDigestValue(ReferenceImpl.java:327)
at com.ibm.xml.crypto.dsig.dom.ReferenceImpl.sign(ReferenceImpl.java:237)
at com.ibm.xml.crypto.dsig.dom.XMLSignatureImpl.sign(XMLSignatureImpl.java:158)
at sent.Generate.main(Generate.java:103)
Caused by: javax.xml.crypto.URIReferenceException: Can't resolve ID: '123' in ''
at com.ibm.xml.crypto.dsig.dom.URIDereferencerImpl.dereference(URIDereferencerImpl.java:193)
at com.ibm.xml.crypto.dsig.dom.ReferenceImpl.calculateDigestValue(ReferenceImpl.java:285)
... 3 more
javax.xml.crypto.URIReferenceException: Can't resolve ID: '123' in ''
at com.ibm.xml.crypto.dsig.dom.URIDereferencerImpl.dereference(URIDereferencerImpl.java:193)
at com.ibm.xml.crypto.dsig.dom.ReferenceImpl.calculateDigestValue(ReferenceImpl.java:285)
at com.ibm.xml.crypto.dsig.dom.ReferenceImpl.sign(ReferenceImpl.java:237)
at com.ibm.xml.crypto.dsig.dom.XMLSignatureImpl.sign(XMLSignatureImpl.java:158)
at sent.Generate.main(Generate.java:103)


-------------------------------------------------------------
I've given the whole Java code i used to generate the signature and the XML i used below for you to get a clear picture of what i tried...
Any suggestions are very much welcome..
thanks..
ragu
----------------------------------------------------------------

Generate.java
.............

---------------------------------------------------------------------

XML Document "shippedPedigree.xml" used
.......................................


--------------------------------------------------------------------
Nicholas Jordan
Ranch Hand

Joined: Sep 17, 2006
Posts: 1282


You have a pair of "single quotes" around '123' in ("#xpointer(id('123'))", which is unusual for a string paramater to a function. This may be normal in xml parsing, I know nothing of the matter but wanted to compliment your posting style - this is mastery and for a fist post is to be complimented.

There is a button: Disable smilies in this post, you may edit your own posts using the button edit_ubb6.gif which looks like a pencil and paper in the view and has a tool tip of Edit/Delete post. Using this will allow the Instant Graemlins to be de-activated.

Also: break up this line thus:

[ December 22, 2007: Message edited by: Nicholas Jordan ]

"The differential equations that describe dynamic interactions of power generators are similar to that of the gravitational interplay among celestial bodies, which is chaotic in nature."
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in Digitally Signing a particular element of an XML Document
 
Similar Threads
NUll pointer exception in XML sig program
Error while parsing XML with PDF attachment
Signing XML and Canonicalization
Signing & Verify XML Document
How to use SAML 2.0 Sender Vouches?