Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

It depends on JWS with Detached Content and  JWS with Unencoded Payload options as well as on the newly introduced CXF multipart filters and works as follows.

When request or response attachments attachment parts are about to be submitted to the Multipart serialization provider, JWS Multipart Output Filter initializes a JWSSignature object. Next every attachmentparts's output stream is replaced with the filtering output stream which updates the signature object on every write operation. Finally this multipart filter adds one more attachment part to the list of the attachments to be written - this attachment part holds a reference to JWS Signature. When this last attachment part is written, JWSSignature produces the signature bytes which are encoded using either JWS Compact or JWS JSON format, with the detached and unencoded content already being pushed to the output stream.

When the attachments attachment parts are about to be read by the Multipart deserialization provider, their signature carried over in the last attachment part will need to be verified. Just before the attachment parts are about to be read in order to be made available to the application code, JWS Multipart Input Filter checks the last attachment part and initializes a JWSVerificationSignature object. Next for every attachment but the last one it replaces the input stream with the filtering input stream which updates the signature verification object on every read operation. Once all the data have been read it compares the calculated signature with the received signature.

Note all of the multipart attachments parts can be secured this way but by default, unless filters set a 'supportSinglePartOnly' property to 'false', the attachments with more than one data part will be rejected. This is done to avoid some possible security side-effects when the receiving side starts processing the parts as soon as they become available, before all of the multipart payload have has been read.

Here is the example showing how a Book object (represented as an XML attachment on the wire) can be secured.

...