如何在spring-ws

时间:2019-06-27 11:02:58

标签: spring-security

我正在使用Spring Boot 2并收到以下错误:

org.springframework.ws.soap.security.wss4j2.Wss4jSecuritySecurementException:不提供密码回调;嵌套的异常是org.apache.wss4j.common.ext.WSSecurityException:没有提供密码回调     在org.springframework.ws.soap.security.wss4j2.Wss4jSecurityInterceptor.secureMessage(Wss4jSecurityInterceptor.java:577)〜[spring-ws-security-3.0.7.RELEASE.jar:na]     在org.springframework.ws.soap.security.AbstractWsSecurityInterceptor.handleRequest(AbstractWsSecurityInterceptor.java:210)〜[spring-ws-security-3.0.7.RELEASE.jar:na]     在org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:597)[spring-ws-core-3.0.7.RELEASE.jar:na]     在org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:555)[spring-ws-core-3.0.7.RELEASE.jar:na]     在org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:390)[spring-ws-core-3.0.7.RELEASE.jar:na]     在aero.sita.gsl.config.VisaAppAdaptor.getApplicationNumber(VisaAppAdaptor.java:27)[classes /:na]     在aero.sita.gsl.controller.VisaApplicationSearchController.getVisaDetails(VisaApplicationSearchController.java:33)[classes /:na]     在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)〜[na:1.8.0_212]     在sun.reflect.NativeMethodAccessorImpl.invoke(未知来源)〜[na:1.8.0_212]     在sun.reflect.DelegatingMethodAccessorImpl.invoke(未知来源)〜[na:1.8.0_212]     在java.lang.reflect.Method.invoke(未知来源)〜[na:1.8.0_212]     在org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)[spring-web-5.2.0.M3.jar:5.2.0.M3]     在org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)[spring-web-5.2.0.M3.jar:5.2.0.M3]     在org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105)上[spring-webmvc-5.2.0.M3.jar:5.2.0.M3]     在org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:889)上[spring-webmvc-5.2.0.M3.jar:5.2.0.M3]     在org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:794)上[spring-webmvc-5.2.0.M3.jar:5.2.0.M3]     在org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)上[spring-webmvc-5.2.0.M3.jar:5.2.0.M3]     在org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1039)[spring-webmvc-5.2.0.M3.jar:5.2.0.M3]     在org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)[spring-webmvc-5.2.0.M3.jar:5.2.0.M3]     在org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)[spring-webmvc-5.2.0.M3.jar:5.2.0.M3]     在org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:897)[spring-webmvc-5.2.0.M3.jar:5.2.0.M3]     在javax.servlet.http.HttpServlet.service(HttpServlet.java:634)[tomcat-embed-core-9.0.21.jar:9.0.21]     在org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882)[spring-webmvc-5.2.0.M3.jar:5.2.0.M3]     在javax.servlet.http.HttpServlet.service(HttpServlet.java:741)[tomcat-embed-core-9.0.21.jar:9.0.21]     在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)[tomcat-embed-core-9.0.21.jar:9.0.21]     在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)[tomcat-embed-core-9.0.21.jar:9.0.21]     在org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)[tomcat-embed-websocket-9.0.21.jar:9.0.21]     在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)[tomcat-embed-core-9.0.21.jar:9.0.21]     在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)[tomcat-embed-core-9.0.21.jar:9.0.21]     在org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)[spring-web-5.2.0.M3.jar:5.2.0.M3]     在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)[spring-web-5.2.0.M3.jar:5.2.0.M3]     在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)[tomcat-embed-core-9.0.21.jar:9.0.21]     在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)[tomcat-embed-core-9.0.21.jar:9.0.21]     在org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:92)[spring-web-5.2.0.M3.jar:5.2.0.M3]     在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)[spring-web-5.2.0.M3.jar:5.2.0.M3]     在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)[tomcat-embed-core-9.0.21.jar:9.0.21]     在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)[tomcat-embed-core-9.0.21.jar:9.0.21]     在org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93)[spring-web-5.2.0.M3.jar:5.2.0.M3]     在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)[spring-web-5.2.0.M3.jar:5.2.0.M3]     在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)[tomcat-embed-core-9.0.21.jar:9.0.21]     在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)[tomcat-embed-core-9.0.21.jar:9.0.21]     在org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)上[spring-web-5.2.0.M3.jar:5.2.0.M3]     在org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:109)[spring-web-5.2.0.M3.jar:5.2.0.M3]     在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)[tomcat-embed-core-9.0.21.jar:9.0.21]     在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)[tomcat-embed-core-9.0.21.jar:9.0.21]     在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)[tomcat-embed-core-9.0.21.jar:9.0.21]     在org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)[tomcat-embed-core-9.0.21.jar:9.0.21]     在org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)[tomcat-embed-core-9.0.21.jar:9.0.21]     在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)[tomcat-embed-core-9.0.21.jar:9.0.21]     在org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)[tomcat-embed-core-9.0.21.jar:9.0.21]     在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)[tomcat-embed-core-9.0.21.jar:9.0.21]     在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)[tomcat-embed-core-9.0.21.jar:9.0.21]     在org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)[tomcat-embed-core-9.0.21.jar:9.0.21]     在org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)上[tomcat-embed-core-9.0.21.jar:9.0.21]     在org.apache.coyote.AbstractProtocol $ ConnectionHandler.process(AbstractProtocol.java:853)[tomcat-embed-core-9.0.21.jar:9.0.21]     在org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.doRun(NioEndpoint.java:1587)[tomcat-embed-core-9.0.21.jar:9.0.21]     在org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)上[tomcat-embed-core-9.0.21.jar:9.0.21]     在java.util.concurrent.ThreadPoolExecutor.runWorker(未知来源)[na:1.8.0_212]     在java.util.concurrent.ThreadPoolExecutor $ Worker.run(未知来源)[na:1.8.0_212]     在org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61)[tomcat-embed-core-9.0.21.jar:9.0.21]     在java.lang.Thread.run(未知来源)[na:1.8.0_212] 引起原因:org.apache.wss4j.common.ext.WSSecurityException:没有提供密码回调     在org.apache.wss4j.dom.action.CustomTokenAction.execute(CustomTokenAction.java:42)〜[wss4j-ws-security-dom-2.2.0.jar:2.2.0]     在org.apache.wss4j.dom.handler.WSHandler.doSenderAction(WSHandler.java:238)〜[wss4j-ws-security-dom-2.2.0.jar:2.2.0]     在org.springframework.ws.soap.security.wss4j2.Wss4jHandler.doSenderAction(Wss4jHandler.java:63)〜[spring-ws-security-3.0.7.RELEASE.jar:na]     在org.springframework.ws.soap.security.wss4j2.Wss4jSecurityInterceptor.secureMessage(Wss4jSecurityInterceptor.java:574)〜[spring-ws-security-3.0.7.RELEASE.jar:na]     ...省略了60个共同的框架

@配置 公共类BeanConfig扩展了WsConfigurerAdapter {

@Autowired
private Environment env;

@Bean
public Jaxb2Marshaller marshaller() {
    Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
    marshaller.setContextPath("visaapp");
    return marshaller;
}

@Bean
public VisaAppAdaptor soapConnector(Jaxb2Marshaller marshaller) {
    VisaAppAdaptor client = new VisaAppAdaptor();
    client.setDefaultUri(env.getProperty("visa.application.uri"));
    client.setMarshaller(marshaller);
    client.setUnmarshaller(marshaller);
    ClientInterceptor[] interceptor = new ClientInterceptor[]{securityInterceptor()};
    client.setInterceptors(interceptor);
    return client;
}

@Bean
public Wss4jSecurityInterceptor securityInterceptor(){
    Wss4jSecurityInterceptor wss4jSecurityInterceptor = new Wss4jSecurityInterceptor();
    wss4jSecurityInterceptor.setValidationCallbackHandler(securityCallbackHandler());
    wss4jSecurityInterceptor.setSecurementSamlCallbackHandler(securityCallbackHandler());
    wss4jSecurityInterceptor.setSecurementActions(WSHandlerConstants.USERNAME_TOKEN + " " + WSHandlerConstants.CUSTOM_TOKEN);
    wss4jSecurityInterceptor.setSecurementUsernameTokenCreated(true);
    wss4jSecurityInterceptor.setSecurementPasswordType(WSConstants.PW_TEXT);
    wss4jSecurityInterceptor.setSecurementUsername("dummy");
    wss4jSecurityInterceptor.setSecurementPassword(env.getProperty("soap.auth.password"));
    wss4jSecurityInterceptor.setTimestampPrecisionInMilliseconds(true);
    //wss4jSecurityInterceptor.setSecurementPassword(env.getProperty("soap.auth.password"));
    return wss4jSecurityInterceptor;
}

@Bean
public ClientPasswordCallback pwdCallBack() {
    ClientPasswordCallback pwdCallBack = new ClientPasswordCallback();
    return pwdCallBack;

}

@Bean
public SimplePasswordValidationCallbackHandler securityCallbackHandler(){
    SimplePasswordValidationCallbackHandler callbackHandler = new SimplePasswordValidationCallbackHandler();
    Properties users = new Properties();
    users.setProperty("abc", "abc");
    callbackHandler.setUsers(users);
    return callbackHandler;
}

我想在Wss4jSecurityInterceptor中提供passwordcallback处理程序。

0 个答案:

没有答案