On 2010-1-4, at 下午7:34, Philip wrote:


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

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.


Right, this is what we like to do. We understood how the interceptor reads the username etc. But where we have to put the interceptor? Is it right to put the JbiJAASInterceptor in the xbean of the cxf-bc (consumer- part)? Or do
we have to use an own interceptor and include the JbiJAAS?

If its right to include the JbiJAASInterceptor directly in the xbean.xml (inInterceptor): what we have to do to fix the contructor/argument error at
deploy?

Hi,
No, you shouldn't include the JbiJAASInterceptor directly in the xbean.xml. You need write your own interceptor, assume your interceptor is your_interceptor_package.your_interceptor_class
put the code piece 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
                    }
                }
            }

in your interceptor, and in the xbean.xml for your cxf bc consumer, add your interceptor like
        <cxfbc:inInterceptors>
<bean class="your_interceptor_package.your_interceptor_class"/>
        </cxfbc:inInterceptors>

Freeman

Thanks!
N./P.


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

Reply via email to