You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fx-dev@ws.apache.org by Ofelia Tindea <of...@googlemail.com> on 2006/05/30 18:54:16 UTC

Encrypt with WSS4J

Hi,

Can you please help me, I'm trying to encrypt / decrypt several parts of a
SOAP message with wss4j. For encryption I use WSSecDKEncrypt.

The problem is that if the Vector of parts contains more than one element,
given by "Id" value, in the resulted encrypted document only the last
encrypted element xenc:EncryptedData will have a ds:KeyInfo child node. And
when I try to decrypt this document I get the following exception:

org.apache.ws.security.WSSecurityException:
 An error was discovered processing the <wsse:Security> header.
(WSSecurityEngine: EncryptedKey does not contain ds:KeyInfo)

at
org.apache.ws.security.processor.ReferenceListProcessor.decryptDataRefEmbedded(
ReferenceListProcessor.java:129)
at
org.apache.ws.security.processor.ReferenceListProcessor.handleReferenceList(
ReferenceListProcessor.java:97)
at org.apache.ws.security.processor.ReferenceListProcessor.handleToken (
ReferenceListProcessor.java:66)
at org.apache.ws.security.WSSecurityEngine.processSecurityHeader(
WSSecurityEngine.java:269)
at org.apache.ws.security.WSSecurityEngine.processSecurityHeader(
WSSecurityEngine.java:191) at
org.apache.ws.security.WSSecurityEngine.processSecurityHeader(
WSSecurityEngine.java:144)

The sequence of code where i do the encryption looks like this:

Vector parts = new Vector();
for (int i = 0; i < noOfParts; i++) {
WSEncryptionPart encP = new WSEncryptionPart(Integer.toString(i),"Element");
parts.add(encP);
}
encrBuilder.setParts(parts);
Document encryptedDoc = encrBuilder.build(doc, crypto, secHeader);

Am I doing something wrong, is there something that i am missing? Can you
please give me any ideeas about how i might solve this.

Thanks,

Ofelia