2016-12-01 275 views
0

我有一個Web應用程序,它使用apache cxf和spring啓動提供soap web服務。因此,我的類路徑中沒有xml文件來配置我的bean,它們都是在java配置中配置的。我想使用cxf中的ws-security設置身份驗證。 所以我想知道是否有針對SAAJInInterceptor和WSS4JInInterceptor豆類例如像這樣的Java配置:SAAJInInterceptor和WSS4JInInterceptor beans的Java配置

@Bean 
public ServletRegistrationBean cxfServlet() { 
    ServletRegistrationBean servlet = new ServletRegistrationBean(new CXFServlet(), "/services/*"); 
    servlet.setLoadOnStartup(1); 
    return servlet; 
} 

回答

0

你只需要在您創建的端點添加攔截器:

Map<String,Object> interceptorConfig = new HashMap<String,Object>(); 
// set the properties of you WSS4J config 
// ... 
WSS4JInInterceptor myInterceptor = new WSS4JInInterceptor(interceptorConfig); 
myEndpoint.getInInterceptors().add(myInterceptor); 

另一種解決方案是通過使用@InInterceptors

+0

感謝的註解您的及時反應......我該怎麼辦它使用@InInterceptors註釋? – FiokoSoft