I don't know for sure, but you should be able to figure out the problem by inserting some print statements or running your test case thru a debugger such as jdb or JSwat (you will have to recompile the Apache XMLSec source with the -g flag though). Also, make sure when you parse your Document with a DocumentBuilder you set it to be namespace aware (DocumentBuilderFactory.setNamespaceAware(true)).

--Sean

Milan Tomic wrote:
As much as I could debug XSEC, "Algorith" attribute was never found for my
<SignatureMethod> element, although it is there. Perhaps this is an issue
with namespaces?

I'm attaching XML file I was using for testing purposes.

Best regards,
Milan


-----Original Message-----
From: Milan Tomic [mailto:[EMAIL PROTECTED] Sent: Friday, October 14, 2005 11:49 AM
To: [email protected]
Subject: RE: [java] XMLSignature ctor



Yes, the docSig parameter should be the
SignatureMethod element and not the Signature element.


Thank you, Sean. The error message a little confused me.

I did as you suggested and now I got this exception in XMLSignature ctor:

org.apache.xml.security.signature.XMLSignatureException: The requested
algorithm  does not exist. Original Message was: null
Original Exception was java.lang.NullPointerException
        at
org.apache.xml.security.algorithms.SignatureAlgorithm.<init>(Unknown Source)
        at org.apache.xml.security.signature.SignedInfo.<init>(Unknown
Source)
        at org.apache.xml.security.signature.XMLSignature.<init>(Unknown
Source)
        at TestXSEC.main(TestXSEC.java:97)
java.lang.NullPointerException
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:141)
        at
org.apache.xml.security.algorithms.SignatureAlgorithm.<init>(Unknown Source)
        at org.apache.xml.security.signature.SignedInfo.<init>(Unknown
Source)
        at org.apache.xml.security.signature.XMLSignature.<init>(Unknown
Source)
        at TestXSEC.main(TestXSEC.java:97)
Exception in thread "main"

I'm using this XMLSignature ctor:

XMLSignature(org.w3c.dom.Document doc,
            java.lang.String BaseURI,
            java.lang.String SignatureMethodURI,
            java.lang.String CanonicalizationMethodURI)

I couldn't find any examples using this ctor. I'm trying to sign already
created XML template with <Signature> element in it. Similar to
templateSign.cpp in C++ examples. I'm using XSEC 1.2.1 and JDK 1.4.2.

Am I doing something wrong? Could someone verify that this ctor works OK?

Best regards,
Milan


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

<IzdaniRacunEnostavni xmlns:ds="http://www.w3.org/2000/09/xmldsig#"; xmlns:xds="http://uri.etsi.org/01903/v1.1.1#"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:noNamespaceSchemaLocation="http://www.gzs.si/e-poslovanje/sheme/eSlog_1-4_PreprostiRacun.xsd";><Racun 
Id="data"></Racun><ds:Signature Id="SignatureId"><ds:SignedInfo><ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315";></ds:CanonicalizationMethod><ds:SignatureMethod 
Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1";></ds:SignatureMethod><ds:Reference URI="#data"><ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1";></ds:DigestMethod><ds:DigestValue>empty</ds:DigestValue></ds:Reference><ds:Reference 
URI="#SignedPropertiesId"><ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1";></ds:DigestMethod><ds:DigestValue>empty</ds:DigestValue></ds:Reference></ds:SignedInfo><ds:SignatureValue>empty</ds:SignatureValue><ds:Object><xds:QualifyingPropert
ies Target="#SignatureId"><xds:SignedProperties 
Id="SignedPropertiesId"><xds:SignedSignatureProperties><xds:SigningTime>2005-10-14T13:30:52.783Z</xds:SigningTime><xds:SigningCertificate><xds:Cert><xds:CertDigest><xds:DigestMethod 
Algorithm="http://www.w3.org/2000/09/xmldsig#sha1";></xds:DigestMethod><xds:DigestValue>s4Vq41bmhfrwpmaHpEt0tilaFmc=</xds:DigestValue></xds:CertDigest><xds:IssuerSerial><ds:X509IssuerName>OU=sitest-ca, O=state-institutions, 
C=si</ds:X509IssuerName><ds:X509SerialNumber>1007374424</ds:X509SerialNumber></xds:IssuerSerial></xds:Cert></xds:SigningCertificate><xds:SignaturePolicyIdentifier><xds:SignaturePolicyImplied></xds:SignaturePolicyImplied></xds:SignaturePolicyIdentifier></xds:SignedSignatureProperties></xds:SignedProperties></xds:QualifyingProperties></ds:Object></ds:Signature></IzdaniRacunEnostavni>

Reply via email to