Author: ffang
Date: Tue Dec 13 04:54:57 2011
New Revision: 1213565

URL: http://svn.apache.org/viewvc?rev=1213565&view=rev
Log:
[SMX4-1006]add a cxf example with blueprint configuration

Added:
    servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/
    
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/README.txt
    
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/client.html
    
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/pom.xml
    servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/
    
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/
    
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/java/
    
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/java/org/
    
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/java/org/apache/
    
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/java/org/apache/servicemix/
    
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/java/org/apache/servicemix/examples/
    
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/java/org/apache/servicemix/examples/cxf/
    
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/java/org/apache/servicemix/examples/cxf/Client.java
    
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/java/org/apache/servicemix/examples/cxf/ClientPasswordCallback.java
    
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/java/org/apache/servicemix/examples/cxf/CustomerSecurityInterceptor.java
    
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/java/org/apache/servicemix/examples/cxf/HelloWorld.java
    
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/java/org/apache/servicemix/examples/cxf/HelloWorldImpl.java
    
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/resources/
    
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/resources/OSGI-INF/
    
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/resources/OSGI-INF/blueprint/
    
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/resources/OSGI-INF/blueprint/blueprint.xml
   (with props)
Modified:
    
servicemix/smx4/features/trunk/assemblies/apache-servicemix-jbi/src/main/filtered-resources/README.txt
    
servicemix/smx4/features/trunk/assemblies/apache-servicemix/src/main/filtered-resources/features.xml
    servicemix/smx4/features/trunk/examples/cxf/pom.xml

Modified: 
servicemix/smx4/features/trunk/assemblies/apache-servicemix-jbi/src/main/filtered-resources/README.txt
URL: 
http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/assemblies/apache-servicemix-jbi/src/main/filtered-resources/README.txt?rev=1213565&r1=1213564&r2=1213565&view=diff
==============================================================================
--- 
servicemix/smx4/features/trunk/assemblies/apache-servicemix-jbi/src/main/filtered-resources/README.txt
 (original)
+++ 
servicemix/smx4/features/trunk/assemblies/apache-servicemix-jbi/src/main/filtered-resources/README.txt
 Tue Dec 13 04:54:57 2011
@@ -52,10 +52,16 @@ CXF examples
   Uses CXF to create a web service enabled for WS-ReliableMessaging, and 
exposes
   it through the OSGi HTTP service.
 
-- cxf-ws-security
-  Uses CXF to create a web service enabled for WS-Security, and exposes
-  it through the OSGi HTTP service.  It includes a custom CallbackHandler 
implementation
-  to show you how to implement your own authentication logic.
+- cxf-ws-security-osgi
+  Create a web service with CXF using WS-SECURITY and expose it through the 
OSGi HTTP
+  Service, then it will leverage cxf JAASLoginInterceptor to authenticate 
against karaf
+  default jaas configuration.
+
+- cxf-ws-security-blueprint
+  Create a web service with CXF using WS-SECURITY and blueprint configuration,
+  and expose it through the OSGi HTTP
+  Service, then it will leverage cxf JAASLoginInterceptor to authenticate 
against karaf
+  default jaas configuration.
 
 
 Karaf examples

Modified: 
servicemix/smx4/features/trunk/assemblies/apache-servicemix/src/main/filtered-resources/features.xml
URL: 
http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/assemblies/apache-servicemix/src/main/filtered-resources/features.xml?rev=1213565&r1=1213564&r2=1213565&view=diff
==============================================================================
--- 
servicemix/smx4/features/trunk/assemblies/apache-servicemix/src/main/filtered-resources/features.xml
 (original)
+++ 
servicemix/smx4/features/trunk/assemblies/apache-servicemix/src/main/filtered-resources/features.xml
 Tue Dec 13 04:54:57 2011
@@ -137,6 +137,12 @@
         <bundle 
dependency="true">mvn:org.springframework/spring-beans/${spring.version}</bundle>
         
<bundle>mvn:org.apache.servicemix.examples/cxf-ws-security-osgi/${version}</bundle>
     </feature>
+    <feature name="examples-cxf-ws-security-blueprint" version="${version}" 
resolver="(obr)">
+        <feature>cxf-osgi</feature>
+        <bundle 
dependency="true">mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.jbi-api-1.0/${servicemix.specs.version}</bundle>
+        <bundle 
dependency="true">mvn:org.apache.servicemix/servicemix-utils/${servicemix.utils.version}</bundle>
+        
<bundle>mvn:org.apache.servicemix.examples/cxf-ws-security-blueprint/${version}</bundle>
+    </feature>
     <feature name="examples-cxf-ws-rm" version="${version}" resolver="(obr)">
         
<bundle>mvn:org.apache.servicemix.examples/cxf-ws-rm/${version}</bundle>
     </feature>

Added: 
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/README.txt
URL: 
http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/README.txt?rev=1213565&view=auto
==============================================================================
--- 
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/README.txt
 (added)
+++ 
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/README.txt
 Tue Dec 13 04:54:57 2011
@@ -0,0 +1,258 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+CXF WS-SECURITY OSGi HTTP WEB SERVICE
+=========================
+
+Purpose
+-------
+Create a web service with CXF using WS-SECURITY and blueprint configuration,
+and expose it through the OSGi HTTP
+Service, then it will leverage cxf JAASLoginInterceptor to authenticate 
against karaf
+default jaas configuration.
+
+
+Explanation
+-----------
+The web service is a simple JAX-WS web service with ws-security UsernameToken 
action called HelloWorldSecurity. The 
+interface and the implementation are located in the src/main/java/org/
+apache/servicemix/examples/cxf directory of this example.
+
+The blueprint.xml file, located in the src/main/resources/OSGI-INF/blueprint
+directory:
+
+
+1. Configures the web service endpoint as follows:
+
+    <jaxws:endpoint id="helloWorld"
+        implementor="org.apache.servicemix.examples.cxf.HelloWorldImpl"
+        address="/HelloWorldSecurity">
+        <jaxws:inInterceptors>
+            <bean class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
+                 <property name="properties">
+                     <map>
+                         <entry key="action" value="UsernameToken"/>
+                         <entry key="passwordType" value="PasswordTest"/>
+                     </map>
+                 </property>
+             </bean>          
+            <ref component-id="authenticationInterceptor"/>
+        </jaxws:inInterceptors>
+        <jaxws:properties>
+            <entry key="ws-security.validate.token" value="false"/>
+        </jaxws:properties>
+    </jaxws:endpoint>
+    <bean id="authenticationInterceptor" 
class="org.apache.cxf.interceptor.security.JAASLoginInterceptor">
+       <property name="contextName" value="karaf"/>
+    </bean>
+
+This will leverage cxf JAASLoginInterceptor to authenticate against karaf 
default jaas configuration through property contextName, which store 
username/password/role in SMX_HOME/etc/users.properties, to run this example, 
need add joe=password in etc/users.properties. Users can easily change to use 
other jaas context(JDBC,LDAP etc) as described from 
http://karaf.apache.org/manual/2.2.4/developers-guide/security-framework.html.
+
+
+Prerequisites for Running the Example
+-------------------------------------
+1. You must have the following installed on your machine:
+
+   - JDK 1.6 or higher
+   
+   - Maven 2.2.1 or higher
+   
+  For more information, see the README in the top-level examples
+  directory.
+
+
+2. Start ServiceMix by running the following command:
+
+  <servicemix_home>/bin/servicemix          (on UNIX)
+  <servicemix_home>\bin\servicemix          (on Windows)
+
+
+Running the Example
+-------------------
+You can run the example in two ways:
+
+- A. Using a Prebuilt Deployment Bundle: Quick and Easy
+This option is useful if you want to see the example up and
+running as quickly as possible.
+
+- B. Building the Example Bundle Yourself
+This option is useful if you want to change the example in any
+way. It tells you how to build and deploy the example. This
+option might be slower than option A because, if you do not
+already have the required bundles in your local Maven
+repository, Maven will have to download the bundles it needs.
+
+A. Using a Prebuilt Deployment Bundle: Quick and Easy
+-----------------------------------------------------
+To install and run a prebuilt version of this example, enter
+the following command in the ServiceMix console:
+
+  features:install examples-cxf-ws-security-blueprint
+  
+This command makes use of the ServiceMix features facility. For
+more information about the features facility, see the README.txt
+file in the examples parent directory.
+
+To view the service WSDL, open your browser and go to the following
+URL:
+
+  http://localhost:8181/cxf/HelloWorldSecurity?wsdl
+
+Note, if you use Safari, right click the window and select
+'Show Source'.
+
+Running a Client
+----------------
+To run the web client:
+
+1. Open the client.html, which is located in the same directory as
+   this README file, in your favorite browser.
+
+2. Click the Send button to send a request.
+
+   Once the request has been successfully sent, a response similar
+   to the following should appear in the right-hand panel of the
+   web page:
+   
+   STATUS: 200
+   <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";>
+     <soap:Body><ns2:sayHiResponse xmlns:ns2="http://cxf.examples.
+     servicemix.apache.org/"><return>Hello John Doe</return>
+     </ns2:sayHiResponse>
+     </soap:Body>
+   </soap:Envelope>
+
+To run the java code client:
+
+1. Change to the <servicemix_home>/examples/cxf-ws-security-blueprint
+   directory.
+
+2. Run the following command:
+
+     mvn compile exec:java
+
+   If the client request is successful, 
+   it will print out
+       Hello ffang
+   in the ServiceMix console:
+
+
+Changing /cxf servlet alias
+---------------------------
+By default CXF Servlet is assigned a '/cxf' alias. You can
+change it in a couple of ways
+
+a. Add org.apache.cxf.osgi.cfg to the /etc directory and set
+   the 'org.apache.cxf.servlet.context' property, for example:
+   
+     org.apache.cxf.servlet.context=/custom
+   
+b. Use shell config commands, for example :
+   
+     config:edit org.apache.cxf.osgi   
+     config:propset org.apache.cxf.servlet.context /super
+     config:update
+
+
+B. Building the Example Bundle Yourself
+---------------------------------------
+To install and run the example where you build the example bundle
+yourself, complete the following steps:
+
+1. If you have already run the example using the prebuilt version as
+   described above, you must first uninstall the 
examples-cxf-ws-security-blueprint
+   feature by entering the following command in the ServiceMix console:
+
+     features:uninstall examples-cxf-ws-security-blueprint
+
+   
+2. Build the example by opening a command prompt, changing directory to
+   examples/cxf-ws-security-blueprint (this example) and entering the 
following Maven
+   command:
+
+     mvn install
+   
+   If all of the required OSGi bundles are available in your local
+   Maven repository, the example will build very quickly. Otherwise
+   it may take some time for Maven to download everything it needs.
+   
+   The mvn install command builds the example deployment bundle and
+   copies it to your local Maven repository and to the target directory
+   of this example.
+     
+3. Install the example by entering the following command in
+   the ServiceMix console:
+   
+     features:install examples-cxf-ws-security-blueprint
+       
+   It makes use of the ServiceMix features facility. For more
+   information about the features facility, see the README.txt file
+   in the examples parent directory.
+
+To view the service WSDL, open your browser and go to the following
+URL:
+
+  http://localhost:8181/cxf/HelloWorldSecurity?wsdl
+
+Note, if you use Safari, right click the window and select
+'Show Source'.
+
+You can try running a client against your service by following the
+instructions in the "Running a Client" section above.
+
+
+Stopping and Uninstalling the Example
+-------------------------------------
+To stop the example, you must first know the bundle ID that ServiceMix
+has assigned to it. To get the bundle ID, enter the following command
+at the ServiceMix console:
+
+  osgi:list
+
+At the end of the listing, you should see an entry similar to the
+following:
+
+  [170] [Active     ] [Started] [  60] Apache ServiceMix Example :: CXF WS 
SECURITY OSGI (4.2.0.0)
+
+In this case, the bundle ID is 170.
+
+To stop the example, enter the following command at the ServiceMix
+console:
+
+  osgi:stop <bundle_id>
+
+For example:
+
+  osgi:stop 170
+
+To uninstall the example, enter one of the following commands in
+the ServiceMix console:
+
+  features:uninstall examples-cxf-ws-security-blueprint
+ 
+or
+ 
+  osgi:uninstall <bundle_id>
+  
+
+Viewing the Log Entries
+-----------------------
+You can view the entries in the log file in the data/log
+directory of your ServiceMix installation, or by typing
+the following command in the ServiceMix console:
+
+  log:display

Added: 
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/client.html
URL: 
http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/client.html?rev=1213565&view=auto
==============================================================================
--- 
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/client.html
 (added)
+++ 
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/client.html
 Tue Dec 13 04:54:57 2011
@@ -0,0 +1,144 @@
+<!--
+    
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+    
+    http://www.apache.org/licenses/LICENSE-2.0
+    
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<html>
+<head>
+<title>ServiceMix 4 CXF-WS-SECURITY-OSGi Example</title>
+<script type="text/javascript">
+var urlToOpen = "http://localhost:8181/cxf/HelloWorldSecurity";; //default URL 
to open
+
+function getHTTPObject() {
+  var xmlhttp = false;
+
+  /* Compilation conditionnelle d'IE */
+  /* Check if we are using IE */
+  /*@cc_on
+  @if (@_jscript_version >= 5)
+     try {
+        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
+     } catch (e) {
+        try {
+           xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
+        } catch (E) {
+           xmlhttp = false;
+        }
+     }
+  @else
+     xmlhttp = false;
+  @end @*/
+
+  /* on essaie de créer l'objet si ce n'est pas déjà fait */
+  /* Create the xmlhttp object if it is not yet defined */
+  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
+     try {
+        xmlhttp = new XMLHttpRequest();
+     } catch (e) {
+        xmlhttp = false;
+     }
+  }
+
+  if (xmlhttp) {
+     /* on définit ce qui doit se passer quand la page répondra */
+     /* Define the callback function for the response */
+     xmlhttp.onreadystatechange=function() {
+        if (xmlhttp.readyState == 4) { /* 4 : état "complete" */
+           var response = document.getElementById("response");
+           var responseStatus = "";
+           try {
+             responseStatus = xmlhttp.status + "";
+           } catch (e) {
+             responseStatus = "ERROR WHILE RETRIEVING STATUS; MAYBE UNABLE TO 
CONNECT.";
+           }
+           response.value = "STATUS: " + responseStatus + "\n" + 
xmlhttp.responseText;
+        }
+     }
+  }
+  return xmlhttp;
+}
+
+function send() {
+  if ((document.getElementById("urlToOpen").value != urlToOpen) && 
(document.getElementById("urlToOpen").value != "")) {
+    // use user entry if it is not the empty string
+    urlToOpen = document.getElementById("urlToOpen").value;
+  }  
+  var xmlhttp = getHTTPObject();
+  if (!xmlhttp) {
+    alert('cound not create XMLHttpRequest object');
+    return;
+  }
+  var request = document.getElementById("request");
+  var response = document.getElementById("response");
+  try {
+    netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead 
UniversalBrowserWrite");
+  } catch (e) {
+  }
+  try {
+    xmlhttp.open("POST", urlToOpen, true);
+  } catch (e) {
+    alert('error opening');
+  }
+  xmlhttp.send(request.value);
+}
+
+</script>
+</head>
+
+<body>
+
+<h1>ServiceMix 4 CXF-WS-SECURITY-OSGi Example</h1>
+
+<p>Welcome to the CXF-WS-SECURITY-OSGi example for ServiceMix 4</p>
+
+<p>Perform a POST into the HTTP binding. This requires JavaScript.</p> 
+<p>Target: <input type="text" size="50" id="urlToOpen" value=""><script 
type="text/javascript">document.getElementById("urlToOpen").value = 
urlToOpen;</script>.</p>
+  
+<table>
+  <tr>
+    <td>
+  <textarea id="request" style="width:600px;height:400px"><?xml version="1.0" 
encoding="UTF-8"?>
+  <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";>
+    <soap:Header>
+        <wsse:Security 
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";>
+            <wsse:UsernameToken >
+                <wsse:Username>joe</wsse:Username>
+                <wsse:Password 
Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText";>password</wsse:Password>
+            </wsse:UsernameToken>
+        </wsse:Security>
+    </soap:Header>
+    <soap:Body>
+        <ns2:sayHi xmlns:ns2="http://cxf.examples.servicemix.apache.org/";>
+            <arg0>John Doe</arg0>
+        </ns2:sayHi>
+    </soap:Body>
+</soap:Envelope>
+
+  </textarea>
+    </td>
+    <td>
+  <textarea id="response" style="width:600px;height:400px">
+  </textarea>
+    </td>
+  </tr>
+  <tr>
+    <td colspan=2>
+  <input type="button" value="Send" onClick="send();"/>
+    </td>
+  </tr>
+</table>
+</body>
+</html>

