cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Manson <dev.mansontho...@gmail.com>
Subject Re: How do I add a CXF Interceptor that would execute after WSS4JOutInterceptor so that I can change username
Date Fri, 18 Oct 2013 20:08:53 GMT
well,
that doesn't work for me...



<bean  id=*"SecurityCxfInterceptor"*

          class=*
"com.tibco.cts.amxbpm.fwk.security.SecurityCxfPhaseInterceptor"* />



  <bean id=*"WSS4JOutInterceptor"* class=*
"org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor"*>

    <constructor-arg>

      <map>

        <entry key=*"action"* value=*"UsernameToken"* />

        <entry key=*"user"* value=*"tibco-admin"* />

        <entry key=*"passwordType"* value=*"PasswordText"* />

        <entry key=*"passwordCallbackClass"*

          value=*"com.tibco.cts.amxbpm.fwk.security.PasswordCallbackHandler"
* />

      </map>

    </constructor-arg>

  </bean>





     <cxf:bus>

          <cxf:features>

               <p:policies />

               <cxf:logging />

          </cxf:features>

          <cxf:outInterceptors>

            <ref bean=*"WSS4JOutInterceptor"* />

               <ref bean=*"SecurityCxfInterceptor"* />

          </cxf:outInterceptors>

     </cxf:bus>






*public* *class* SecurityCxfPhaseInterceptor
*extends*AbstractPhaseInterceptor<Message>

