java在Apache CXF Blueprint中为Web服务调用属性文件来实例用户和密码是否可行?
我对Fuse和WebServices比较陌生
我用BasicAuthorizationInterceptor做了一个SOAP Web服务,这是实际的上下文,它正在工作:
<cxf:cxfEndpoint address="/SampleEp" id="insertSomethingToDB" serviceClass="com.example.sample_ep.SampleEp" wsdlURL="wsdl/SampleEP.wsdl">
<cxf:inInterceptors>
<ref component-id="securityInterceptor"/>
</cxf:inInterceptors>
</cxf:cxfEndpoint>
<bean
class="com.example.middleware.BasicAuthAuthorizationInterceptor" id="securityInterceptor">
<property name="users">
<map>
<entry key="user" value="password"/>
</map>
</property>
</bean>
因此,为了增加安全性,我将尝试将用户放在项目外部的属性文件中,这是一个想法:
<cxf:cxfEndpoint address="/SampleEp" id="insertSomethingToDB" serviceClass="com.example.sample_ep.SampleEp" wsdlURL="wsdl/SampleEP.wsdl">
<cxf:inInterceptors>
<ref component-id="securityInterceptor"/>
</cxf:inInterceptors>
</cxf:cxfEndpoint>
<bean
class="com.example.middleware.BasicAuthAuthorizationInterceptor" id="securityInterceptor">
<property name="users">
<map>
<entry key="${cxf.user}" value="${cxf.password}"/>
</map>
</property>
</bean>
<bean> add some code to add a *.properties file outside the project </bean>
有可能吗? 还是我真的不喜欢这个
# 1 楼答案
好的,我用Jasypt和JAAS尝试了一些方法,得到了解决方案:
只需将以下内容添加到蓝图标题:
瞧,它在您的项目之外使用一个安全的用户/通过验证:D
最重要的是,属性文件需要以下格式: