Author: ffang
Date: Thu Dec 31 01:53:02 2009
New Revision: 894759
URL: http://svn.apache.org/viewvc?rev=894759&view=rev
Log:
[SMX4-353]add cxf-ws-security test in examples/itests
Added:
servicemix/smx4/features/trunk/examples/itests/cxf-ws-security-osgi/
servicemix/smx4/features/trunk/examples/itests/cxf-ws-security-osgi/pom.xml
servicemix/smx4/features/trunk/examples/itests/cxf-ws-security-osgi/src/
servicemix/smx4/features/trunk/examples/itests/cxf-ws-security-osgi/src/main/
servicemix/smx4/features/trunk/examples/itests/cxf-ws-security-osgi/src/main/java/
servicemix/smx4/features/trunk/examples/itests/cxf-ws-security-osgi/src/main/java/org/
servicemix/smx4/features/trunk/examples/itests/cxf-ws-security-osgi/src/main/java/org/apache/
servicemix/smx4/features/trunk/examples/itests/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/
servicemix/smx4/features/trunk/examples/itests/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/
servicemix/smx4/features/trunk/examples/itests/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/cxf/
servicemix/smx4/features/trunk/examples/itests/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/cxf/HelloWorld.java
(with props)
servicemix/smx4/features/trunk/examples/itests/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/cxf/HelloWorldImpl.java
(with props)
servicemix/smx4/features/trunk/examples/itests/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/cxf/ServerPasswordCallback.java
servicemix/smx4/features/trunk/examples/itests/cxf-ws-security-osgi/src/main/resources/
servicemix/smx4/features/trunk/examples/itests/cxf-ws-security-osgi/src/main/resources/META-INF/
servicemix/smx4/features/trunk/examples/itests/cxf-ws-security-osgi/src/main/resources/META-INF/spring/
servicemix/smx4/features/trunk/examples/itests/cxf-ws-security-osgi/src/main/resources/META-INF/spring/beans.xml
(with props)
servicemix/smx4/features/trunk/examples/itests/tests/src/test/resources/org/apache/servicemix/request.xml
(with props)
Modified:
servicemix/smx4/features/trunk/examples/itests/pom.xml
servicemix/smx4/features/trunk/examples/itests/tests/pom.xml
servicemix/smx4/features/trunk/examples/itests/tests/src/test/java/org/apache/servicemix/examples/IntegrationTest.java
Added:
servicemix/smx4/features/trunk/examples/itests/cxf-ws-security-osgi/pom.xml
URL:
http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/itests/cxf-ws-security-osgi/pom.xml?rev=894759&view=auto
==============================================================================
--- servicemix/smx4/features/trunk/examples/itests/cxf-ws-security-osgi/pom.xml
(added)
+++ servicemix/smx4/features/trunk/examples/itests/cxf-ws-security-osgi/pom.xml
Thu Dec 31 01:53:02 2009
@@ -0,0 +1,88 @@
+<?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>org.apache.servicemix.examples.itests</artifactId>
+ <version>4.1.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.apache.servicemix.examples</groupId>
+
<artifactId>org.apache.servicemix.examples.itests.cxf-ws-security-osgi</artifactId>
+ <packaging>bundle</packaging>
+ <name>Apache ServiceMix Example ITESTS BUNDLE :: 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.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
+ </Import-Package>
+
<Export-Package>org.apache.servicemix.examples.cxf</Export-Package>
+ <Require-Bundle>org.apache.cxf.bundle</Require-Bundle>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Added:
servicemix/smx4/features/trunk/examples/itests/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/itests/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/cxf/HelloWorld.java?rev=894759&view=auto
==============================================================================
---
servicemix/smx4/features/trunk/examples/itests/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/cxf/HelloWorld.java
(added)
+++
servicemix/smx4/features/trunk/examples/itests/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/cxf/HelloWorld.java
Thu Dec 31 01:53:02 2009
@@ -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/itests/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/cxf/HelloWorld.java
------------------------------------------------------------------------------
svn:executable = *
Added:
servicemix/smx4/features/trunk/examples/itests/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/itests/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/cxf/HelloWorldImpl.java?rev=894759&view=auto
==============================================================================
---
servicemix/smx4/features/trunk/examples/itests/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/cxf/HelloWorldImpl.java
(added)
+++
servicemix/smx4/features/trunk/examples/itests/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/cxf/HelloWorldImpl.java
Thu Dec 31 01:53:02 2009
@@ -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/itests/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/cxf/HelloWorldImpl.java
------------------------------------------------------------------------------
svn:executable = *
Added:
servicemix/smx4/features/trunk/examples/itests/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/itests/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/cxf/ServerPasswordCallback.java?rev=894759&view=auto
==============================================================================
---
servicemix/smx4/features/trunk/examples/itests/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/cxf/ServerPasswordCallback.java
(added)
+++
servicemix/smx4/features/trunk/examples/itests/cxf-ws-security-osgi/src/main/java/org/apache/servicemix/examples/cxf/ServerPasswordCallback.java
Thu Dec 31 01:53:02 2009
@@ -0,0 +1,22 @@
+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/itests/cxf-ws-security-osgi/src/main/resources/META-INF/spring/beans.xml
URL:
http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/itests/cxf-ws-security-osgi/src/main/resources/META-INF/spring/beans.xml?rev=894759&view=auto
==============================================================================
---
servicemix/smx4/features/trunk/examples/itests/cxf-ws-security-osgi/src/main/resources/META-INF/spring/beans.xml
(added)
+++
servicemix/smx4/features/trunk/examples/itests/cxf-ws-security-osgi/src/main/resources/META-INF/spring/beans.xml
Thu Dec 31 01:53:02 2009
@@ -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/itests/cxf-ws-security-osgi/src/main/resources/META-INF/spring/beans.xml
------------------------------------------------------------------------------
svn:executable = *
Modified: servicemix/smx4/features/trunk/examples/itests/pom.xml
URL:
http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/itests/pom.xml?rev=894759&r1=894758&r2=894759&view=diff
==============================================================================
--- servicemix/smx4/features/trunk/examples/itests/pom.xml (original)
+++ servicemix/smx4/features/trunk/examples/itests/pom.xml Thu Dec 31 01:53:02
2009
@@ -33,6 +33,7 @@
<modules>
<module>cxf-http-osgi</module>
+ <module>cxf-ws-security-osgi</module>
<module>cxf-jms-osgi</module>
<module>cxf-nmr-osgi</module>
<module>cxf-soap-handler-osgi</module>
Modified: servicemix/smx4/features/trunk/examples/itests/tests/pom.xml
URL:
http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/itests/tests/pom.xml?rev=894759&r1=894758&r2=894759&view=diff
==============================================================================
--- servicemix/smx4/features/trunk/examples/itests/tests/pom.xml (original)
+++ servicemix/smx4/features/trunk/examples/itests/tests/pom.xml Thu Dec 31
01:53:02 2009
@@ -209,6 +209,12 @@
</dependency>
<dependency>
<groupId>org.apache.servicemix.examples</groupId>
+
<artifactId>org.apache.servicemix.examples.itests.cxf-ws-security-osgi</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.servicemix.examples</groupId>
<artifactId>org.apache.servicemix.examples.itests.cxf-jms-osgi</artifactId>
<version>${project.version}</version>
</dependency>
@@ -441,6 +447,17 @@
<artifactId>org.apache.servicemix.specs.jsr311-api-${jaxrs.api.version}</artifactId>
<version>${servicemix.specs.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.ws.security</groupId>
+ <artifactId>wss4j</artifactId>
+ <version>${wss4j.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicemix.bundles</groupId>
+ <artifactId>org.apache.servicemix.bundles.opensaml</artifactId>
+ <version>${opensaml.version}</version>
+ </dependency>
+
</dependencies>
<build>
Modified:
servicemix/smx4/features/trunk/examples/itests/tests/src/test/java/org/apache/servicemix/examples/IntegrationTest.java
URL:
http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/itests/tests/src/test/java/org/apache/servicemix/examples/IntegrationTest.java?rev=894759&r1=894758&r2=894759&view=diff
==============================================================================
---
servicemix/smx4/features/trunk/examples/itests/tests/src/test/java/org/apache/servicemix/examples/IntegrationTest.java
(original)
+++
servicemix/smx4/features/trunk/examples/itests/tests/src/test/java/org/apache/servicemix/examples/IntegrationTest.java
Thu Dec 31 01:53:02 2009
@@ -20,7 +20,10 @@
import java.io.File;
import java.io.InputStream;
import java.io.PrintWriter;
+import java.net.HttpURLConnection;
+import java.io.OutputStream;
import java.net.URL;
+import java.net.URLConnection;
import java.util.jar.Manifest;
import java.util.HashMap;
import java.util.Map;
@@ -39,6 +42,7 @@
import org.apache.servicemix.nmr.api.Pattern;
import org.apache.servicemix.nmr.api.Status;
import org.apache.servicemix.platform.testing.support.AbstractIntegrationTest;
+import org.apache.servicemix.util.FileUtil;
import org.springframework.osgi.test.platform.OsgiPlatform;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
@@ -96,6 +100,10 @@
getBundle("org.apache.activemq", "activemq-console"),
getBundle("org.apache.activemq", "activemq-pool"),
getBundle("org.apache.activemq", "kahadb"),
+
+ //for ws-security
+ getBundle("org.apache.servicemix.bundles",
"org.apache.servicemix.bundles.opensaml"),
+ getBundle("org.apache.ws.security", "wss4j"),
getBundle("org.apache.servicemix.specs",
"org.apache.servicemix.specs.jbi-api-1.0"),
getBundle("org.apache.servicemix.specs",
"org.apache.servicemix.specs.stax-api-1.0"),
@@ -138,6 +146,7 @@
getBundle("org.apache.servicemix.nmr",
"org.apache.servicemix.nmr.osgi"),
getBundle("org.apache.servicemix.document",
"org.apache.servicemix.document"),
getBundle("org.apache.servicemix.examples",
"org.apache.servicemix.examples.itests.cxf-http-osgi"),
+ getBundle("org.apache.servicemix.examples",
"org.apache.servicemix.examples.itests.cxf-ws-security-osgi"),
getBundle("org.apache.servicemix.examples",
"org.apache.servicemix.examples.itests.cxf-jms-osgi"),
getBundle("org.apache.servicemix.examples",
"org.apache.servicemix.examples.itests.cxf-soap-handler-osgi"),
getBundle("org.apache.servicemix.examples",
"org.apache.servicemix.examples.itests.cxf-handler-cfg"),
@@ -216,6 +225,7 @@
+
"org.apache.servicemix.examples.cxf.soaphandler,"
+
"org.apache.servicemix.examples.cxf.springcfghandler,"
+
"org.apache.servicemix.examples.cxf.wsaddressing,"
+ + "org.apache.servicemix.util,"
+ "org.apache.hello_world_soap_http,"
+ "org.apache.cxf,"
+ "org.apache.cxf.bus,"
@@ -312,4 +322,24 @@
assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"
standalone=\"yes\"?><Customer><id>123</id><name>John</name></Customer>",
bos.toString());
}
+
+ public void testWSSecurity() throws Exception {
+ Thread.sleep(5000);
+
waitOnContextCreation("org.apache.servicemix.examples.itests.cxf-ws-security-osgi");
+ Thread.sleep(5000);
+ URLConnection connection = new
URL("http://localhost:8080/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/request.xml");
+ FileUtil.copyInputStream(fis, os);
+ // Read the response.
+ InputStream is = connection.getInputStream();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ FileUtil.copyInputStream(is, baos);
+ assertTrue(baos.toString().indexOf("Hello John Doe") >= 0);
+
+ }
}
Added:
servicemix/smx4/features/trunk/examples/itests/tests/src/test/resources/org/apache/servicemix/request.xml
URL:
http://svn.apache.org/viewvc/servicemix/smx4/features/trunk/examples/itests/tests/src/test/resources/org/apache/servicemix/request.xml?rev=894759&view=auto
==============================================================================
---
servicemix/smx4/features/trunk/examples/itests/tests/src/test/resources/org/apache/servicemix/request.xml
(added)
+++
servicemix/smx4/features/trunk/examples/itests/tests/src/test/resources/org/apache/servicemix/request.xml
Thu Dec 31 01:53:02 2009
@@ -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/itests/tests/src/test/resources/org/apache/servicemix/request.xml
------------------------------------------------------------------------------
svn:executable = *