CXF运行时和IBM WebSphere v8.5.5的Web服务基本身份验证问题

时间:2018-09-12 13:48:25

标签: web-services websphere

我们正在托管通过Apache CXF 3.0.1公开服务的Web服务(JAX-WS)。我们已经在IBM WebSphere v8.5.5.5上成功部署了它,并提出了以下建议:

  • 将类加载设置为PARENT_LAST = true
  • DisableIBMJAXWSEngine = true

bean定义文件的摘录如下:

<jaxws:endpoint id="VPMSWebService"
        implementor="com.xxxxx.CustomServiceImpl" address="/vWebService">
        <jaxws:features>
            <wsa:addressing xmlns:wsa="http://cxf.apache.org/ws/addressing" />
        </jaxws:features>
        <jaxws:properties>
            <entry key="jaxb-validation-event-handler">
                <bean class="com.xxxxx.CXFValidationEventHandler" />
            </entry>
        </jaxws:properties>     
        <jaxws:inInterceptors>
            <bean class="com.xxxxxx.IncomingAuthenticationInterceptor"/>
        </jaxws:inInterceptors>
        <jaxws:inFaultInterceptors>
            <bean class="com.xxxxx.IncomingAuthenticationFaultInterceptor"/>
        </jaxws:inFaultInterceptors>      
        <jaxws:handlers>
            <bean class="com.xxxxxxx.interceptors.AuthenticationHandler"/>
        </jaxws:handlers>  
</jaxws:endpoint>

在部署描述符中以声明方式引入了基本身份验证,如下所示:

