• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem in Digitally Signing a particular element of an XML Document

 
ragunath Mariappan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic