Author: alessio.soldano(a)jboss.com
Date: 2012-01-13 08:50:40 -0500 (Fri, 13 Jan 2012)
New Revision: 15486
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/MultipleClientsServiceImpl.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/MultipleClientsSignEncryptTestCase.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/sign-encrypt/META-INF/john.jks
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/sign-encrypt/META-INF/john.properties
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/sign-encrypt/WEB-INF/bob2.jks
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/sign-encrypt/WEB-INF/bob2.properties
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-samples-jars-jaxws.xml
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/KeystorePasswordCallback.java
Log:
[JBWS-3412] Adding testcase
Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-samples-jars-jaxws.xml
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-samples-jars-jaxws.xml 2012-01-13
13:33:57 UTC (rev 15485)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-samples-jars-jaxws.xml 2012-01-13
13:50:40 UTC (rev 15486)
@@ -2,7 +2,7 @@
<!--
~ JBoss, Home of Professional Open Source.
- ~ Copyright 2011, Red Hat, Inc., and individual contributors
+ ~ Copyright 2012, Red Hat, Inc., and individual contributors
~ as indicated by the @author tags. See the copyright.txt file in the
~ distribution for a full listing of individual contributors.
~
@@ -128,6 +128,27 @@
</manifest>
</war>
+ <!-- jaxws-samples-wsse-policy-sign-encrypt-mc -->
+ <war
+
warfile="${tests.output.dir}/test-libs/jaxws-samples-wsse-policy-sign-encrypt-mc.war"
needxmlfile='false'>
+ <classes dir="${tests.output.dir}/test-classes">
+ <include
name="org/jboss/test/ws/jaxws/samples/wsse/policy/basic/ServiceIface.class"/>
+ <include
name="org/jboss/test/ws/jaxws/samples/wsse/policy/basic/MultipleClientsServiceImpl.class"/>
+ <include
name="org/jboss/test/ws/jaxws/samples/wsse/policy/jaxws/Say*.class"/>
+ <include
name="org/jboss/test/ws/jaxws/samples/wsse/policy/basic/KeystorePasswordCallback.class"/>
+ </classes>
+ <webinf
dir="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/basic/sign-encrypt/WEB-INF">
+ <include name="wsdl/*"/>
+ </webinf>
+ <zipfileset
dir="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/basic/sign-encrypt/WEB-INF"
prefix="WEB-INF/classes">
+ <include name="bob2.jks" />
+ <include name="bob2.properties" />
+ </zipfileset>
+ <manifest>
+ <attribute name="Dependencies"
value="org.apache.ws.security,org.apache.cxf"/>
+ </manifest>
+ </war>
+
<!-- jaxws-samples-wsse-policy-sign-encrypt-client -->
<jar
destfile="${tests.output.dir}/test-libs/jaxws-samples-wsse-policy-sign-encrypt-client.jar">
<metainf
dir="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/basic/sign-encrypt/META-INF">
@@ -136,6 +157,16 @@
</metainf>
</jar>
+ <!-- jaxws-samples-wsse-policy-sign-encrypt-mc-client -->
+ <jar
destfile="${tests.output.dir}/test-libs/jaxws-samples-wsse-policy-sign-encrypt-mc-client.jar">
+ <metainf
dir="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/basic/sign-encrypt/META-INF">
+ <include name="alice.properties" />
+ <include name="alice.jks" />
+ <include name="john.properties" />
+ <include name="john.jks" />
+ </metainf>
+ </jar>
+
<!-- jaxws-samples-wsse-policy-username-unsecure-transport -->
<war
warfile="${tests.output.dir}/test-libs/jaxws-samples-wsse-policy-username-unsecure-transport.war"
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/KeystorePasswordCallback.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/KeystorePasswordCallback.java 2012-01-13
13:33:57 UTC (rev 15485)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/KeystorePasswordCallback.java 2012-01-13
13:50:40 UTC (rev 15486)
@@ -39,6 +39,7 @@
{
passwords.put("alice", "password");
passwords.put("bob", "password");
+ passwords.put("john", "password");
}
/**
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/MultipleClientsServiceImpl.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/MultipleClientsServiceImpl.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/MultipleClientsServiceImpl.java 2012-01-13
13:50:40 UTC (rev 15486)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.samples.wsse.policy.basic;
+
+import javax.jws.WebService;
+import javax.servlet.annotation.WebServlet;
+
+import org.apache.cxf.annotations.EndpointProperties;
+import org.apache.cxf.annotations.EndpointProperty;
+
+@WebService
+(
+ portName = "SecurityServicePort",
+ serviceName = "SecurityService",
+ wsdlLocation = "WEB-INF/wsdl/SecurityService.wsdl",
+ targetNamespace =
"http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy",
+ endpointInterface =
"org.jboss.test.ws.jaxws.samples.wsse.policy.basic.ServiceIface"
+)
+@EndpointProperties(value = {
+ @EndpointProperty(key = "ws-security.signature.properties", value =
"bob2.properties"),
+ @EndpointProperty(key = "ws-security.encryption.properties", value =
"bob2.properties"),
+ @EndpointProperty(key = "ws-security.signature.username", value =
"bob"),
+ @EndpointProperty(key = "ws-security.encryption.username", value =
"useReqSigCert"),
+ @EndpointProperty(key = "ws-security.callback-handler", value =
"org.jboss.test.ws.jaxws.samples.wsse.policy.basic.KeystorePasswordCallback")
+ }
+)
+@WebServlet(name = "TestServlet", urlPatterns = "/*")
+public class MultipleClientsServiceImpl implements ServiceIface
+{
+ public String sayHello()
+ {
+ return "Multiple Clients Secure Hello World!";
+ }
+}
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/MultipleClientsSignEncryptTestCase.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/MultipleClientsSignEncryptTestCase.java
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/MultipleClientsSignEncryptTestCase.java 2012-01-13
13:50:40 UTC (rev 15486)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.samples.wsse.policy.basic;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Service;
+import javax.xml.ws.soap.SOAPFaultException;
+
+import junit.framework.Test;
+
+import org.apache.cxf.ws.security.SecurityConstants;
+import org.jboss.wsf.test.JBossWSCXFTestSetup;
+import org.jboss.wsf.test.JBossWSTest;
+
+/**
+ * WS-Security Policy sign & encrypt test case
+ * (multiple clients)
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 13-Jan-2012
+ */
+public final class MultipleClientsSignEncryptTestCase extends JBossWSTest
+{
+ private final String serviceURL = "http://" + getServerHost() +
":8080/jaxws-samples-wsse-policy-sign-encrypt-mc";
+
+ public static Test suite()
+ {
+ return new JBossWSCXFTestSetup(MultipleClientsSignEncryptTestCase.class,
+ "jaxws-samples-wsse-policy-sign-encrypt-mc-client.jar
jaxws-samples-wsse-policy-sign-encrypt-mc.war");
+ }
+
+ public void testAlice() throws Exception
+ {
+ QName serviceName = new
QName("http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy",
"SecurityService");
+ URL wsdlURL = new URL(serviceURL + "?wsdl");
+ Service service = Service.create(wsdlURL, serviceName);
+ ServiceIface proxy = (ServiceIface)service.getPort(ServiceIface.class);
+ setupWsse(proxy, "alice");
+ try
+ {
+ assertEquals("Multiple Clients Secure Hello World!",
proxy.sayHello());
+ }
+ catch (SOAPFaultException e)
+ {
+ throw new Exception("Please check that the Bouncy Castle provider is
installed.", e);
+ }
+ }
+
+ public void testJohn() throws Exception
+ {
+ QName serviceName = new
QName("http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy",
"SecurityService");
+ URL wsdlURL = new URL(serviceURL + "?wsdl");
+ Service service = Service.create(wsdlURL, serviceName);
+ ServiceIface proxy = (ServiceIface)service.getPort(ServiceIface.class);
+ setupWsse(proxy, "john");
+ try
+ {
+ assertEquals("Multiple Clients Secure Hello World!",
proxy.sayHello());
+ }
+ catch (SOAPFaultException e)
+ {
+ throw new Exception("Please check that the Bouncy Castle provider is
installed.", e);
+ }
+ }
+
+ private void setupWsse(ServiceIface proxy, String client)
+ {
+
((BindingProvider)proxy).getRequestContext().put(SecurityConstants.CALLBACK_HANDLER, new
KeystorePasswordCallback());
+
((BindingProvider)proxy).getRequestContext().put(SecurityConstants.SIGNATURE_PROPERTIES,
Thread.currentThread().getContextClassLoader().getResource("META-INF/" + client
+ ".properties"));
+
((BindingProvider)proxy).getRequestContext().put(SecurityConstants.ENCRYPT_PROPERTIES,
Thread.currentThread().getContextClassLoader().getResource("META-INF/" + client
+ ".properties"));
+
((BindingProvider)proxy).getRequestContext().put(SecurityConstants.SIGNATURE_USERNAME,
client);
+
((BindingProvider)proxy).getRequestContext().put(SecurityConstants.ENCRYPT_USERNAME,
"bob");
+ }
+}
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/sign-encrypt/META-INF/john.jks
===================================================================
(Binary files differ)
Property changes on:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/sign-encrypt/META-INF/john.jks
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/sign-encrypt/META-INF/john.properties
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/sign-encrypt/META-INF/john.properties
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/sign-encrypt/META-INF/john.properties 2012-01-13
13:50:40 UTC (rev 15486)
@@ -0,0 +1,5 @@
+org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin
+org.apache.ws.security.crypto.merlin.keystore.type=jks
+org.apache.ws.security.crypto.merlin.keystore.password=password
+org.apache.ws.security.crypto.merlin.keystore.alias=john
+org.apache.ws.security.crypto.merlin.file=META-INF/john.jks
\ No newline at end of file
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/sign-encrypt/WEB-INF/bob2.jks
===================================================================
(Binary files differ)
Property changes on:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/sign-encrypt/WEB-INF/bob2.jks
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/sign-encrypt/WEB-INF/bob2.properties
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/sign-encrypt/WEB-INF/bob2.properties
(rev 0)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/sign-encrypt/WEB-INF/bob2.properties 2012-01-13
13:50:40 UTC (rev 15486)
@@ -0,0 +1,5 @@
+org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin
+org.apache.ws.security.crypto.merlin.keystore.type=jks
+org.apache.ws.security.crypto.merlin.keystore.password=password
+org.apache.ws.security.crypto.merlin.keystore.alias=bob
+org.apache.ws.security.crypto.merlin.file=bob2.jks
\ No newline at end of file