<security-constraint>
    <web-resource-collection>
        <web-resource-name>web service resource</web-resource-name>
        <url-pattern>/*</url-pattern>
        <http-method>GET</http-method>
        <http-method>POST</http-method>     
    </web-resource-collection>
    <auth-constraint>
        <role-name>SvcLayerUser</role-name>
    </auth-constraint>
    <user-data-constraint>
        <transport-guarantee>NONE</transport-guarantee>
    </user-data-constraint>
  </security-constraint>
  <security-role>
    <role-name>SvcLayerUser</role-name>
  </security-role>
  <login-config>
    <auth-method>BASIC</auth-method>
    <realm-name>Authentication</realm-name>
  </login-config>

当使用SOAPUI作为具有正确用户名/密码对的客户端调用服务时,调用是正常的,并且正确的SOAP响应将返回到调用程序。如果问题出在XML上,则分别返回SOAP Fault。启用调试后,我们可以浏览应用程序的完整流程。

当我们输入错误的用户名或密码时会出现问题。然后,WebSphere容器仅处理身份验证,将不带任何内容的401 HTTP状态代码传递给SOAPUI。任何基于CXF的拦截器或处理程序都不会被调用。

[9/18/18 4:23:05:439 EDT] 00000082 FfdcProvider W com.ibm.ws.ffdc.impl.FfdcProvider logIncident FFDC1003I:在E:\ WAS8.5 \ IBM \ WebSphere \上发出的FFDC事件AppServer \ profiles \ AppSrv20 \ logs \ ffdc \ server1_4c0ec188_18.09.18_04.23.05.3929133133879993856345.txt com.ibm.websphere.security.PasswordCheckFailedException 190 [9/18/18 4:23:05:454 EDT] 00000082 DMAdapter I com.ibm.ws.ffdc.impl.DMAdapter getAnalysisEngine FFDC1009I:使用数据库的分析引擎:E:\ WAS8.5 \ IBM \ WebSphere \ AppServer \ properties \ logbr \ ffdc \ adv \ ffdcdb.xml [9/18/18 4:23:05:470 EDT] 00000082 FfdcProvider W com.ibm.ws.ffdc.impl.FfdcProvider logIncident FFDC1003I:FFDC事件在E:\ WAS8.5 \ IBM \ WebSphere \ AppServer \ profiles上发出\ AppSrv20 \ logs \ ffdc \ server1_4c0ec188_18.09.18_04.23.05.3924076528169475779324.txt com.ibm.ws.security.ltpa.LTPAServerObject.authenticate 1020 [9/18/18 4:23:05:470 EDT] 00000082 LTPAServerObj E SECJ0369E:使用LTPA时身份验证失败。异常是com.ibm.websphere.wim.exception.PasswordCheckFailedException:CWWIM4513E'bob'主体名称的密码匹配失败。 [9/18/18 4:23:05:485 EDT] 00000082 FfdcProvider W com.ibm.ws.ffdc.impl.FfdcProvider logIncident FFDC1003I:FFDC事件在E:\ WAS8.5 \ IBM \ WebSphere \ AppServer \ profiles上发出\ AppSrv20 \ logs \ ffdc \ server1_4c0ec188_18.09.18_04.23.05.4701707172482039548991.txt com.ibm.websphere.security.auth.WSLoginFailedException 250 [9/18/18 4:23:05:485 EDT] 00000082 FfdcProvider W com.ibm.ws.ffdc.impl.FfdcProvider logIncident FFDC1003I:FFDC事件在E:\ WAS8.5 \ IBM \ WebSphere \ AppServer \ profiles上发出\ AppSrv20 \ logs \ ffdc \ server1_4c0ec188_18.09.18_04.23.05.4703645264312534190424.txt com.ibm.ws.security.server.lm.ltpaLoginModule.login 452 [9/18/18 4:23:05:485 EDT] 00000082 FfdcProvider W com.ibm.ws.ffdc.impl.FfdcProvider logIncident FFDC1003I:FFDC事件在E:\ WAS8.5 \ IBM \ WebSphere \ AppServer \ profiles上发出\ AppSrv20 \ logs \ ffdc \ server1_4c0ec188_18.09.18_04.23.05.4859153488925589622788.txt com.ibm.ws.security.server.lm.wsMapDefaultInboundLoginModule.login 860 [9/18/18 4:23:05:501 EDT] 00000082 FfdcProvider W com.ibm.ws.ffdc.impl.FfdcProvider logIncident FFDC1003I:FFDC事件在E:\ WAS8.5 \ IBM \ WebSphere \ AppServer \ profiles上发出\ AppSrv20 \ logs \ ffdc \ server1_4c0ec188_18.09.18_04.23.05.4853176694169720358643.txt com.ibm.ws.security.auth.JaasLoginHelper.jaas_login 503 [9/18/18 4:23:05:501 EDT] 00000082 FfdcProvider W com.ibm.ws.ffdc.impl.FfdcProvider logIncident FFDC1003I:FFDC事件在E:\ WAS8.5 \ IBM \ WebSphere \ AppServer \ profiles上发出\ AppSrv20 \ logs \ ffdc \ server1_4c0ec188_18.09.18_04.23.05.5012191986958630799174.txt com.ibm.ws.security.auth.ContextManagerImpl.login 4948 [9/18/18 4:23:05:641 EDT] 00000082 LTPAServerObj E SECJ0369E:使用LTPA时身份验证失败。异常是com.ibm.websphere.wim.exception.PasswordCheckFailedException:CWWIM4513E'bob'主体名称的密码匹配失败。.

FFDC日志文件具有

[9/18/18 4:23:05:470 EDT] FFDC异常:com.ibm.websphere.security.auth.WSLoginFailedException SourceId:com.ibm.ws.security.server.lm.ltpaLoginModule.login ProbeId :452记者:com.ibm.ws.security.server.lm.ltpaLoginModule@a2cacf0e com.ibm.websphere.wim.exception.PasswordCheckFailedException:CWWIM4513E'bob'主体名称的密码匹配失败。     在com.ibm.ws.wim.adapter.file.was.FileAdapter.login(FileAdapter.java:2455)     在com.ibm.ws.wim.ProfileManager.loginImpl(ProfileManager.java:3859)     在com.ibm.ws.wim.ProfileManager.genericProfileManagerMethod(ProfileManager.java:360)     在com.ibm.ws.wim.ProfileManager.login(ProfileManager.java:468)     在com.ibm.websphere.wim.ServiceProvider.login(ServiceProvider.java:545)     在com.ibm.ws.wim.registry.util.LoginBridge.checkPassword(LoginBridge.java:194)     在com.ibm.ws.wim.registry.WIMUserRegistry $ 1.run(WIMUserRegistry.java:270)     在com.ibm.ws.wim.registry.WIMUserRegistry $ 1.run(WIMUserRegistry.java:262)     在com.ibm.ws.security.auth.ContextManagerImpl.runAs(ContextManagerImpl.java:5554)     在com.ibm.ws.security.auth.ContextManagerImpl.runAsSystem(ContextManagerImpl.java:5680)     在com.ibm.ws.wim.security.authz.jacc.JACCSecurityManager.runAsSuperUser(JACCSecurityManager.java:438)     位于com.ibm.ws.wim.env.was.JACCAuthorizationService.runAsSuperUser(JACCAuthorizationService.java:1086)     在com.ibm.ws.wim.security.authz.ProfileSecurityManager.runAsSuperUser(ProfileSecurityManager.java:285)     在com.ibm.ws.wim.registry.WIMUserRegistry.checkPassword(WIMUserRegistry.java:261)     在com.ibm.ws.security.registry.UserRegistryImpl.checkPassword(UserRegistryImpl.java:394)     在com.ibm.ws.security.ltpa.LTPAServerObject.authenticate(LTPAServerObject.java:997)     在com.ibm.ws.security.server.lm.ltpaLoginModule.login(ltpaLoginModule.java:660)     在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处     在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95)     在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:56)     在java.lang.reflect.Method.invoke(Method.java:620)     在javax.security.auth.login.LoginContext.invoke(LoginContext.java:781)     在javax.security.auth.login.LoginContext.access $ 000(LoginContext.java:215)     在javax.security.auth.login.LoginContext $ 4.run(LoginContext.java:706)     在javax.security.auth.login.LoginContext $ 4.run(LoginContext.java:704)     在java.security.AccessController.doPrivileged(AccessController.java:488)     在javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:703)     在javax.security.auth.login.LoginContext.login(LoginContext.java:609)     在com.ibm.ws.security.auth.JaasLoginHelper.jaas_login(JaasLoginHelper.java:491)     在com.ibm.ws.security.auth.ContextManagerImpl.login(ContextManagerImpl.java:4892)     在com.ibm.ws.security.auth.ContextManagerImpl.login(ContextManagerImpl.java:4494)     在com.ibm.ws.security.auth.ContextManagerImpl.login(ContextManagerImpl.java:4490)     在com.ibm.ws.security.web.WebAuthenticator.basicAuthenticate(WebAuthenticator.java:3722)     在com.ibm.ws.security.web.WebAuthenticator.handleBasicAuth(WebAuthenticator.java:2869)     在com.ibm.ws.security.web.WebAuthenticator.authenticate(WebAuthenticator.java:3235)     在com.ibm.ws.security.web.WebCollaborator.SetAuthenticatedSubjectIfNeeded(WebCollaborator.java:3232)     在com.ibm.ws.security.web.WebCollaborator.authorize(WebCollaborator.java:716)     在com.ibm.ws.security.web.EJSWebCollaborator.preInvoke(EJSWebCollaborator.java:446)     在com.ibm.ws.webcontainer.collaborator.WebAppSecurityCollaboratorImpl.preInvoke(WebAppSecurityCollaboratorImpl.java:230)     在com.ibm.wsspi.webcontainer.collaborator.CollaboratorHelper.preInvokeCollaborators(CollaboratorHelper.java:436)     在com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1089)     在com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:4028)     在com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)     在com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1016)     在com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1817)     在com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:200)     在com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:463)     在com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:530)     在com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:316)     在com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:287)     在com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)     在com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)     在com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175)     在com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)     在com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)     在com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)     在com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)     在com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)     在com.ibm.io.async.ResultHandler $ 2.run(ResultHandler.java:905)     在com.ibm.ws.util.ThreadPool $ Worker.run(ThreadPool.java:1892)

主要问题是:

  1. 为什么在基于Windows的CXF组件不被调用时 用户名或密码错误会发生异常吗?为什么选择WebSphere 容器引发异常,并将控件返回给调用者 直接吗?

  2. 为应对上述WAS,我们应该对EAR进行哪些更改     容器异常,因此我们可以使其成为详细的SOAP错误和     返回给呼叫者更多信息?

1 个答案:

答案 0 :(得分:0)

在进行基本身份验证时,甚至在服务器身份到达Webcontainer之前,都会在服务器基础结构上对其进行检查,并且由于容器已经知道您的用户未通过身份验证,因此它甚至不会调用Web服务引擎。

您需要自定义登录过程以拦截该请求(例如,自定义登录模块),或者在处理程序中实现整个登录逻辑(例如,调用WSLogin),两者都太过宽泛,无法在此处进行讨论。

首先,您可以查看此页面Advanced authentication in WebSphere Application Server

两者都是复杂的解决方案,因此,我强烈建议您这样做,因为目前,您正在返回明确的消息,即请求未经过任何身份验证,并且由于它是WS调用,因此您实际上不需要提供任何自定义的人工操作可读的消息。此外,显示更多详细信息“为什么身份验证失败”会削弱您的安全性,向攻击者提供更多信息,通常不建议这样做。