{

  *private* *final* *static* String *wsseNamespace* = "
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd
";

  *private* *final* *static* String *wssePrefix*    = "wsse";





  *public* SecurityCxfPhaseInterceptor()

  {

    *super*(Phase.*PRE_PROTOCOL*);



    addAfter( WSS4JOutInterceptor.*class*.getName() );

  }







  @Override

  *public* *void* handleMessage(Message soapMessage) *throws* Fault

  {

    SOAPMessage sm = soapMessage.getContent(SOAPMessage.*class*);



    String amxbpmUserName = (String) soapMessage.getContextualProperty(
"amxbpm.username");



    *try*


On Fri, Oct 18, 2013 at 6:32 PM, Thomas Manson
<dev.mansonthomas@gmail.com>wrote:

> Thanks Daniel,
>
>  I will rework my code.
>
>   My WSS4JOutInterceptor was added like this :
>
>
>
>
>
>
> <!-- org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor -->
>
>      <bean class=*
> "com.tibco.cts.amxbpm.fwk.security.MyWSS4JOutInterceptor"*
>
>           id=*"outbound-security"*>
>
>           <constructor-arg>
>
>                <map>
>
>                      <entry key=*"action"* value=*"UsernameToken"* />
>
>                      <entry key=*"user"* value=*"tibco-admin"* />
>
>                      <entry key=*"passwordType"* value=*"PasswordText"* />
>
>                      <entry key=*"passwordCallbackClass"*
>
>                           value=*
> "com.tibco.cts.amxbpm.fwk.security.PasswordCallbackHandler"* />
>
>                </map>
>
>           </constructor-arg>
>
>      </bean>
>
>
>
>      <jaxws:client id=*"WorkListServiceProxyFactory"*
>
>           name=*"{http://services.brm.n2.tibco.com}WorkListService_EP"*
>
>           serviceClass=*"com.tibco.n2.brm.services.WorkListService"*
>
>           address=*"http://
> ${amxbpm.ws.host}:${amxbpm.ws.port}/amxbpm/WorkListService"*>
>
>
>
>           <jaxws:outInterceptors>
>
>                <ref bean=*"outbound-security"* />
>
>           </jaxws:outInterceptors>
>
>
>
>      </jaxws:client>
>
>
> On Fri, Oct 18, 2013 at 6:29 PM, DSL <dlaprade@gmail.com> wrote:
>
>> If you want your interceptor to execute after the WSS4JOutInterceptor then
>> the configuration would look like:
>>
>> <cxf:outInterceptors>
>>     <ref bean="WSS4JOutInterceptor"/>
>>     <ref bean="RefToAbstractPhaseInterceptorBean"/>
>> </cxf:outInterceptors>
>>
>> If the WSS4J is not defined in the list of outInterceptors, then your
>> interceptor will never get run. Do you have the WSS4JOutInterceptor
>> configured and added to the list of out interceptors?
>>
>>
>> On Fri, Oct 18, 2013 at 12:12 PM, Manson Thomas <mt@mansonthomas.com>
>> wrote:
>>
>> > Can you expand your idea?
>> >
>> >
>> >
>> > I would put this AbstractPhaseInterceptor in here :
>> >
>> >
>> >  <cxf:bus>
>> >
>> >  <cxf:features>
>> >
>> >  <p:policies />
>> >
>> >  <cxf:logging />
>> >
>> >  </cxf:features>
>> >
>> >  <cxf:outInterceptors>
>> >
>> >  <ref bean="RefToAbstractPhaseInterceptorBean" />
>> >
>> >  </cxf:outInterceptors>
>> >
>> > </cxf:bus>
>> >
>> > and the constructor of this class would be like :
>> >
>> >
>> >
>> >
>> >   public SecurityCxfInterceptor()
>> >
>> >   {
>> >
>> >     super(Phase.PRE_PROTOCOL); // should I need to call super with this
>> > kind of parameter?
>> >
>> >
>> >
>> >     this.addAfter(SecurityCxfInterceptor.class.getName());
>> >
>> >   }
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > On Fri, Oct 18, 2013 at 5:56 PM, DSL <dlaprade@gmail.com> wrote:
>> >
>> > > Thomas,
>> > >
>> > > You just need to create a class that extends AbstractPhaseInterceptor
>> > > and add this in your constructor:
>> > >
>> > > addAfter( WSS4JOutInterceptro.class.getName() );
>> > >
>> > >
>> > > On Fri, Oct 18, 2013 at 11:04 AM, Thomas Manson
>> > > <dev.mansonthomas@gmail.com>wrote:
>> > >
>> > > > Hi,
>> > > >
>> > > >   I'm trying to call a webservice and dynamically change the
>> username.
>> > > >
>> > > >   To do that I've tried to add a CXF interceptor that would update
>> the
>> > > > current username setted by WSS4JOutInterceptor.
>> > > >
>> > > >   Unfortunately, I didn't succeed to make my interceptor to get
>> > executed
>> > > > after WSS4JOutInterceptor so the SoapHeader is empty.
>> > > >
>> > > > I've tried that :
>> > > >
>> > > > public class SecurityCxfInterceptor extends AbstractSoapInterceptor
>> > > >
>> > > > {
>> > > >
>> > > >   public SecurityCxfInterceptor()
>> > > >
>> > > >   {
>> > > >
>> > > >     super(Phase.PRE_PROTOCOL);
>> > > >
>> > > >
>> > > >
>> > > > //    this.getAfter().add(SAAJOutInterceptor.class.getName());
>> > > >
>> > > > //    this.getBefore().add(WSS4JOutInterceptor.class.getName());
>> > > >
>> > > >     this.addAfter(SecurityCxfInterceptor.class.getName());
>> > > >
>> > > >   }
>> > > >
>> > > > with this spring configuration
>> > > >
>> > > >
>> > > > <bean  id="SecurityCxfInterceptor"
>> > > > class="com.tibco.cts.amxbpm.fwk.security.SecurityCxfInterceptor" />
>> > > >
>> > > >
>> > > > <cxf:bus>
>> > > > <cxf:features>
>> > > > <p:policies />
>> > > > <cxf:logging />
>> > > > </cxf:features>
>> > > >  <cxf:outInterceptors>
>> > > >  <ref bean="SecurityCxfInterceptor" />
>> > > >  </cxf:outInterceptors>
>> > > > </cxf:bus>
>> > > >
>> > > >
>> > > > And I've aslo tried to extend WSS4JOutInterceptor but it doesn't
>> work,
>> > > > as WSS4JOutInterceptor just add an EndingInterceptor which point to
>> an
>> > > > internal call that does the job.
>> > > >
>> > > >
>> > > > Can somebody put me on the correct track to have my interceptor
>> > exectued
>> > > > after WSS4JOutInterceptor so that I can update the username?
>> > > >
>> > > >
>> > > >
>> > > > Thanks,
>> > > >
>> > > > Thomas.
>> > > >
>> > >
>> >
>>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message