I would like to address a SOAP web service via camel-cxf endpoint. How can I implement an OAuth flow, preferably in the blueprint? Is that configurative or do I have to implement it myself?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
I have found nice documentation on this:
Basically, you have to implement interceptors and filters: Your blueprint.xml
<bean id="tvServiceClientFactory" class="org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean">
<property name="address" value="http://localhost:${http.port}/services/oauth/validate"/>
<property name="headers">
<map>
<entry key="Accept" value="application/xml"/>
<entry key="Content-Type" value="application/x-www-form-urlencoded"/>
</map>
</property>
</bean>
<bean id="tvServiceClient" factory-bean="tvServiceClientFactory" factory-method="createWebClient"/>
<bean id="tokenValidator" class="org.apache.cxf.rs.security.oauth2.filters.AccessTokenValidatorClient">
<property name="tokenValidatorClient" ref="tvServiceClient"/>
</bean>
<bean id="oauthFiler" class="org.apache.cxf.rs.security.oauth2.filters.OAuthRequestFilter">
<property name="tokenValidator" ref="tokenValidator"/>
</bean>
<bean id="myApp" class="org.myapp.MyApp"/>
<jaxrs:server id="fromThirdPartyToMyApp" address="/thirdparty-to-myapp">
<jaxrs:serviceBeans>
<ref bean="myApp"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="oauthFilter"/>
</jaxrs:providers>
</jaxrs:server>