Web services 如何从Mule中的WS-Security属性文件中读取用户名和密码
我已经在CXF webservice中实现了WS-security,以下是Mule流程:-Web services 如何从Mule中的WS-Security属性文件中读取用户名和密码,web-services,spring-security,mule,mule-studio,ws-security,Web Services,Spring Security,Mule,Mule Studio,Ws Security,我已经在CXF webservice中实现了WS-security,以下是Mule流程:- <context:property-placeholder location="classpath:conf/DBConnectionProp.properties"/> <!-- Authentication security--> <mule-ss:security-manager> <mule-ss:delegate
<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>
但是,如果删除${username}和${password}并直接提供用户名和密码,则运行正常。。我不知道如何从属性文件读取用户名和密码。。请帮忙。。是否有一种方法可以实现从属性文件读取ws-security???尝试使用:
username1=username
password1=password
以及:
因为与名称具有相同值的属性可能存在问题。多亏了David。。。
这是一个奇怪的问题,正如David所说,有效的解决方案是:
<ss:user name="${username1}" password="${password1}" authorities="ROLE_ADMIN" />
其中我不能将密钥用作用户名或密码
更新我发现错误是由于属性“用户名
”被Windows环境变量“用户名
”覆盖所致ref:-您所说的“以字符串形式读取整个值”是什么意思?
conf/DBConnectionProp.properties
中是否定义了username
和password
属性?我想象不是因为它的名字,这个文件似乎包含数据库访问的属性,而不是保护端点的属性。是的,David,我在那里定义了username=username password=password,但当我使用${username}或${password}Mmmh时,它仍然没有读取它,就好像没有加载属性文件一样。您可以将忽略资源未找到=“false”
添加到上下文:属性占位符
中,看看会发生什么吗?但是David,我正在从属性文件中获取其他值。。例如,如果我定义myValue=abcd。。然后我可以使用${myValue}在logger中获得它。那么,可能是ss:user
中的一个bug?
<ss:user name="${username1}" password="${password1}" authorities="ROLE_ADMIN" />
<ss:user name="${username1}" password="${password1}" authorities="ROLE_ADMIN" />