Advertisement
gusto2

CXF WS authentication and authorization

Nov 17th, 2013
851
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 4.03 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <blueprint
  3.    xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
  4.    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  5.    xmlns:cxf="http://cxf.apache.org/blueprint/core"
  6.    xmlns:camelcxf="http://camel.apache.org/schema/blueprint/cxf"
  7.    xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
  8.    xsi:schemaLocation="
  9.        http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
  10.        http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd http://camel.apache.org/schema/blueprint
  11.        http://camel.apache.org/schema/blueprint/camel-blueprint.xsd http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0
  12.        http://svn.apache.org/repos/asf/aries/trunk/blueprint/blueprint-cm/src/main/resources/org/apache/aries/blueprint/compendium/cm/blueprint-cm-1.1.0.xsd
  13.        http://cxf.apache.org/blueprint/core http://cxf.apache.org/schemas/blueprint/core.xsd">
  14.  
  15.  
  16.     <bean id="authenticationInterceptor"
  17.          class="org.apache.cxf.interceptor.security.JAASLoginInterceptor">
  18.         <property name="contextName" value="karaf"/>
  19.         <property name="roleClassifier" value="RolePrincipal"/>
  20.         <property name="roleClassifierType" value="classname"/>
  21.     </bean>
  22.    
  23.     <bean id="wsSecInterceptor" class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
  24.         <argument>
  25.             <map>
  26.                 <entry key="action" value="UsernameToken"/>
  27.                 <entry key="passwordType" value="PasswordText"/>
  28.             </map>
  29.         </argument>
  30.     </bean>    
  31.        
  32.     <bean id="authorizationInterceptor" class="org.apache.cxf.interceptor.security.SimpleAuthorizingInterceptor">
  33. <!-- no wildcard support, names need to match exactly -->
  34. <!--        <property name="methodRolesMap">
  35.            <map>
  36.                
  37.                <entry key="method_1" value="ROLE_USER ROLE_ADMIN"/>
  38.                <entry key="method_2" value="ROLE_ADMIN"/>
  39.            </map>
  40.        </property>-->
  41.         <!-- its possible to define global roles that apply to all WSDL operations not listed above -->
  42.         <property name="globalRoles" value="ROLE_WS_USER"/>
  43.     </bean>        
  44.    
  45.     <camelcxf:cxfEndpoint id="egovAddressEndpoint"
  46.                          address="/egov/api/external/AddressService"
  47.                          xmlns:addr="http://address.ws.egov.xxx.com/v1_0/ws"
  48.                          serviceName="addr:eGovAddressService"
  49.                          endpointName="addr:AddressServicePortBinding"
  50.                          serviceClass="com.xxx.egov.ws.address.v1_0.ws.EGovAddressService">
  51.         <!--        wsdlURL="classpath:com/xxx/egov/ws/address/v1_0/AddressService.wsdl"-->
  52.         <camelcxf:properties>
  53.             <entry key="dataFormat" value="PAYLOAD" />
  54. <!-- maybe one of these is enough, I put both directives to be sure.
  55.    The intention is not to provide a password callback, but let the CXF
  56.    use an underlaying security context to authenticate and authorize users -->
  57.             <entry key="ws-security.ut.no-callbacks" value="true"/>
  58.             <entry key="ws-security.validate.token" value="false"/>
  59.         </camelcxf:properties>
  60.         <camelcxf:outInterceptors>
  61.             <!--<bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>-->
  62.         </camelcxf:outInterceptors>
  63.         <camelcxf:inInterceptors>
  64.             <!--<bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>-->
  65.             <ref component-id="wsSecInterceptor" />
  66.             <ref component-id="authenticationInterceptor"/>  
  67.             <ref component-id="authorizationInterceptor" />          
  68.         </camelcxf:inInterceptors>
  69.     </camelcxf:cxfEndpoint>
  70.    
  71.     <camelContext xmlns="http://camel.apache.org/schema/blueprint" id="addrApiWs">
  72.         <route id="egovWsAddress">
  73.             <from uri="egovAddressEndpoint" />
  74.             <to uri="vm:egov.logging" />
  75.         </route>
  76.     </camelContext>
  77.    
  78. </blueprint>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement