servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r901991 - in /servicemix/smx4/features/trunk: assembly/src/main/descriptors/ assembly/src/main/filtered-resources/ examples/ examples/cxf-ws-security-osgi/ examples/cxf-ws-security-osgi/src/ examples/cxf-ws-security-osgi/src/main/ examples/...
Date Fri, 22 Jan 2010 04:48:13 GMT
Author: ffang
Date: Fri Jan 22 04:48:12 2010
New Revision: 901991

URL: http://svn.apache.org/viewvc?rev=901991&view=rev
Log:
[SMX4-464]add a demo for cxf with ws-security using http-osgi transport

Added:
    servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/
    servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/README.txt
    servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/client.html
    servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/pom.xml
    servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/
    servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/
    servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/java/
    servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/java/org/
    servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/java/org/apache/
    servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/
    servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/
    servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/cxf/
    servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/cxf/Client.java
    servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/cxf/HelloWorld.java
  (with props)
    servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/cxf/HelloWorldImpl.java
  (with props)
    servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/cxf/ServerPasswordCallback.java
    servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/resources/
    servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/resources/META-INF/
    servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/resources/META-INF/spring/
    servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/resources/META-INF/spring/beans.xml
  (with props)
    servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/resources/org/
    servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/resources/org/apache/
    servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/resources/org/apache/servicemix/
    servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/resources/org/apache/servicemix/examples/
    servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/resources/org/apache/servicemix/examples/cxf/
    servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/resources/org/apache/servicemix/examples/cxf/request.xml
  (with props)
Modified:
    servicemix/smx4/features/trunk/assembly/src/main/descriptors/unix-bin.xml
    servicemix/smx4/features/trunk/assembly/src/main/descriptors/windows-bin.xml
    servicemix/smx4/features/trunk/assembly/src/main/filtered-resources/features.xml
    servicemix/smx4/features/trunk/assembly/src/main/filtered-resources/pom.xml
    servicemix/smx4/features/trunk/examples/pom.xml

Modified: servicemix/smx4/features/trunk/assembly/src/main/descriptors/unix-bin.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/assembly/src/main/descriptors/unix-bin.xml?rev=901991&r1=901990&r2=901991&view=diff
==============================================================================
--- servicemix/smx4/features/trunk/assembly/src/main/descriptors/unix-bin.xml (original)
+++ servicemix/smx4/features/trunk/assembly/src/main/descriptors/unix-bin.xml Fri Jan 22 04:48:12
2010
@@ -247,6 +247,13 @@
             <lineEnding>unix</lineEnding>
         </file>
         <file>
+            <source>${basedir}/../examples/cxf-ws-security-osgi/README.txt</source>
+            <outputDirectory>/examples/cxf-ws-security-osgi</outputDirectory>
+            <filtered>true</filtered>
+            <lineEnding>unix</lineEnding>
+        </file>
+
+        <file>
             <source>${basedir}/../examples/cxf-camel-nmr/README.txt</source>
             <outputDirectory>/examples/cxf-camel-nmr</outputDirectory>
             <filtered>true</filtered>

Modified: servicemix/smx4/features/trunk/assembly/src/main/descriptors/windows-bin.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/assembly/src/main/descriptors/windows-bin.xml?rev=901991&r1=901990&r2=901991&view=diff
==============================================================================
--- servicemix/smx4/features/trunk/assembly/src/main/descriptors/windows-bin.xml (original)
+++ servicemix/smx4/features/trunk/assembly/src/main/descriptors/windows-bin.xml Fri Jan 22
04:48:12 2010
@@ -235,6 +235,13 @@
               <lineEnding>dos</lineEnding>
             </file>
             <file>
+              <source>${basedir}/../examples/cxf-ws-security-osgi/README.txt</source>
+              <outputDirectory>/examples/cxf-ws-security-osgi</outputDirectory>
+              <filtered>true</filtered>
+              <lineEnding>dos</lineEnding>
+            </file>
+
+            <file>
               <source>${basedir}/../examples/cxf-camel-nmr/README.txt</source>
               <outputDirectory>/examples/cxf-camel-nmr</outputDirectory>
               <filtered>true</filtered>

Modified: servicemix/smx4/features/trunk/assembly/src/main/filtered-resources/features.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/assembly/src/main/filtered-resources/features.xml?rev=901991&r1=901990&r2=901991&view=diff
==============================================================================
--- servicemix/smx4/features/trunk/assembly/src/main/filtered-resources/features.xml (original)
+++ servicemix/smx4/features/trunk/assembly/src/main/filtered-resources/features.xml Fri Jan
22 04:48:12 2010
@@ -157,6 +157,10 @@
         <bundle>mvn:org.apache.servicemix.examples.cxf-wsdl-first-osgi-package/wsdl-first-cxfbc-bundle/${version}</bundle>
         <bundle>mvn:org.apache.servicemix.examples.cxf-wsdl-first-osgi-package/wsdl-first-cxfse-bundle/${version}</bundle>
     </feature>
