Hi all,
I'm trying to add a timestamp into a WSSEC header but I'm having problems when I want to include it in the signature process. When I add it, I have the following exception:

[java] org.apache.ws.security.WSSecurityException: Signature creation failed; nested exception is: [java] org.apache.xml.security.signature.XMLSignatureException: Id not found [java] Original Exception was org.apache.xml.security.signature.ReferenceNotInitializedException: Id not found
     [java] Client exiting
[java] Original Exception was org.apache.xml.security.signature.ReferenceNotInitializedException: Id not found [java] Original Exception was org.apache.xml.security.signature.ReferenceNotInitializedException: Id not found [java] Original Exception was org.apache.xml.security.utils.resolver.ResourceResolverException: Id not found [java] at org.apache.ws.security.message.WSSecSignature.computeSignature (WSSecSignature.java:663) [java] at org.apache.ws.security.message.WSSecSignature.build (WSSecSignature.java:728) [java] at org.perfsonar.client.base.authn.WSSAuthNX509Data.addX509STInMessage (Unknown Source) [java] at org.perfsonar.client.base.authn.WSSAuthNX509Data.addX509STInMessage (Unknown Source) [java] at org.perfsonar.service.testHarness.authService.AuthNRequestTest.testReque st(Unknown Source) [java] at org.perfsonar.service.testHarness.authService.AuthNRequestTest.makeReque st(Unknown Source) [java] at org.perfsonar.service.testHarness.authService.AuthNRequestTest.main (Unknown Source) [java] Caused by: org.apache.xml.security.signature.XMLSignatureException: Id not found [java] Original Exception was org.apache.xml.security.signature.ReferenceNotInitializedException: Id not found [java] Original Exception was org.apache.xml.security.signature.ReferenceNotInitializedException: Id not found [java] Original Exception was org.apache.xml.security.signature.ReferenceNotInitializedException: Id not found [java] Original Exception was org.apache.xml.security.utils.resolver.ResourceResolverException: Id not found [java] at org.apache.xml.security.signature.XMLSignature.sign(Unknown Source) [java] at org.apache.ws.security.message.WSSecSignature.computeSignature (WSSecSignature.java:659)
     [java]     ... 6 more

I'm using WSS4J 1.5.1 and my piece of code is the following:
            Document doc = envelope.getAsDocument();
            WSSecHeader secHeader = new WSSecHeader();
            secHeader.setActor("ac");
            secHeader.insertSecurityHeader(doc);

            // Adding the certificate using WSS
            WSSecSignature sec509 = new WSSecSignature();
            sec509.setUserInfo("xmlsec", "security");
SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(envelope.getAsDOM()); Vector<WSEncryptionPart> parts = new Vector<WSEncryptionPart>(1,1);

            // Set up to use STRTransorm to sign the signature token
            WSEncryptionPart encP =
                new WSEncryptionPart(
                    "STRTransform",
                    soapConstants.getEnvelopeURI(),
                    "Content");
            parts.add(encP);

            WSSecTimestamp timestamp = new WSSecTimestamp();
            timestamp.setTimeToLive(600);
            timestamp.prepare(doc);
            parts.add(new WSEncryptionPart(timestamp.getId()));

            sec509.setParts(parts);
sec509.setKeyIdentifierType (WSConstants.BST_DIRECT_REFERENCE);

            // Signing the message
            Document signedDoc = sec509.build(doc, crypto, secHeader);

Could anyone see the problem?

Thanks in advance

--
Cándido Rodríguez Montes                E-mail: [EMAIL PROTECTED]
Red.ES/RedIRIS                                  Tel:+34 955 05 66 13
Edificio CICA
Avenida Reina Mercedes, s/n
41012 Sevilla
SPAIN



Reply via email to