On 2010-1-4, at 下午6:16, Philip wrote:

Hi

first of all happy new year and thanks for your replies!

On Thu, Dec 17, 2009 at 2:33 PM, Freeman Fang <[email protected]>wrote:


You needn't add JbiJAASInterceptor explicitly in spring bean, it's added by default for cxf bc consumer endpoint and passed in AuthenticationService as
argument for constructor.
The error you saw means JbiJAASInterceptor has no default constructor, it
needs an argument for constructor.


What we have to do here exaxtly - do we have to add something like
<constructor-arg> in the xbean.xml?
Hi,

No, you needn't add <constructor-arg> as JbiJAASInterceptor is added by default already. I just suggest you take a look at this JbiJAASInterceptor and learn how to extract username token from wss4j soap headers, I believe that's what you want to do.


Furthermore we don't really know ho to use the result-vector of this
Interceptor?
Basically you can just iterate this vector to find WSUsernameTokenPrincipal, then you can get username/password from it.

The main code already in JbiJAASInterceptor, something like

List<Object> results = (Vector<Object>)message.get(WSHandlerConstants.RECV_RESULTS);
            if (results == null) {
                return;
            }
            for (Iterator iter = results.iterator(); iter.hasNext();) {
                WSHandlerResult hr = (WSHandlerResult) iter.next();
                if (hr == null || hr.getResults() == null) {
                    return;
                }

for (Iterator it = hr.getResults().iterator(); it.hasNext();) { WSSecurityEngineResult er = (WSSecurityEngineResult) it.next();

if (er != null && er.getPrincipal() instanceof WSUsernameTokenPrincipal) { WSUsernameTokenPrincipal p = (WSUsernameTokenPrincipal)er.getPrincipal();
                        p.getName();//here you get the username
                        p.getPassword();//here you get the password
                    }
                }
            }

Freeman

Thanks again,
Philip + Nicolas


--
Freeman Fang
------------------------
Open Source SOA: http://fusesource.com

Reply via email to