【发布时间】:2014-09-18 15:59:51
【问题描述】:
我已经在 CXF 网络服务中实现了 WS-security,下面是 Mule 流程:-
<context:property-placeholder location="classpath:conf/DBConnectionProp.properties"/>
<!-- Authentication security-->
<mule-ss:security-manager>
<mule-ss:delegate-security-provider name="memory-provider" delegate-ref="authenticationManager" />
</mule-ss:security-manager>
<spring:beans>
<ss:authentication-manager alias="authenticationManager">
<ss:authentication-provider>
<ss:user-service id="userService" >
<ss:user name="${username}" password="${password}" authorities="ROLE_ADMIN" />
</ss:user-service>
</ss:authentication-provider>
</ss:authentication-manager>
</spring:beans>
<cxf:ws-security name="inboundSecurityConfig">
<cxf:mule-security-manager />
<cxf:ws-config>
<cxf:property key="action" value="UsernameToken" />
</cxf:ws-config>
</cxf:ws-security>
<!-- Authentication security ends-->
<flow name="securedSoapService">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8090" path="designation" doc:name="HTTP">
<cxf:jaxws-service serviceClass="com.getdesignation.test.services.schema.maindata.v1.GetDesignation">
<cxf:ws-security ref="inboundSecurityConfig"/>
</cxf:jaxws-service>
</http:inbound-endpoint>
<component class="com.getdesignation.vertu.services.schema.maindata.v1.Impl.GetDesignationImpl" />
</flow>
现在的问题是,它没有从属性文件中读取用户名和密码的值..
如果我尝试从属性文件 <ss:user name="${username}" password="${password}" authorities="ROLE_ADMIN" /> 中读取值,那么它会将整个值作为字符串读取,并导致以下异常为 invalid 用户名和密码:-
WARN 2014-09-18 21:23:41,426 [[SOAPSecurity2].connector.http.mule.default.receiver.02] org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor:
org.apache.ws.security.WSSecurityException: The security token could not be authenticated or authorized
at org.mule.module.cxf.support.MuleSecurityManagerValidator.validate(MuleSecurityManagerValidator.java:57)
at org.apache.ws.security.processor.UsernameTokenProcessor.handleUsernameToken(UsernameTokenProcessor.java:153)
at org.apache.ws.security.processor.UsernameTokenProcessor.handleToken(UsernameTokenProcessor.java:66)
at org.apache.ws.security.WSSecurityEngine.processSecurityHeader(WSSecurityEngine.java:396)
at org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor.handleMessage(WSS4JInInterceptor.java:281)
at org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor.handleMessage(WSS4JInInterceptor.java:100)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:122)
但是如果删除 ${username} 和 ${password} 并直接提供用户名和密码,那么它运行正常.. 我不知道如何让它从属性文件中读取用户名和密码.. 请help .. 有没有办法实现从属性文件读取 ws-security ???
【问题讨论】:
-
“将整个值读取为字符串”是什么意思?
username和password属性是否在conf/DBConnectionProp.properties中定义?我想不是因为它的名字,这个文件似乎包含用于数据库访问的属性,而不是用于保护端点的属性。 -
是的大卫我已经定义了用户名=用户名密码=密码但是当我使用 ${username} 或 ${password} 时它仍然没有读取它
-
嗯,好像没有加载属性文件。你能把
ignore-resource-not-found="false"加到context:property-placeholder看看会发生什么吗? -
但是大卫我从属性文件中获取其他值..例如,如果我定义 myValue=abcd ..那么我可以使用 ${myValue} 在记录器中获取它
-
那可能是
ss:user中的错误?
标签: web-services spring-security mule mule-studio ws-security