On Saturday 09 October 2010 9:13:27 am Andreas Veithen wrote: > On Fri, Oct 8, 2010 at 18:13, Daniel Kulp <dk...@apache.org> wrote: > > And I think this is where the issues may start popping up, but definitely > > resolvable. If you look at the CXF survey, one of the MAJOR "areas of > > improvement" for CXF was too many external dependencies. I'm kind of > > reluctant to add more "required" deps. Thus, the security stuff would > > need to work with the default SAAJ impl (in particular, the one built > > into the JDK), but I could definitely see making something like this as > > an optional "performance enhancment" type thing. Ideally, the existing > > SAAJ interceptor would be smart enough to checkt he SAAJ impl being used > > and do the smart thing depending on what it sees. > > What about the following solution: > * Introduce a new SAAJManager interface that encapsulates the SAAJ > handling stuff. > * Create a default implementation based on the code currently > contained in the standard SAAJ interceptors. > * Refactor SAAJInInterceptor and SAAJOutInterceptor to look up the > SAAJManager using Bus#getExtension. If none is found, fall back to the > default implementation. > * Maybe also refactor the WSS4J interceptors to use SAAJManager > instead of instantiating SAAJ(In|Out)Interceptor. > * My ddom-cxf stuff would then provide an alternative SAAJManager > implementation and automatically register that as a bus extension.
Sure. That works. :-) > > If the DDOM stuff we need can be squashed/shaded > > into a single jar that is just a drop in replacement of saaj-impl, that > > concern could also be aleviated quite a bit as well. > > Yes, I was also thinking the same. There are a couple of other reasons > why this is a good idea: > * The DDOM project is split into a multitude of smaller modules, so > that for every use case, you only get the stuff that is really needed > (e.g. some modules depend on the Axiom APIs, but you don't want that > as a transitive dependency for the CXF stuff ;-). This works well when > Maven is used, but of course it's a pain for users who use other > tools. > * The code in the CXF stuff is (currently) tightly coupled to some > internal DDOM APIs that are likely to change over time. Thus, > packaging all the required stuff into a single JAR and shade it makes > sense because it avoids conflicts caused by incompatible versions of > DDOM modules. That all makes sense. Keeping the dep list small is definitely a welcome thing. > > That said, the callback method added to WSS4J has an additional use case > > that Sergey and I have been noodling on outside of SOAP. One thing > > we're trying to figure out how to do is leverage some of the WS-SecPol > > support to provide message level security for XML REST payloads. With > > the callback, we MAY be able to have separate XML sources for the > > security header and the actual payload (think separate MIME containers) > > where we feed the security header into WSS4J, and it calls back out to > > us to load the other parts as/if needed. Very early in the "noodling in > > our heads" stages. :-) > > The DDOM solution here would simply be to compose the equivalent SOAP > message and pass that to WSS4J. This would mean creating a skeleton > SOAP message and adding the source objects for the header and body > parts to that skeleton. It is definitely possible to defer the > expansion of these parts (and even the lookup of the corresponding > MIME parts from the message) until the very last moment. This is > conceptually similar to your solution except that the callbacks are > invoked by the DOM/SAAJ implementation instead of WSS4J. This could > have some advantages: > > * The scope of WSS4J would remain strictly limited to WS-Security and > no API changes are needed. > * If I understand your idea correctly, then conceptually you are > defining a mapping between REST style requests/responses and SOAP > messages conforming to WS-Security. With DDOM, the code that > implements this would simply be a direct transcription of these > mapping rules (plus of course some glue code). This is beginning to sound too much like Synapse. Seriously, this isn't ideal for certain policy elements. For example, an XPATH expression for the encrypted elements should, ideally, not have any soap things in it for a REST invokation. I'd need to think about this some more though. The main issue here would be the fact that the Message object that is passed from Interceptor to Interceptor when using JAX-RS is not a SoapMessage. It's probably just a MessageImpl. If you try to even configure any of the WSS4J or SAAJ interceptors onto the JAX-RS chains, it will throw and exception before the handleMessage call is even called. The Java runtime won't even allow it. The WSS4J interceptors would need to be updated to adjust for that anyway. > >> It also > >> successfully passes the most important parts of the DOM3 test suite. > >> * When configured as SAAJ implementation in the CXF build (without the > >> custom SAAJInInterceptor), it passes all unit tests up to the systests > >> (It seems that this is primarily due to the fact that some of the > >> systests use SAAJ to compose test messages). > > > > Likely yes. Do you have a feeling as to whether those are issues in > > the CXF tests or issues with DDOM? > > These are issues in DDOM. They are simply due to the fact that many > SAAJ methods in DDOM are still unimplemented ;-). It's almost a shame you are doing this at google instead of in Apache someplace. Apache has access to the standalone SAAJ TCK for testing that, but we're only really allowed to test it on Apache projects. Maybe convince Geronimo to try using DDOM as an optional SAAJ impl and see how the SAAJ J2EE tests progress. Oh well. > What I wanted to say > here is that there is enough stuff in DDOM's SAAJ implementation to > play nicely with CXF's own code. Of course, once the SOAPMessage is > exposed to user code through a JAX-WS handler or provider endpoint, > this is no longer enough. As I said, for the moment it's a PoC. OK. Makes sense. Gotta start someplace. :-) > > I see in the code that it doesn't support attachments either. That > > would be required for the JAX-WS TCK. (and likely for some of the > > systests as well) That said, those should be fairly easy to handle since > > you have the SoapMessage. The DDOM version could be MUCH more > > efficient by not buffering the attachments unless they really are > > accessed. One of my "issues" with the JAX-WS handlers is they require > > us to stop streaming EVERYTHING and buffer it, even if the only thing > > the handler does is: System.out.println("Hello World!"); > > this could be a huge help with that. > > The SAAJ stuff in DDOM is actually split into two parts: > * The part that implements the SAAJ object model. This contains the > code that extends DOM and also some partial implementations of > SOAPMessage and SOAPPart. On the other hand, it doesn't contain any > MIME parsing or attachment management logic. And it shouldn't need to contain any MIME parsing stuff for the CXF version. CXF has already taken care of that. > * The part that provides the SAAJ factories and thus the complete SAAJ > implementation. Of course this part depends on the first part and will > eventually contain the MIME parsing logic to satisfy the requirements > of the SAAJ spec. But we don't use any of that in CXF. So irrelevant for a first pass CXF integration. Once we get into using it to support Dispatch clients and Provider based services, I suppose it would be required though. > When running the CXF test suites against DDOM I use both parts as a > drop-in replacement for Sun's saaj-impl. On the other hand, the custom > SAAJInInterceptor only uses the first part. This means that the > SOAPMessage implementation is not the same as the one that would be > created by MessageFactory. Instead it uses an implementation that is > basically a wrapper around a org.apache.cxf.binding.soap.SoapMessage > object. This can be seen here: > > http://ddom.googlecode.com/svn/trunk/modules/ddom-cxf/src/main/java/com/goo > glecode/ddom/cxf/SOAPMessageImpl.java Right. I was looking at that. > The idea is that the methods that are used to manage attachments (and > that are currently unimplemented) would all delegate to the > corresponding CXF APIs. This means that all optimizations done by CXF > would also work when accessing the attachments through SAAJ. Since > SAAJ exposes attachments via iterators, the only case were all > attachments are buffered would be a call to countAttachments... OK. I didn't read far enough again. :-) It's pretty easy. The CXF SoapMessage (or just Message) has an Attachment list that can be retrieved via: Collection<Attachment> attachments = CastUtils.cast((Collection<?>)mc.get(Message.ATTACHMENTS)); That can easily be wrapped or similar to implement the required SAAJ API's. Anyway, this is definitely all very interesting. Thanks for pursuing this. Kind of can't wait till Colm frees up a bit to have his brain noodling on things as well. :-) -- Daniel Kulp dk...@apache.org http://dankulp.com/blog