Added: 
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/pom.xml
URL: 
http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/pom.xml?rev=1213565&view=auto
==============================================================================
--- 
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/pom.xml 
(added)
+++ 
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/pom.xml 
Tue Dec 13 04:54:57 2011
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+
+    <!--
+
+        Licensed to the Apache Software Foundation (ASF) under one or more
+        contributor license agreements.  See the NOTICE file distributed with
+        this work for additional information regarding copyright ownership.
+        The ASF licenses this file to You under the Apache License, Version 2.0
+        (the "License"); you may not use this file except in compliance with
+        the License.  You may obtain a copy of the License at
+
+           http://www.apache.org/licenses/LICENSE-2.0
+
+        Unless required by applicable law or agreed to in writing, software
+        distributed under the License is distributed on an "AS IS" BASIS,
+        WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
implied.
+        See the License for the specific language governing permissions and
+        limitations under the License.
+    -->
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.servicemix.examples</groupId>
+        <artifactId>cxf</artifactId>
+        <version>4.4.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>cxf-ws-security-blueprint</artifactId>
+    <packaging>bundle</packaging>
+    <name>Apache ServiceMix :: Features :: Examples :: CXF WS-Security 
Blueprint</name>
+    <description>CXF example using WS-Security with Blueprint</description>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-ws-metadata_2.0_spec</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.servicemix</groupId>
+            <artifactId>servicemix-utils</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.ws.security</groupId>
+            <artifactId>wss4j</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-transports-http</artifactId>
+            <version>${cxf.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-ws-security</artifactId>
+            <version>${cxf.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-frontend-jaxws</artifactId>
+            <version>${cxf.version}</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+                        
<Bundle-Description>${project.description}</Bundle-Description>
+                        <Import-Package>
+                            javax.jws,
+                            javax.xml.bind.annotation,
+                            javax.wsdl,
+                            org.osgi.service.blueprint,
+                            org.apache.cxf.ws.security.wss4j,
+                            javax.security.auth.callback,
+                            org.apache.ws.security,
+                            org.apache.commons.logging,
+                            org.apache.servicemix.util,
+                            org.apache.ws.security.processor,
+                            org.apache.cxf.interceptor.security,
+                            org.apache.cxf, org.apache.cxf.endpoint, 
org.apache.cxf.frontend, org.apache.cxf.interceptor, org.apache.cxf.jaxws, 
org.apache.cxf.message, org.apache.cxf.phase
+                        </Import-Package>
+                        
<Export-Package>org.apache.servicemix.examples.cxf</Export-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>exec-maven-plugin</artifactId>
+                <configuration>
+                    
<mainClass>org.apache.servicemix.examples.cxf.Client</mainClass>
+                    
<includePluginDependencies>false</includePluginDependencies>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

Added: 
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/java/org/apache/servicemix/examples/cxf/Client.java
URL: 
http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/java/org/apache/servicemix/examples/cxf/Client.java?rev=1213565&view=auto
==============================================================================
--- 
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/java/org/apache/servicemix/examples/cxf/Client.java
 (added)
+++ 
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/java/org/apache/servicemix/examples/cxf/Client.java
 Tue Dec 13 04:54:57 2011
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.examples.cxf;
+
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.cxf.frontend.ClientProxy;
+import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;
+
+
+public class Client{
+    public static void main(String[] args) {
+        try {
+        new Client().sendRequest();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+    
+    public void sendRequest() throws Exception {
+        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
+        factory.setServiceClass(HelloWorld.class);
+        factory.setAddress("http://localhost:8181/cxf/HelloWorldSecurity";);
+        HelloWorld client = (HelloWorld) factory.create();
+        
+        Map<String, Object> outProps = new HashMap<String, Object>();
+        outProps.put("action", "UsernameToken");
+
+        //add a CustomerSecurityInterceptor for client side to init wss4j staff
+        //retrieve and set user/password,  users can easily add this 
interceptor
+        //through spring configuration also
+        ClientProxy.getClient(client).getOutInterceptors().add(new 
CustomerSecurityInterceptor());
+        ClientProxy.getClient(client).getOutInterceptors().add(new 
WSS4JOutInterceptor());
+        String ret = client.sayHi("ffang");
+        System.out.println(ret);
+    }
+
+}

Added: 
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/java/org/apache/servicemix/examples/cxf/ClientPasswordCallback.java
URL: 
http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/java/org/apache/servicemix/examples/cxf/ClientPasswordCallback.java?rev=1213565&view=auto
==============================================================================
--- 
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/java/org/apache/servicemix/examples/cxf/ClientPasswordCallback.java
 (added)
+++ 
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/java/org/apache/servicemix/examples/cxf/ClientPasswordCallback.java
 Tue Dec 13 04:54:57 2011
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.servicemix.examples.cxf;
+
+import java.io.IOException;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import org.apache.ws.security.WSPasswordCallback;
+
+public class ClientPasswordCallback implements CallbackHandler {
+
+    public void handle(Callback[] callbacks) throws IOException, 
UnsupportedCallbackException {
+
+        WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
+
+        if (pc.getIdentifier().equals("joe")) {
+            pc.setPassword("password");
+        }
+    }
+
+}
+
+

Added: 
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/java/org/apache/servicemix/examples/cxf/CustomerSecurityInterceptor.java
URL: 
http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/java/org/apache/servicemix/examples/cxf/CustomerSecurityInterceptor.java?rev=1213565&view=auto
==============================================================================
--- 
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/java/org/apache/servicemix/examples/cxf/CustomerSecurityInterceptor.java
 (added)
+++ 
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/java/org/apache/servicemix/examples/cxf/CustomerSecurityInterceptor.java
 Tue Dec 13 04:54:57 2011
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.servicemix.examples.cxf;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;
+
+public class CustomerSecurityInterceptor extends 
AbstractPhaseInterceptor<Message> {
+
+    public CustomerSecurityInterceptor() {
+        super(Phase.SETUP);
+    }
+
+    public void handleMessage(Message message) throws Fault {
+        Map<String, Object> outProps = new HashMap<String, Object>();
+        outProps.put("action", "UsernameToken");
+
+        outProps.put("passwordType", "PasswordText");
+        outProps.put("user", "joe");
+        outProps.put("passwordCallbackClass", 
"org.apache.servicemix.examples.cxf.ClientPasswordCallback");
+        for (Interceptor inteceptor : message.getInterceptorChain()) {
+            //set properties for WSS4JOutInterceptor
+            if 
(inteceptor.getClass().getName().equals("org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor"))
 {
+                ((WSS4JOutInterceptor)inteceptor).setProperties(outProps);
+            }
+        }
+    }
+
+ 
+}

Added: 
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/java/org/apache/servicemix/examples/cxf/HelloWorld.java
URL: 
http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/java/org/apache/servicemix/examples/cxf/HelloWorld.java?rev=1213565&view=auto
==============================================================================
--- 
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/java/org/apache/servicemix/examples/cxf/HelloWorld.java
 (added)
+++ 
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/java/org/apache/servicemix/examples/cxf/HelloWorld.java
 Tue Dec 13 04:54:57 2011
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+// START SNIPPET: service
+package org.apache.servicemix.examples.cxf;
+
+import javax.jws.WebService;
+
+@WebService
+public interface HelloWorld {
+    String sayHi(String text);
+}
+// END SNIPPET: service

Added: 
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/java/org/apache/servicemix/examples/cxf/HelloWorldImpl.java
URL: 
http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/java/org/apache/servicemix/examples/cxf/HelloWorldImpl.java?rev=1213565&view=auto
==============================================================================
--- 
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/java/org/apache/servicemix/examples/cxf/HelloWorldImpl.java
 (added)
+++ 
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/java/org/apache/servicemix/examples/cxf/HelloWorldImpl.java
 Tue Dec 13 04:54:57 2011
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+// START SNIPPET: service
+package org.apache.servicemix.examples.cxf;
+
+import javax.jws.WebService;
+
+@WebService(endpointInterface = 
"org.apache.servicemix.examples.cxf.HelloWorld")
+public class HelloWorldImpl implements HelloWorld {
+
+    public String sayHi(String text) {
+        return "Hello " + text;
+    }
+}
+// END SNIPPET: service

Added: 
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/resources/OSGI-INF/blueprint/blueprint.xml
URL: 
http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/resources/OSGI-INF/blueprint/blueprint.xml?rev=1213565&view=auto
==============================================================================
--- 
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/resources/OSGI-INF/blueprint/blueprint.xml
 (added)
+++ 
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/resources/OSGI-INF/blueprint/blueprint.xml
 Tue Dec 13 04:54:57 2011
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<!-- START SNIPPET: beans -->
+<blueprint
+    xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+    xmlns:jaxws="http://cxf.apache.org/blueprint/jaxws";
+    xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
+                         http://cxf.apache.org/blueprint/jaxws 
http://cxf.apache.org/schemas/blueprint/jaxws.xsd";>
+
+
+    <jaxws:endpoint id="helloWorld"
+        implementor="org.apache.servicemix.examples.cxf.HelloWorldImpl"
+        address="/HelloWorldSecurity">
+        <jaxws:inInterceptors>
+            <bean class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
+                 <property name="properties">
+                     <map>
+                         <entry key="action" value="UsernameToken"/>
+                         <entry key="passwordType" value="PasswordTest"/>
+                     </map>
+                 </property>
+             </bean>          
+            <ref component-id="authenticationInterceptor"/>
+        </jaxws:inInterceptors>
+        <jaxws:properties>
+            <entry key="ws-security.validate.token" value="false"/>
+        </jaxws:properties>
+    </jaxws:endpoint>
+    <bean id="authenticationInterceptor" 
class="org.apache.cxf.interceptor.security.JAASLoginInterceptor">
+       <property name="contextName" value="karaf"/>
+    </bean>
+
+</blueprint>

Propchange: 
servicemix/smx4/features/trunk/examples/cxf/cxf-ws-security-blueprint/src/main/resources/OSGI-INF/blueprint/blueprint.xml
------------------------------------------------------------------------------
    svn:executable = *

Modified: servicemix/smx4/features/trunk/examples/cxf/pom.xml
URL: 
http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/cxf/pom.xml?rev=1213565&r1=1213564&r2=1213565&view=diff
==============================================================================
--- servicemix/smx4/features/trunk/examples/cxf/pom.xml (original)
+++ servicemix/smx4/features/trunk/examples/cxf/pom.xml Tue Dec 13 04:54:57 2011
@@ -37,6 +37,7 @@
         <module>cxf-jaxrs</module>
         <module>cxf-ws-addressing</module>
         <module>cxf-ws-security-osgi</module>
+        <module>cxf-ws-security-blueprint</module>
         <module>cxf-ws-rm</module>
     </modules>
 


Reply via email to