+    <feature name="examples-cxf-ws-security-osgi" version="${version}">
+        <feature>cxf-osgi</feature>
+        <bundle>mvn:org.apache.servicemix.examples/cxf-ws-security-osgi/${version}</bundle>
+    </feature>
     <!--
       -
       -  JBI Components

Modified: servicemix/smx4/features/trunk/assembly/src/main/filtered-resources/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/assembly/src/main/filtered-resources/pom.xml?rev=901991&r1=901990&r2=901991&view=diff
==============================================================================
--- servicemix/smx4/features/trunk/assembly/src/main/filtered-resources/pom.xml (original)
+++ servicemix/smx4/features/trunk/assembly/src/main/filtered-resources/pom.xml Fri Jan 22
04:48:12 2010
@@ -45,6 +45,7 @@
         <module>cxf-ws-addressing</module>
         <module>cxf-jaxrs</module>
         <module>cxf-wsdl-first-osgi-package</module>
+        <module>cxf-ws-security-osgi</module>
     </modules>
 
 </project>

Added: servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/README.txt
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/README.txt?rev=901991&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/README.txt (added)
+++ servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/README.txt Fri Jan 22 04:48:12
2010
@@ -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 expose it through the OSGi HTTP
+Service.
+
+
+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 beans.xml file, located in the src/main/resources/META-INF/spring
+directory:
+
+1. Imports the configuration files needed to enable CXF and OSGi work
+   together.
+
+2. 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">
+                <constructor-arg>
+                    <map>
+                        <entry key="action" value="UsernameToken"/>
+                        <entry key="passwordType" value="PasswordText"/>
+                        <entry key="passwordCallbackRef">
+                            <ref bean="myPasswordCallback"/>
+                        </entry>
+
+                    </map>
+                </constructor-arg>
+            </bean>
+        </jaxws:inInterceptors>
+    </jaxws:endpoint>
+
+
+Prerequisites for Running the Example
+-------------------------------------
+1. You must have the following installed on your machine:
+
+   - JDK 1.5 or higher
+   
+   - Maven 2.0.9 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-osgi
+  
+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-osgi
+   directory.
+
+2. Run the following command:
+
+     mvn compile exec:java
+
+   If the client request is successful, a response similar to the
+   following should appear in the ServiceMix console:
+
+   <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>
+
+
+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-osgi
+   feature by entering the following command in the ServiceMix console:
+
+     features:uninstall examples-cxf-ws-security-osgi
+
+   
+2. Build the example by opening a command prompt, changing directory to
+   examples/cxf-ws-security-osgi (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-osgi
+       
+   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-osgi
+ 
+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-ws-security-osgi/client.html
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/client.html?rev=901991&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/client.html (added)
+++ servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/client.html Fri Jan 22 04:48:12
2010
@@ -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-ws-security-osgi/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/pom.xml?rev=901991&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/pom.xml (added)
+++ servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/pom.xml Fri Jan 22 04:48:12
2010
@@ -0,0 +1,101 @@
+<?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>examples</artifactId>
+        <version>4.1.0-SNAPSHOT</version>
+    </parent>
+
+    <groupId>org.apache.servicemix.examples</groupId>
+    <artifactId>cxf-ws-security-osgi</artifactId>
+    <packaging>bundle</packaging>
+    <version>4.1.0-SNAPSHOT</version>
+    <name>Apache ServiceMix Example :: CXF WS SECURITY OSGi</name>
+
+    
+    <dependencies>
+
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-ws-metadata_2.0_spec</artifactId>
+            <version>${geronimo.wsmetadata.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.servicemix</groupId>
+            <artifactId>servicemix-utils</artifactId>
+            <version>${servicemix-utils.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.ws.security</groupId>
+            <artifactId>wss4j</artifactId>
+            <version>${wss4j.version}</version>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+                        <Import-Package>
+                            javax.jws,
+                            javax.xml.bind.annotation,
+                            javax.wsdl,
+                            META-INF.cxf,
+                            META-INF.cxf.osgi,
+                            org.apache.cxf.bus,
+                            org.apache.cxf.bus.spring,
+                            org.apache.cxf.bus.resource,
+                            org.apache.cxf.configuration.spring,
+                            org.apache.cxf.resource,
+                            org.apache.cxf.transport.http_osgi,
+                            org.apache.cxf.ws.security.wss4j,
+                            org.springframework.beans.factory.config,
+                            javax.security.auth.callback,
+                            org.apache.ws.security,
+                            org.apache.commons.logging,
+                            org.apache.servicemix.util
+                        </Import-Package>
+                        <Export-Package>org.apache.servicemix.examples.cxf</Export-Package>
+                        <Require-Bundle>org.apache.cxf.bundle</Require-Bundle>
+                    </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-ws-security-osgi/src/main/java/org/apache/servicemix/examples/cxf/Client.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/cxf/Client.java?rev=901991&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/cxf/Client.java
(added)
+++ servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/cxf/Client.java
Fri Jan 22 04:48:12 2010
@@ -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.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLConnection;
+
+import org.apache.servicemix.util.FileUtil;
+
+public class Client{
+    public static void main(String[] args) {
+        try {
+	    new Client().sendRequest();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+    
+    public void sendRequest() throws Exception {
+        URLConnection connection = new URL("http://localhost:8181/cxf/HelloWorldSecurity")
+                .openConnection();
+        connection.setDoInput(true);
+        connection.setDoOutput(true);
+        OutputStream os = connection.getOutputStream();
+        // Post the request file.
+        InputStream fis = getClass().getClassLoader().getResourceAsStream("org/apache/servicemix/examples/cxf/request.xml");
+        FileUtil.copyInputStream(fis, os);
+        // Read the response.
+        InputStream is = connection.getInputStream();
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        FileUtil.copyInputStream(is, baos);
+        System.out.println("the response is =====>");
+        System.out.println(baos.toString());
+    }
+
+}

Added: servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/cxf/HelloWorld.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/cxf/HelloWorld.java?rev=901991&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/cxf/HelloWorld.java
(added)
+++ servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/cxf/HelloWorld.java
Fri Jan 22 04:48:12 2010
@@ -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

Propchange: servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/cxf/HelloWorld.java
------------------------------------------------------------------------------
    svn:executable = *

Added: servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/cxf/HelloWorldImpl.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/cxf/HelloWorldImpl.java?rev=901991&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/cxf/HelloWorldImpl.java
(added)
+++ servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/cxf/HelloWorldImpl.java
Fri Jan 22 04:48:12 2010
@@ -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

Propchange: servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/cxf/HelloWorldImpl.java
------------------------------------------------------------------------------
    svn:executable = *

Added: servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/cxf/ServerPasswordCallback.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/cxf/ServerPasswordCallback.java?rev=901991&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/cxf/ServerPasswordCallback.java
(added)
+++ servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/cxf/ServerPasswordCallback.java
Fri Jan 22 04:48:12 2010
@@ -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 ServerPasswordCallback implements CallbackHandler {
+
+    public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
{
+
+        WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
+
+        if (pc.getIdentifer().equals("joe")) {
+            pc.setPassword("password");
+        }
+    }
+
+}
+
+

Added: servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/resources/META-INF/spring/beans.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/resources/META-INF/spring/beans.xml?rev=901991&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/resources/META-INF/spring/beans.xml
(added)
+++ servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/resources/META-INF/spring/beans.xml
Fri Jan 22 04:48:12 2010
@@ -0,0 +1,55 @@
+<?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 -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xmlns:jaxws="http://cxf.apache.org/jaxws"
+    xsi:schemaLocation="
+    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+    http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
+
+    <import resource="classpath:META-INF/cxf/cxf.xml" />
+    <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
+    <import resource="classpath:META-INF/cxf/cxf-extension-http.xml" />
+    <import resource="classpath:META-INF/cxf/osgi/cxf-extension-osgi.xml" />
+
+    <bean id="myPasswordCallback" class="org.apache.servicemix.examples.cxf.ServerPasswordCallback"/>
+
+    <jaxws:endpoint id="helloWorld"
+        implementor="org.apache.servicemix.examples.cxf.HelloWorldImpl"
+        address="/HelloWorldSecurity">
+        <jaxws:inInterceptors>
+            <bean class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
+                <constructor-arg>
+                    <map>
+                        <entry key="action" value="UsernameToken"/>
+                        <entry key="passwordType" value="PasswordText"/>
+                        <entry key="passwordCallbackRef">
+                            <ref bean="myPasswordCallback"/>
+                        </entry>
+
+                    </map>
+                </constructor-arg>
+            </bean>
+        </jaxws:inInterceptors>
+    </jaxws:endpoint>
+
+</beans>
+<!-- END SNIPPET: beans -->

Propchange: servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/resources/META-INF/spring/beans.xml
------------------------------------------------------------------------------
    svn:executable = *

Added: servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/resources/org/apache/servicemix/examples/cxf/request.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/resources/org/apache/servicemix/examples/cxf/request.xml?rev=901991&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/resources/org/apache/servicemix/examples/cxf/request.xml
(added)
+++ servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/resources/org/apache/servicemix/examples/cxf/request.xml
Fri Jan 22 04:48:12 2010
@@ -0,0 +1,16 @@
+<?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>

Propchange: servicemix/smx4/features/trunk/examples/cxf-ws-security-osgi/src/main/resources/org/apache/servicemix/examples/cxf/request.xml
------------------------------------------------------------------------------
    svn:executable = *

Modified: servicemix/smx4/features/trunk/examples/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/pom.xml?rev=901991&r1=901990&r2=901991&view=diff
==============================================================================
--- servicemix/smx4/features/trunk/examples/pom.xml (original)
+++ servicemix/smx4/features/trunk/examples/pom.xml Fri Jan 22 04:48:12 2010
@@ -46,7 +46,8 @@
         <module>cxf-osgi</module>
         <module>cxf-jaxrs</module>
         <module>cxf-ws-addressing</module>
-        <module>cxf-wsdl-first-osgi-package</module> 
+        <module>cxf-wsdl-first-osgi-package</module>
+        <module>cxf-ws-security-osgi</module>
         <module>itests</module>
     </modules>
 



Mime
View raw message