You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by mamerkashi <ma...@csc.com> on 2010/11/18 22:05:04 UTC
passing parameters to callback handler
Hello,
I have setup my spring configuration to invoke WSS4JInInterceptor and
passing to it, as arguments MyPasswordCallback (please see below). I would
like to pass certain configuration parameters to MyPasswordCallback class.
Does anyone know how to achieve this?
Thanks in advance
<bean id="wss4jInInterceptorServer"
class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
<constructor-arg>
<map>
<entry key="action" value="UsernameToken"/>
<entry key="passwordType" value="PasswordText"/>
<entry key="passwordCallbackClass"
value="com.mycompany.security.MyPasswordCallback"/>
</map>
</constructor-arg>
</bean>
--
View this message in context: http://cxf.547215.n5.nabble.com/passing-parameters-to-callback-handler-tp3271496p3271496.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: passing parameters to callback handler
Posted by Daniel Kulp <dk...@apache.org>.
On Friday 19 November 2010 12:57:43 pm mamerkashi wrote:
> Daniel,
>
> Great, and thanks. That worked, but I don't understand why the key and
> value should be the same?? Can you please provide a little explanation?
> Thanks
Well, they don't really. WSS4J first looks for something with the
"passwordCallbackClass" key and casts that to a String. If that is null, it
then looks for something with a "passwordCallbackRef" and casts that to the
CallbackHandler.
Thus, the value just needs to be of the right type. (string for one, a
Callback object for the other). You could have inlined the callback:
<bean id="wss4jInInterceptorServer"
class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
<constructor-arg>
<map>
<entry key="action" value="UsernameToken"/>
<entry key="passwordType" value="PasswordText"/>
<entry key="passwordCallbackRef">
<bean class="com.myCompany.security.MyPasswordCallback">
<property name="key1" value="value1"/>
<property name="key2" value="value2"/>
</bean>
</entry>
</map>
</constructor-arg>
</bean>
and it would have been fine as well.
--
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
Re: passing parameters to callback handler
Posted by mamerkashi <ma...@csc.com>.
Daniel,
Great, and thanks. That worked, but I don't understand why the key and value
should be the same?? Can you please provide a little explanation? Thanks
--
Hossein Amerkashi
--
View this message in context: http://cxf.547215.n5.nabble.com/passing-parameters-to-callback-handler-tp3271496p3272730.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: passing parameters to callback handler
Posted by Daniel Kulp <dk...@apache.org>.
> <entry key="passwordCallbackClass"
> value-ref="passwordCallbackRef"/>
That should be:
<entry key="passwordCallbackRef"
value-ref="passwordCallbackRef"/>
The key is different.
Dan
On Friday 19 November 2010 10:21:32 am mamerkashi wrote:
> I tried as shown below, but get runtime exception of:
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
> <soap:Body>
> <soap:Fault>
> <faultcode>soap:Server</faultcode>
> <faultstring>com.MyCompany.service.security.MyPasswordCallback cannot be
> cast java.lang.String</faultstring>
> </soap:Fault>
> </soap:Body>
> </soap:Envelope>
>
>
> <bean id="wss4jInInterceptorServer"
> class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
> <constructor-arg>
> <map>
> <entry key="action" value="UsernameToken"/>
> <entry key="passwordType" value="PasswordText"/>
> <entry key="passwordCallbackClass"
> value-ref="passwordCallbackRef"/>
> </map>
> </constructor-arg>
> </bean>
>
>
> <bean id="passwordCallbackRef"
> class="com.myCompany.security.MyPasswordCallback">
> <property name="key1" value="value1"/>
> <property name="key2" value="value2"/>
> </bean>
--
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
Re: passing parameters to callback handler
Posted by mamerkashi <ma...@csc.com>.
I tried as shown below, but get runtime exception of:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>com.MyCompany.service.security.MyPasswordCallback cannot be
cast java.lang.String</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>
<bean id="wss4jInInterceptorServer"
class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
<constructor-arg>
<map>
<entry key="action" value="UsernameToken"/>
<entry key="passwordType" value="PasswordText"/>
<entry key="passwordCallbackClass"
value-ref="passwordCallbackRef"/>
</map>
</constructor-arg>
</bean>
<bean id="passwordCallbackRef"
class="com.myCompany.security.MyPasswordCallback">
<property name="key1" value="value1"/>
<property name="key2" value="value2"/>
</bean>
--
View this message in context: http://cxf.547215.n5.nabble.com/passing-parameters-to-callback-handler-tp3271496p3272450.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: passing parameters to callback handler
Posted by Daniel Kulp <dk...@apache.org>.
On Thursday 18 November 2010 4:05:04 pm mamerkashi wrote:
> Hello,
>
> I have setup my spring configuration to invoke WSS4JInInterceptor and
> passing to it, as arguments MyPasswordCallback (please see below). I would
> like to pass certain configuration parameters to MyPasswordCallback class.
> Does anyone know how to achieve this?
>
> Thanks in advance
>
>
> <bean id="wss4jInInterceptorServer"
> class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
> <constructor-arg>
> <map>
> <entry key="action" value="UsernameToken"/>
> <entry key="passwordType" value="PasswordText"/>
> <entry key="passwordCallbackClass"
> value="com.mycompany.security.MyPasswordCallback"/>
> </map>
> </constructor-arg>
> </bean>
I THINK (I'm not 100% sure on this), you can do:
<entry key="passwordCallbackRef">
<bean class="com.mycompany.security.MyPasswordCallback">
<property .....>
</bean>
</entry>
or similar to pass an actual instance of the callback class in.
--
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog