[jbossws-commits] JBossWS SVN: r17654 - in stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests: src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic and 1 other directory.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Wed Jun 5 13:55:24 EDT 2013


Author: alessio.soldano at jboss.com
Date: 2013-06-05 13:55:24 -0400 (Wed, 05 Jun 2013)
New Revision: 17654

Added:
   stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/AnnotatedServiceIface.java
   stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/AnnotatedServiceImpl.java
   stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/AnnotatedSignEncryptTestCase.java
Modified:
   stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/scripts/cxf-samples-jars-jaxws.xml
Log:
Adding ws-security policy test


Modified: stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/scripts/cxf-samples-jars-jaxws.xml
===================================================================
--- stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/scripts/cxf-samples-jars-jaxws.xml	2013-06-05 17:54:10 UTC (rev 17653)
+++ stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/scripts/cxf-samples-jars-jaxws.xml	2013-06-05 17:55:24 UTC (rev 17654)
@@ -340,6 +340,23 @@
        </manifest>
     </war>
 
+    <!-- jaxws-samples-wsse-policy-sign-encrypt-gcm-code-first -->
+    <war
+       warfile="${tests.output.dir}/test-libs/jaxws-samples-wsse-policy-sign-encrypt-gcm-code-first.war" needxmlfile='false'>
+       <classes dir="${tests.output.dir}/test-classes">
+          <include name="org/jboss/test/ws/jaxws/samples/wsse/policy/basic/AnnotatedService*.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>
+       <zipfileset dir="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/basic/gcm/WEB-INF" prefix="WEB-INF/classes">
+          <include name="bob.jks" />
+          <include name="bob.properties" />
+       </zipfileset>
+       <manifest>
+         <attribute name="Dependencies" value="org.jboss.ws.cxf.jbossws-cxf-client, org.apache.ws.security"/>
+       </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'>

Added: stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/AnnotatedServiceIface.java
===================================================================
--- stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/AnnotatedServiceIface.java	                        (rev 0)
+++ stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/AnnotatedServiceIface.java	2013-06-05 17:55:24 UTC (rev 17654)
@@ -0,0 +1,38 @@
+/*
+ * 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.WebMethod;
+import javax.jws.WebService;
+
+import org.jboss.wsf.stack.cxf.policy.PolicySets;
+
+ at WebService
+(
+   targetNamespace = "http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy"
+)
+ at PolicySets("AsymmetricBinding_X509v1_GCM192OAEP_ProtectTokens")
+public interface AnnotatedServiceIface
+{
+   @WebMethod
+   String sayHello();
+}

Added: stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/AnnotatedServiceImpl.java
===================================================================
--- stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/AnnotatedServiceImpl.java	                        (rev 0)
+++ stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/AnnotatedServiceImpl.java	2013-06-05 17:55:24 UTC (rev 17654)
@@ -0,0 +1,50 @@
+/*
+ * 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 org.apache.cxf.annotations.EndpointProperties;
+import org.apache.cxf.annotations.EndpointProperty;
+
+ at WebService(
+   portName = "AnnotatedSecurityServicePort",
+   serviceName = "AnnotatedSecurityService",
+   name = "AnnotatedServiceIface",
+   endpointInterface = "org.jboss.test.ws.jaxws.samples.wsse.policy.basic.AnnotatedServiceIface",
+   targetNamespace = "http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy"
+)
+ at EndpointProperties(value = {
+      @EndpointProperty(key = "ws-security.signature.properties", value = "bob.properties"),
+      @EndpointProperty(key = "ws-security.encryption.properties", value = "bob.properties"),
+      @EndpointProperty(key = "ws-security.signature.username", value = "bob"),
+      @EndpointProperty(key = "ws-security.encryption.username", value = "alice"),
+      @EndpointProperty(key = "ws-security.callback-handler", value = "org.jboss.test.ws.jaxws.samples.wsse.policy.basic.KeystorePasswordCallback")
+      }
+)
+public class AnnotatedServiceImpl implements AnnotatedServiceIface
+{
+   public String sayHello()
+   {
+      return "Secure Hello World!";
+   }
+}

Added: stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/AnnotatedSignEncryptTestCase.java
===================================================================
--- stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/AnnotatedSignEncryptTestCase.java	                        (rev 0)
+++ stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/AnnotatedSignEncryptTestCase.java	2013-06-05 17:55:24 UTC (rev 17654)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, 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 junit.framework.Test;
+
+import org.apache.cxf.ws.security.SecurityConstants;
+import org.jboss.wsf.test.JBossWSCXFTestSetup;
+import org.jboss.wsf.test.JBossWSTest;
+
+/**
+ * WS-SecurityPolicy code first dev test
+ *
+ * @author alessio.soldano at jboss.com
+ * @since 05-Jun-2013
+ */
+public final class AnnotatedSignEncryptTestCase extends JBossWSTest
+{
+   private final String serviceURL = "http://" + getServerHost() + ":8080/jaxws-samples-wsse-policy-sign-encrypt-gcm-code-first/AnnotatedSecurityService";
+
+   public static Test suite()
+   {
+      return new JBossWSCXFTestSetup(AnnotatedSignEncryptTestCase.class, "jaxws-samples-wsse-policy-sign-encrypt-gcm-code-first.war jaxws-samples-wsse-policy-sign-encrypt-client.jar");
+   }
+
+   public void test() throws Exception
+   {
+      QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy", "AnnotatedSecurityService");
+      URL wsdlURL = new URL(serviceURL + "?wsdl");
+      Service service = Service.create(wsdlURL, serviceName);
+      AnnotatedServiceIface proxy = (AnnotatedServiceIface)service.getPort(AnnotatedServiceIface.class);
+      setupWsse(proxy);
+      assertEquals("Secure Hello World!", proxy.sayHello());
+   }
+
+   private void setupWsse(AnnotatedServiceIface proxy)
+   {
+      ((BindingProvider)proxy).getRequestContext().put(SecurityConstants.CALLBACK_HANDLER, new KeystorePasswordCallback());
+      ((BindingProvider)proxy).getRequestContext().put(SecurityConstants.SIGNATURE_PROPERTIES, Thread.currentThread().getContextClassLoader().getResource("META-INF/alice.properties"));
+      ((BindingProvider)proxy).getRequestContext().put(SecurityConstants.ENCRYPT_PROPERTIES, Thread.currentThread().getContextClassLoader().getResource("META-INF/alice.properties"));
+      ((BindingProvider)proxy).getRequestContext().put(SecurityConstants.SIGNATURE_USERNAME, "alice");
+      ((BindingProvider)proxy).getRequestContext().put(SecurityConstants.ENCRYPT_USERNAME, "bob");
+   }
+}



More information about the jbossws-commits mailing list