Return-Path: Delivered-To: apmail-cxf-users-archive@www.apache.org Received: (qmail 3406 invoked from network); 10 Aug 2009 17:08:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 10 Aug 2009 17:08:36 -0000 Received: (qmail 62882 invoked by uid 500); 10 Aug 2009 17:08:42 -0000 Delivered-To: apmail-cxf-users-archive@cxf.apache.org Received: (qmail 62789 invoked by uid 500); 10 Aug 2009 17:08:42 -0000 Mailing-List: contact users-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@cxf.apache.org Delivered-To: mailing list users@cxf.apache.org Received: (qmail 62779 invoked by uid 99); 10 Aug 2009 17:08:42 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Aug 2009 17:08:42 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of rich.kuali@gmail.com designates 209.85.221.197 as permitted sender) Received: from [209.85.221.197] (HELO mail-qy0-f197.google.com) (209.85.221.197) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Aug 2009 17:08:34 +0000 Received: by qyk35 with SMTP id 35so2845615qyk.24 for ; Mon, 10 Aug 2009 10:08:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=6tfXZtA/zehd33AygR7K5uIjdhv7BQJfVCR5YN9aB6M=; b=eoBfa5ZiEEEeCWIsL/6XKjYjBk0RmzkMtPvakhkjHlB1f5G1WzFxTWji7NN0/FMai9 clNieHBLsqS2CDqZWhLO15TgBxcmLpWtZ3M9ubZX5RttobkfS0pFyhS/0DT1pNACOZjU 6DA11vvW9Y6q8EJSlvSUPztScd3I8/yHnuCjI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=p6Okg1X0orvXSb3J1m1eua3oSJdxe5d7dPI9wq5N/zu/83Lcrwh3Zov3hf4UNa8nZL BdNAuowRRcw1pbguawFNfEr4endW/dd0GgOrnjeGrEqrtzQJttI4g2IFJRUx3kQ3SMlk lOyHW0NnnIKHeRC5Aafp4wlDjrvBg05i+Qgd8= MIME-Version: 1.0 Received: by 10.229.94.194 with SMTP id a2mr1530624qcn.92.1249924093464; Mon, 10 Aug 2009 10:08:13 -0700 (PDT) In-Reply-To: References: <543d7d30908071242o1d66e4e9n9d3f7ff52124fbc7@mail.gmail.com> Date: Mon, 10 Aug 2009 13:08:13 -0400 Message-ID: <543d7d30908101008v537c739eo43e6e150cd797dbb@mail.gmail.com> Subject: Re: Adding Elements to WS-Security Header .... WSS4JOutInterceptor, SAAJOutInterceptor From: R1ch To: users@cxf.apache.org Content-Type: multipart/alternative; boundary=0016364ee8ac96583c0470cca130 X-Virus-Checked: Checked by ClamAV on apache.org --0016364ee8ac96583c0470cca130 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi Mayank and thanks for the respone. Resending I dont think i hit reply all last time I tried what you suggested but I am getting a null pointer exception after the line following SOAPMessage soapMessage = message.getContent(SOAPMessage.*class*); that is, the soapMessage is null. I think this is due to the fact that WSS4JOutInterceptor.handleMessage(SoapMessage mc) if (mc.getContent(SOAPMessage.class) == null) { saajOut.handleMessage(mc); } if you look inside saajOut.handleMessage(mc) this is what creates the soapMessage when the getContent returns null. This is what i was referring to in my example 1) below. So I went with example 2) the internal interceptor. I guess i can try and explicitly add the SAAJOutInterceptor to the endpoint but the documentation says it is not needed in CXF 2.1+ On Mon, Aug 10, 2009 at 1:11 AM, Mayank Mishra wrote: > Hi, > > You can always extend WSS4JOutInterceptor and customize the behavior. But I > would rather do something like below, > > class MyCustomInterceptor extends AbstractPhaseInterceptor{ > > public MyCustomInterceptor(){ > super(); > setPhase(Phase.*PRE_PROTOCOL*); > getAfter().add(SAAJOutInterceptor.*class*.getName()); > getBefore().add(WSS4JOutInterceptor.*class*.getName()); > } > public void handleMessage(SoapMessage message) throws Fault{ > > SOAPMessage soapMessage = message.getContent(SOAPMessage.*class*); > > soapMessage.getSOAPBody().addChildElement(myElement()); > } > > > With Regards, > Mayank > On Fri, Aug 7, 2009 at 2:42 PM, R1ch wrote: > > > CXF 2.2 and WSS4J 1.5.8 > > > > Hello all, > > I have a working webservice configured with WSS4JOutInterceptor to insert > a > > signed SAML token. > > Now I'm trying to insert an Element before the signature occurs so that > my > > Element is also signed. > > > > I tried two different ways and both are not resulting in what I need. > > > ========================================================================== > > 1) did something similar to > > > > public class myInterceptor extends WSS4JOutInterceptor { > > handleMessage(SoapMessage mc) { > > SOAPMessage soapMsg = myElement(); > > mc.setContent(SOAPMessage.class, soapMsg); > > super.handleMessage(mc); > > } > > } > > this throws an exception, dont have it right now but can reproduce if > some > > needs to see it. > > If I place the super.handleMessage(mc); before my code, (before the > > myElement()) there is no error > > but my element is not in the final soap message. > > > > Then I noticed that WSS4JOutInterceptor.handleMessage(SoapMessage mc) has > > if (mc.getContent(SOAPMessage.class) == null) { > > saajOut.handleMessage(mc); > > } > > So I thought that I can't add SOAPMessage content. so I came up with the > > next try > > > > > ========================================================================== > > 2) I did something almost exactly to what WSS4JOutInterceptor has, i.e > use > > an internal interceptor > > with phase.USER_PROTOCOL. The WSS4JOutInterceptorInternal is > > Phase.POST_PROTOCOL so i figured > > if mine was before the post it would work. > > > > public class myInterceptor extends WSS4JOutInterceptor { > > > > final class myInternal implements PhaseInterceptor > { > > handleMessage(SoapMessage mc) { > > SOAPMessage soapMsg = myElement(); > > mc.setContent(SOAPMessage.class, soapMsg); > > super.handleMessage(mc); > > } > > } > > } > > > > Well, my element is in the final SOAP message but it is not signed and my > > was actually empty > > not what the webservice returns. > > > ========================================================================== > > > > So I was going to try and my Element to the message as XMLStreamWriter > > content but I noticed that > > SAAJOutInterceptor.handleMessage(SoapMessage message) replaces that with > > W3CDOMStreamWriter > > > > 1. My first question is how do I get my element signed? > > 2. What is the correct way to add content, is it mc.setContent() or do I > > mc.getContent and add to that? > > 3. What is the pupose of the Message Content Formats? > > 4. When should I use SOAPMessage or XMLStreamWriter or any other format? > > 5. If I put my content in the message for example as java.io.OutputStream > > does it still get added to the final message? > > > > Thanks for your time. > > > --0016364ee8ac96583c0470cca130--