Author: alessio.soldano(a)jboss.com
Date: 2012-10-24 11:27:40 -0400 (Wed, 24 Oct 2012)
New Revision: 16945
Added:
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/JavaFirstServiceIface.java
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/JavaFirstServiceImpl.java
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/username-unsecure-transport/JavaFirstPolicy.xml
Modified:
stack/cxf/branches/jbossws-cxf-4.0.x/
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/scripts/cxf-samples-jars-jaxws.xml
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/UsernameTestCase.java
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/username-unsecure-transport/WEB-INF/web.xml
Log:
Merged revisions 16943-16944 via svnmerge from
https://svn.jboss.org/repos/jbossws/stack/cxf/trunk
.......
r16943 | alessio.soldano(a)jboss.com | 2012-10-24 16:56:40 +0200 (Wed, 24 Oct 2012) | 2
lines
[AS7-5827] Adding sample demonstrating proper javafirst ws-security policy usage
.......
r16944 | alessio.soldano(a)jboss.com | 2012-10-24 17:23:26 +0200 (Wed, 24 Oct 2012) | 3
lines
[AS7-5827] Do not provide @Policy annotation on client side
.......
Property changes on: stack/cxf/branches/jbossws-cxf-4.0.x
___________________________________________________________________
Modified: svnmerge-integrated
-
https://svn.jboss.org/repos/jbossws/stack/cxf/trunk:1-15635,15658,15668,1...
+
https://svn.jboss.org/repos/jbossws/stack/cxf/trunk:1-15635,15658,15668,1...
Modified: svn:mergeinfo
- /stack/cxf/branches/asoldano:14032-14050,14068
/stack/cxf/trunk:15658,15668,15674-15675,15682,15695-15697,15708,15711,15713,15719,15723-15730,15738,15743,15748,15750-15751,15754-15757,15765-15766,15768,15773,15780-15781,15784,15794,15806-15808,15824,15835,15837-15857,15859,15866,15879-15881,15886-15889,15896,15900-15920,15936,15965,15967,15973,16067,16071,16086-16087,16096,16176,16183,16204-16205,16227,16230,16244-16245,16306,16315,16323,16407-16408,16412,16418,16516,16530-16532,16619,16636-16644,16691,16729-16730,16738,16782,16817
+ /stack/cxf/branches/asoldano:14032-14050,14068
/stack/cxf/trunk:15658,15668,15674-15675,15682,15695-15697,15708,15711,15713,15719,15723-15730,15738,15743,15748,15750-15751,15754-15757,15765-15766,15768,15773,15780-15781,15784,15794,15806-15808,15824,15835,15837-15857,15859,15866,15879-15881,15886-15889,15896,15900-15920,15936,15965,15967,15973,16067,16071,16086-16087,16096,16176,16183,16204-16205,16227,16230,16244-16245,16306,16315,16323,16407-16408,16412,16418,16516,16530-16532,16619,16636-16644,16691,16729-16730,16738,16782,16817,16943-16944
Modified:
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/scripts/cxf-samples-jars-jaxws.xml
===================================================================
---
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/scripts/cxf-samples-jars-jaxws.xml 2012-10-24
15:23:26 UTC (rev 16944)
+++
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/scripts/cxf-samples-jars-jaxws.xml 2012-10-24
15:27:40 UTC (rev 16945)
@@ -211,6 +211,7 @@
webxml="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/basic/username-unsecure-transport/WEB-INF/web.xml">
<classes dir="${tests.output.dir}/test-classes">
<include
name="org/jboss/test/ws/jaxws/samples/wsse/policy/basic/Service*.class"/>
+ <include
name="org/jboss/test/ws/jaxws/samples/wsse/policy/basic/JavaFirstService*.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/ServerUsernamePasswordCallback.class"/>
</classes>
@@ -218,8 +219,11 @@
<include name="jaxws-endpoint-config.xml"/>
<include name="wsdl/*"/>
</webinf>
+ <zipfileset
dir="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/basic/username-unsecure-transport"
prefix="WEB-INF/classes">
+ <include name="JavaFirstPolicy.xml" />
+ </zipfileset>
<manifest>
- <attribute name="Dependencies"
value="org.apache.ws.security"/>
+ <attribute name="Dependencies"
value="org.apache.cxf,org.apache.ws.security"/>
</manifest>
</war>
Copied:
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/JavaFirstServiceIface.java
(from rev 16944,
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/JavaFirstServiceIface.java)
===================================================================
---
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/JavaFirstServiceIface.java
(rev 0)
+++
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/JavaFirstServiceIface.java 2012-10-24
15:27:40 UTC (rev 16945)
@@ -0,0 +1,35 @@
+/*
+ * 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;
+
+@WebService
+(
+ targetNamespace =
"http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy"
+)
+public interface JavaFirstServiceIface
+{
+ @WebMethod
+ String sayHello();
+}
Copied:
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/JavaFirstServiceImpl.java
(from rev 16944,
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/JavaFirstServiceImpl.java)
===================================================================
---
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/JavaFirstServiceImpl.java
(rev 0)
+++
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/JavaFirstServiceImpl.java 2012-10-24
15:27:40 UTC (rev 16945)
@@ -0,0 +1,45 @@
+/*
+ * 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.Policy;
+import org.jboss.ws.api.annotation.EndpointConfig;
+
+@WebService
+(
+ portName = "JavaFirstSecurityServicePort",
+ serviceName = "JavaFirstSecurityService",
+ name = "JavaFirstServiceIface",
+ targetNamespace =
"http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy"
+)
+@Policy(placement = Policy.Placement.BINDING, uri = "JavaFirstPolicy.xml")
+@EndpointConfig(configFile = "WEB-INF/jaxws-endpoint-config.xml", configName =
"Custom WS-Security Endpoint")
+public class JavaFirstServiceImpl //Not extending JavaFirstServiceIface for testing
purposes only, to avoid having to
+ //move the @Policy annotation in the interface, which
is also used on client side.
+{
+ public String sayHello()
+ {
+ return "Secure Hello World!";
+ }
+}
Modified:
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/UsernameTestCase.java
===================================================================
---
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/UsernameTestCase.java 2012-10-24
15:23:26 UTC (rev 16944)
+++
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/UsernameTestCase.java 2012-10-24
15:27:40 UTC (rev 16945)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * 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.
*
@@ -41,7 +41,8 @@
*/
public final class UsernameTestCase extends JBossWSTest
{
- private final String serviceURL = "http://" + getServerHost() +
":8080/jaxws-samples-wsse-policy-username-unsecure-transport";
+ private final String serviceURL = "http://" + getServerHost() +
":8080/jaxws-samples-wsse-policy-username-unsecure-transport/service";
+ private final String javaFirstServiceURL = "http://" + getServerHost() +
":8080/jaxws-samples-wsse-policy-username-unsecure-transport/javafirst-service";
public static Test suite()
{
@@ -54,7 +55,7 @@
URL wsdlURL = new URL(serviceURL + "?wsdl");
Service service = Service.create(wsdlURL, serviceName);
ServiceIface proxy = (ServiceIface)service.getPort(ServiceIface.class);
- setupWsse(proxy, "kermit");
+ setupWsse((BindingProvider)proxy, "kermit");
assertEquals("Secure Hello World!", proxy.sayHello());
}
@@ -64,7 +65,7 @@
URL wsdlURL = new URL(serviceURL + "?wsdl");
Service service = Service.create(wsdlURL, serviceName);
ServiceIface proxy = (ServiceIface)service.getPort(ServiceIface.class);
- setupWsse(proxy, "snoopy");
+ setupWsse((BindingProvider)proxy, "snoopy");
try
{
proxy.sayHello();
@@ -76,9 +77,37 @@
}
}
- private void setupWsse(ServiceIface proxy, String username)
+ public void testJavaFirst() throws Exception
{
- ((BindingProvider)proxy).getRequestContext().put(SecurityConstants.USERNAME,
username);
-
((BindingProvider)proxy).getRequestContext().put(SecurityConstants.CALLBACK_HANDLER,
"org.jboss.test.ws.jaxws.samples.wsse.policy.basic.UsernamePasswordCallback");
+ QName serviceName = new
QName("http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy",
"JavaFirstSecurityService");
+ URL wsdlURL = new URL(javaFirstServiceURL + "?wsdl");
+ Service service = Service.create(wsdlURL, serviceName);
+ JavaFirstServiceIface proxy =
(JavaFirstServiceIface)service.getPort(JavaFirstServiceIface.class);
+ setupWsse((BindingProvider)proxy, "kermit");
+ assertEquals("Secure Hello World!", proxy.sayHello());
}
+
+ public void testJavaFirstWrongPassword() throws Exception
+ {
+ QName serviceName = new
QName("http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy",
"JavaFirstSecurityService");
+ URL wsdlURL = new URL(javaFirstServiceURL + "?wsdl");
+ Service service = Service.create(wsdlURL, serviceName);
+ JavaFirstServiceIface proxy =
(JavaFirstServiceIface)service.getPort(JavaFirstServiceIface.class);
+ setupWsse((BindingProvider)proxy, "snoopy");
+ try
+ {
+ proxy.sayHello();
+ fail("User snoopy shouldn't be authenticated.");
+ }
+ catch (Exception e)
+ {
+ //OK
+ }
+ }
+
+ private void setupWsse(BindingProvider proxy, String username)
+ {
+ proxy.getRequestContext().put(SecurityConstants.USERNAME, username);
+ proxy.getRequestContext().put(SecurityConstants.CALLBACK_HANDLER,
"org.jboss.test.ws.jaxws.samples.wsse.policy.basic.UsernamePasswordCallback");
+ }
}
Copied:
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/username-unsecure-transport/JavaFirstPolicy.xml
(from rev 16944,
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/username-unsecure-transport/JavaFirstPolicy.xml)
===================================================================
---
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/username-unsecure-transport/JavaFirstPolicy.xml
(rev 0)
+++
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/username-unsecure-transport/JavaFirstPolicy.xml 2012-10-24
15:27:40 UTC (rev 16945)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<wsp:Policy
wsu:Id="JavaFirstSecurityServiceUsernameUnsecureTransportPolicy"
+
xmlns:wsp="http://www.w3.org/ns/ws-policy"
+
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-w...
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <sp:SupportingTokens
xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"...
+ <wsp:Policy>
+ <sp:UsernameToken
sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolic...
+ <wsp:Policy>
+ <sp:WssUsernameToken10/>
+ </wsp:Policy>
+ </sp:UsernameToken>
+ </wsp:Policy>
+ </sp:SupportingTokens>
+ </wsp:All>
+ </wsp:ExactlyOne>
+</wsp:Policy>
\ No newline at end of file
Modified:
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/username-unsecure-transport/WEB-INF/web.xml
===================================================================
---
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/username-unsecure-transport/WEB-INF/web.xml 2012-10-24
15:23:26 UTC (rev 16944)
+++
stack/cxf/branches/jbossws-cxf-4.0.x/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/username-unsecure-transport/WEB-INF/web.xml 2012-10-24
15:27:40 UTC (rev 16945)
@@ -8,8 +8,16 @@
<servlet-name>TestService</servlet-name>
<servlet-class>org.jboss.test.ws.jaxws.samples.wsse.policy.basic.ServiceImpl</servlet-class>
</servlet>
+ <servlet>
+ <servlet-name>JavaFirstTestService</servlet-name>
+
<servlet-class>org.jboss.test.ws.jaxws.samples.wsse.policy.basic.JavaFirstServiceImpl</servlet-class>
+ </servlet>
<servlet-mapping>
<servlet-name>TestService</servlet-name>
- <url-pattern>/*</url-pattern>
+ <url-pattern>/service</url-pattern>
</servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>JavaFirstTestService</servlet-name>
+ <url-pattern>/javafirst-service</url-pattern>
+ </servlet-mapping>
</web-app>