我是Fuse和Web服务的新手。
我使用basicauthauthorization Interpector进行了SOAP WebService,这是实际的上下文,它正在工作:
<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>
那是可能的吗?还是我真的很糟糕?
好吧,我尝试了一些JASYPT,JAAS并获取解决方案:
<ext:property-placeholder>
<ext:location>file:/this/is/your/path/to/your/propertie/file/cxf.properties
</ext:location>
</ext:property-placeholder>
<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>
仅添加到您的蓝图标题:
xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0"
和voilà,它正在与您的项目外的安全用户/通过验证:D
和最重要的是,属性文件需要此格式:
#cxf.properties
cxf.user=administrator
cxf.password=password