Feb 1st, 2012, 04:06 AM
RestTemplate and XmlSignatures
after searching the forum and the web, I didn't find any hints concerning my problem. I've got a question concerning RestTemplate. Currently, I am implementing a (rest)client that needs to:
a) sign its xml payload
b) verify the signature on the response
Is there any support for this in RestTemplate? Can I (re-)use XWSS and the beans from spring-ws?
Last edited by de_tom; Feb 2nd, 2012 at 02:33 AM.
Feb 1st, 2012, 10:20 AM
Here's what I tried so far:
- ClientHttpRequestInterceptor: Intercepting the message before it was sent, accessing the raw byte of the body. Result: Not really nice, all headers have been set already - content-length needs to be updated after body was modified.
- messageConverters: I have extended a Jaxb2Marshaller and added signing-functionality. Also a bit messy but seems to get the job done.
If you have any feedback, I'd love to hear it.
Feb 2nd, 2012, 02:32 AM
In case anybody has the same requirement, here's what I ended up doing.
- Implement custom marshaller/unmarshaller
- inject jaxb2marshaller as delegate
- for signing: use jaxb2marshaller to marshall into an intermediate result, then apply signature
- for validation: read xml, validate signature then pass the validated document to jaxb2marshaller for unmarshalling
In my opinion, it's not a really nice solution. I'd rather have reused the classes from spring-ws. When I have some spare time, I'll start investigating in this direction.
Tags for this Thread