Author: alessio.soldano(a)jboss.com
Date: 2013-06-13 06:40:12 -0400 (Thu, 13 Jun 2013)
New Revision: 17668
Added:
stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3648/EndpointThree.java
stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3648/EndpointThreeImpl.java
stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3648/KeystorePasswordCallback.java
stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3648/PolicyAttachmentTestCase.java
stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3648-b/
stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3648-b/META-INF/
stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3648-b/META-INF/alice.jks
stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3648-b/META-INF/alice.properties
stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3648-b/WEB-INF/
stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3648-b/WEB-INF/bob.jks
stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3648-b/WEB-INF/bob.properties
Modified:
stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml
Log:
Adding testcase using WSSE + WSSA through @PolicySets
Modified:
stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml
===================================================================
---
stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml 2013-06-13
10:38:02 UTC (rev 17667)
+++
stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml 2013-06-13
10:40:12 UTC (rev 17668)
@@ -343,6 +343,27 @@
</manifest>
</war>
+ <!-- jaxws-cxf-jbws3648-b -->
+ <war warfile="${tests.output.dir}/test-libs/jaxws-cxf-jbws3648-b.war"
needxmlfile='false'>
+ <classes dir="${tests.output.dir}/test-classes">
+ <include
name="org/jboss/test/ws/jaxws/cxf/jbws3648/EndpointThree*.class"/>
+ <include
name="org/jboss/test/ws/jaxws/cxf/jbws3648/KeystorePasswordCallback.class"/>
+ </classes>
+ <zipfileset
dir="${tests.output.dir}/test-resources/jaxws/cxf/jbws3648-b/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>
+ <jar
destfile="${tests.output.dir}/test-libs/jaxws-cxf-jbws3648-b-client.jar">
+ <metainf
dir="${tests.output.dir}/test-resources/jaxws/cxf/jbws3648-b/META-INF">
+ <include name="alice.properties" />
+ <include name="alice.jks" />
+ </metainf>
+ </jar>
+
<!-- jaxws-cxf-logging -->
<jar destfile="${tests.output.dir}/test-libs/jaxws-cxf-logging.jar">
<fileset dir="${tests.output.dir}/test-classes">
Added:
stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3648/EndpointThree.java
===================================================================
---
stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3648/EndpointThree.java
(rev 0)
+++
stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3648/EndpointThree.java 2013-06-13
10:40:12 UTC (rev 17668)
@@ -0,0 +1,35 @@
+/*
+ * 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.cxf.jbws3648;
+
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+import org.jboss.wsf.stack.cxf.policy.PolicySets;
+
+@WebService(name = "EndpointThree", targetNamespace =
"http://org.jboss.ws.jaxws.cxf/jbws3648")
+@SOAPBinding(style = SOAPBinding.Style.RPC)
+@PolicySets({"AsymmetricBinding_X509v1_TripleDesRsa15_EncryptBeforeSigning_ProtectTokens",
"WS-Addressing"})
+public interface EndpointThree
+{
+ String echo(String input);
+}
Added:
stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3648/EndpointThreeImpl.java
===================================================================
---
stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3648/EndpointThreeImpl.java
(rev 0)
+++
stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3648/EndpointThreeImpl.java 2013-06-13
10:40:12 UTC (rev 17668)
@@ -0,0 +1,53 @@
+/*
+ * 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.cxf.jbws3648;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+
+import org.apache.cxf.annotations.EndpointProperties;
+import org.apache.cxf.annotations.EndpointProperty;
+import org.jboss.logging.Logger;
+
+@WebService(name = "EndpointThree",
+ targetNamespace = "http://org.jboss.ws.jaxws.cxf/jbws3648",
+ serviceName = "ServiceThree",
+ endpointInterface =
"org.jboss.test.ws.jaxws.cxf.jbws3648.EndpointThree")
+@SOAPBinding(style = SOAPBinding.Style.RPC)
+@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.cxf.jbws3648.KeystorePasswordCallback")
+ }
+)
+public class EndpointThreeImpl implements EndpointThree
+{
+ @WebMethod
+ public String echo(String input)
+ {
+ Logger.getLogger(this.getClass()).info("echo: " + input);
+ return input;
+ }
+}
Added:
stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3648/KeystorePasswordCallback.java
===================================================================
---
stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3648/KeystorePasswordCallback.java
(rev 0)
+++
stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3648/KeystorePasswordCallback.java 2013-06-13
10:40:12 UTC (rev 17668)
@@ -0,0 +1,71 @@
+/*
+ * 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.cxf.jbws3648;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+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 KeystorePasswordCallback implements CallbackHandler
+{
+
+ private Map<String, String> passwords = new HashMap<String, String>();
+
+ public KeystorePasswordCallback()
+ {
+ passwords.put("alice", "password");
+ passwords.put("bob", "password");
+ passwords.put("john", "password");
+ }
+
+ /**
+ * It attempts to get the password from the private
+ * alias/passwords map.
+ */
+ public void handle(Callback[] callbacks) throws IOException,
UnsupportedCallbackException
+ {
+ for (int i = 0; i < callbacks.length; i++)
+ {
+ WSPasswordCallback pc = (WSPasswordCallback)callbacks[i];
+
+ String pass = passwords.get(pc.getIdentifier());
+ if (pass != null)
+ {
+ pc.setPassword(pass);
+ return;
+ }
+ }
+ }
+
+ /**
+ * Add an alias/password pair to the callback mechanism.
+ */
+ public void setAliasPassword(String alias, String password)
+ {
+ passwords.put(alias, password);
+ }
+}
Added:
stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3648/PolicyAttachmentTestCase.java
===================================================================
---
stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3648/PolicyAttachmentTestCase.java
(rev 0)
+++
stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3648/PolicyAttachmentTestCase.java 2013-06-13
10:40:12 UTC (rev 17668)
@@ -0,0 +1,87 @@
+/*
+ * 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.cxf.jbws3648;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintWriter;
+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.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.interceptor.LoggingInInterceptor;
+import org.apache.cxf.ws.security.SecurityConstants;
+import org.jboss.wsf.test.JBossWSCXFTestSetup;
+import org.jboss.wsf.test.JBossWSTest;
+
+/**
+ *
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 13-Jun-2013
+ */
+public class PolicyAttachmentTestCase extends JBossWSTest
+{
+ public static Test suite()
+ {
+ return new JBossWSCXFTestSetup(PolicyAttachmentTestCase.class,
"jaxws-cxf-jbws3648-b.war, jaxws-cxf-jbws3648-b-client.jar");
+ }
+
+ public void testEndpointWithWSSEAndWSA() throws Exception {
+ Bus bus = BusFactory.newInstance().createBus();
+ BusFactory.setThreadDefaultBus(bus);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ PrintWriter pw = new PrintWriter(bos);
+ try {
+ bus.getInInterceptors().add(new LoggingInInterceptor(pw));
+
+ URL wsdlURL = new URL("http://" + getServerHost() +
":8080/jaxws-cxf-jbws3648-b/ServiceThree" + "?wsdl");
+ QName serviceName = new
QName("http://org.jboss.ws.jaxws.cxf/jbws3648", "ServiceThree");
+ Service service = Service.create(wsdlURL, serviceName);
+ EndpointThree proxy = (EndpointThree)service.getPort(EndpointThree.class);
+ setupWsse(proxy);
+
+ assertEquals("Foo", proxy.echo("Foo"));
+ final String m = bos.toString();
+ assertTrue("WS-Addressing was not enabled!",
m.contains("http://www.w3.org/2005/08/addressing") &&
m.contains("http://www.w3.org/2005/08/addressing/anonymous"));
+ assertTrue("WS-Security was not enabled!",
m.contains("http://www.w3.org/2001/04/xmlenc#rsa-1_5"));
+ } finally {
+ bus.shutdown(true);
+ pw.close();
+ bos.close();
+ }
+ }
+
+ private void setupWsse(EndpointThree 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");
+ }
+}
Added:
stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3648-b/META-INF/alice.jks
===================================================================
(Binary files differ)
Property changes on:
stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3648-b/META-INF/alice.jks
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added:
stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3648-b/META-INF/alice.properties
===================================================================
---
stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3648-b/META-INF/alice.properties
(rev 0)
+++
stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3648-b/META-INF/alice.properties 2013-06-13
10:40:12 UTC (rev 17668)
@@ -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=alice
+org.apache.ws.security.crypto.merlin.file=META-INF/alice.jks
\ No newline at end of file
Added:
stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3648-b/WEB-INF/bob.jks
===================================================================
(Binary files differ)
Property changes on:
stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3648-b/WEB-INF/bob.jks
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added:
stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3648-b/WEB-INF/bob.properties
===================================================================
---
stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3648-b/WEB-INF/bob.properties
(rev 0)
+++
stack/cxf/branches/JBWS-3648/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3648-b/WEB-INF/bob.properties 2013-06-13
10:40:12 UTC (rev 17668)
@@ -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=bob.jks
\ No newline at end of file