如何在Camel(最好是蓝图)中的CXF端点(SOAP)中实现OAuth流?

问题描述 投票:1回答:1

我想通过camel-cxf端点来解决SOAP Web服务。如何实现OAuth流程,最好是在蓝图中?这是有意义的还是我必须自己实施?

oauth-2.0 apache-camel cxf jbossfuse blueprint-osgi
1个回答
1
投票

我找到了很好的documentation

基本上,您必须实现拦截器和过滤器:您的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>
© www.soinside.com 2019 - 2024. All rights reserved.