JBossWS SVN: r14437 - in stack/cxf/trunk/modules/testsuite/cxf-tests: src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas and 1 other directories.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2011-05-26 09:08:10 -0400 (Thu, 26 May 2011)
New Revision: 14437
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/POJOEndpointAuthorizationInterceptor.java
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/ServiceIface.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/ServiceImpl.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/UsernameAuthorizationTestCase.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/jaas/auth/WEB-INF/wsdl/SecurityService.wsdl
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/jaas/auth/WEB-INF/wsdl/SecurityService_schema1.xsd
Log:
[JBWS-3302] Also add authorization testcase
Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml 2011-05-26 12:17:47 UTC (rev 14436)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml 2011-05-26 13:08:10 UTC (rev 14437)
@@ -320,6 +320,7 @@
<classes dir="${tests.output.dir}/test-classes">
<include name="org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/Service*.class"/>
<include name="org/jboss/test/ws/jaxws/samples/wsse/policy/jaxws/*.class"/>
+ <include name="org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/POJOEndpointAuthorizationInterceptor.class"/>
</classes>
<webinf dir="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/jaas/auth/WEB-INF">
<include name="jaxws-endpoint-config.xml"/>
Added: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/POJOEndpointAuthorizationInterceptor.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/POJOEndpointAuthorizationInterceptor.java (rev 0)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/POJOEndpointAuthorizationInterceptor.java 2011-05-26 13:08:10 UTC (rev 14437)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.jaas;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.cxf.interceptor.security.SimpleAuthorizingInterceptor;
+
+
+/**
+ * A custom interceptor for method-level POJO endpoint authorization
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 26-May-2011
+ *
+ */
+public class POJOEndpointAuthorizationInterceptor extends SimpleAuthorizingInterceptor
+{
+
+ public POJOEndpointAuthorizationInterceptor()
+ {
+ super();
+ readRoles();
+ }
+
+ private void readRoles()
+ {
+ //just an example, this might read from a configuration file or such
+ Map<String, String> roles = new HashMap<String, String>();
+ roles.put("sayHello", "friend");
+ roles.put("greetMe", "snoppies");
+ setMethodRolesMap(roles);
+ }
+}
Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/ServiceIface.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/ServiceIface.java 2011-05-26 12:17:47 UTC (rev 14436)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/ServiceIface.java 2011-05-26 13:08:10 UTC (rev 14437)
@@ -32,4 +32,7 @@
{
@WebMethod
String sayHello();
+
+ @WebMethod
+ String greetMe();
}
Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/ServiceImpl.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/ServiceImpl.java 2011-05-26 12:17:47 UTC (rev 14436)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/ServiceImpl.java 2011-05-26 13:08:10 UTC (rev 14437)
@@ -35,11 +35,20 @@
endpointInterface = "org.jboss.test.ws.jaxws.samples.wsse.policy.jaas.ServiceIface"
)
@EndpointConfig(configFile = "WEB-INF/jaxws-endpoint-config.xml", configName = "Custom WS-Security Endpoint")
-@InInterceptors(interceptors = "org.jboss.wsf.stack.cxf.security.authentication.SubjectCreatingPolicyInterceptor") //be sure to have dependency on org.apache.cxf module when on AS7
+//be sure to have dependency on org.apache.cxf module when on AS7, otherwise Apache CXF annotations are ignored
+@InInterceptors(interceptors = {
+ "org.jboss.wsf.stack.cxf.security.authentication.SubjectCreatingPolicyInterceptor",
+ "org.jboss.test.ws.jaxws.samples.wsse.policy.jaas.POJOEndpointAuthorizationInterceptor"}
+)
public class ServiceImpl implements ServiceIface
{
public String sayHello()
{
return "Secure Hello World!";
}
+
+ public String greetMe()
+ {
+ return "Greetings!";
+ }
}
Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/UsernameAuthorizationTestCase.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/UsernameAuthorizationTestCase.java 2011-05-26 12:17:47 UTC (rev 14436)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/UsernameAuthorizationTestCase.java 2011-05-26 13:08:10 UTC (rev 14437)
@@ -58,7 +58,7 @@
assertEquals("Secure Hello World!", proxy.sayHello());
}
- public void testWrongPassword() throws Exception
+ public void testUnauthenticated() throws Exception
{
QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy", "SecurityService");
URL wsdlURL = new URL(serviceURL + "?wsdl");
@@ -75,6 +75,24 @@
//OK
}
}
+
+ public void testUnauthorized() 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, "kermit");
+ try
+ {
+ proxy.greetMe();
+ fail("User kermit shouldn't be authorized to call greetMe().");
+ }
+ catch (Exception e)
+ {
+ assertEquals("Unauthorized", e.getMessage());
+ }
+ }
private void setupWsse(ServiceIface proxy, String username)
{
Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/jaas/auth/WEB-INF/wsdl/SecurityService.wsdl
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/jaas/auth/WEB-INF/wsdl/SecurityService.wsdl 2011-05-26 12:17:47 UTC (rev 14436)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/jaas/auth/WEB-INF/wsdl/SecurityService.wsdl 2011-05-26 13:08:10 UTC (rev 14437)
@@ -20,11 +20,21 @@
<message name="sayHelloResponse">
<part name="parameters" element="tns:sayHelloResponse"/>
</message>
+ <message name="greetMe">
+ <part name="parameters" element="tns:greetMe"/>
+ </message>
+ <message name="greetMeResponse">
+ <part name="parameters" element="tns:greetMeResponse"/>
+ </message>
<portType name="ServiceIface">
<operation name="sayHello">
<input message="tns:sayHello"/>
<output message="tns:sayHelloResponse"/>
</operation>
+ <operation name="greetMe">
+ <input message="tns:greetMe"/>
+ <output message="tns:greetMeResponse"/>
+ </operation>
</portType>
<binding name="SecurityServicePortBinding" type="tns:ServiceIface">
<wsp:PolicyReference URI="#SecurityServiceUsernameUnsecureTransportPolicy"/>
@@ -38,6 +48,15 @@
<soap:body use="literal"/>
</output>
</operation>
+ <operation name="greetMe">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
</binding>
<service name="SecurityService">
<port name="SecurityServicePort" binding="tns:SecurityServicePortBinding">
Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/jaas/auth/WEB-INF/wsdl/SecurityService_schema1.xsd
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/jaas/auth/WEB-INF/wsdl/SecurityService_schema1.xsd 2011-05-26 12:17:47 UTC (rev 14436)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/jaas/auth/WEB-INF/wsdl/SecurityService_schema1.xsd 2011-05-26 13:08:10 UTC (rev 14437)
@@ -14,5 +14,19 @@
<xs:element name="return" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
+
+ <xs:element name="greetMe" type="tns:greetMe"/>
+
+ <xs:element name="greetMeResponse" type="tns:greetMeResponse"/>
+
+ <xs:complexType name="greetMe">
+ <xs:sequence/>
+ </xs:complexType>
+
+ <xs:complexType name="greetMeResponse">
+ <xs:sequence>
+ <xs:element name="return" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
</xs:schema>
13 years, 7 months
JBossWS SVN: r14436 - in stack/cxf/trunk/modules/testsuite/cxf-tests: src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy and 6 other directories.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2011-05-26 08:17:47 -0400 (Thu, 26 May 2011)
New Revision: 14436
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/ServiceIface.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/ServiceImpl.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/UsernameAuthorizationTestCase.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/UsernamePasswordCallback.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/jaas/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/jaas/auth/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/jaas/auth/WEB-INF/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/jaas/auth/WEB-INF/jaxws-endpoint-config.xml
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/jaas/auth/WEB-INF/jboss-web.xml
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/jaas/auth/WEB-INF/web.xml
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/jaas/auth/WEB-INF/wsdl/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/jaas/auth/WEB-INF/wsdl/SecurityService.wsdl
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/jaas/auth/WEB-INF/wsdl/SecurityService_schema1.xsd
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml
Log:
[JBWS-3302] Adding testcase
Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml 2011-05-26 12:16:19 UTC (rev 14435)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml 2011-05-26 12:17:47 UTC (rev 14436)
@@ -313,6 +313,24 @@
</manifest>
</war>
+ <!-- jaxws-samples-wsse-policy-username-jaas -->
+ <war
+ warfile="${tests.output.dir}/test-libs/jaxws-samples-wsse-policy-username-jaas.war"
+ webxml="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/jaas/auth/WEB-INF/web.xml">
+ <classes dir="${tests.output.dir}/test-classes">
+ <include name="org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/Service*.class"/>
+ <include name="org/jboss/test/ws/jaxws/samples/wsse/policy/jaxws/*.class"/>
+ </classes>
+ <webinf dir="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/jaas/auth/WEB-INF">
+ <include name="jaxws-endpoint-config.xml"/>
+ <include name="jboss-web.xml"/>
+ <include name="wsdl/*"/>
+ </webinf>
+ <manifest>
+ <attribute name="Dependencies" value="org.apache.ws.security,org.apache.cxf"/>
+ </manifest>
+ </war>
+
<!-- saaj-soap-connection -->
<war
warfile="${tests.output.dir}/test-libs/saaj-soap-connection.war"
Added: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/ServiceIface.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/ServiceIface.java (rev 0)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/ServiceIface.java 2011-05-26 12:17:47 UTC (rev 14436)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.jaas;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+
+@WebService
+(
+ targetNamespace = "http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy"
+)
+public interface ServiceIface
+{
+ @WebMethod
+ String sayHello();
+}
Added: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/ServiceImpl.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/ServiceImpl.java (rev 0)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/ServiceImpl.java 2011-05-26 12:17:47 UTC (rev 14436)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.jaas;
+
+import javax.jws.WebService;
+
+import org.apache.cxf.interceptor.InInterceptors;
+import org.jboss.ws.api.annotation.EndpointConfig;
+
+@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.jaas.ServiceIface"
+)
+@EndpointConfig(configFile = "WEB-INF/jaxws-endpoint-config.xml", configName = "Custom WS-Security Endpoint")
+@InInterceptors(interceptors = "org.jboss.wsf.stack.cxf.security.authentication.SubjectCreatingPolicyInterceptor") //be sure to have dependency on org.apache.cxf module when on AS7
+public class ServiceImpl implements ServiceIface
+{
+ public String sayHello()
+ {
+ return "Secure Hello World!";
+ }
+}
Added: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/UsernameAuthorizationTestCase.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/UsernameAuthorizationTestCase.java (rev 0)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/UsernameAuthorizationTestCase.java 2011-05-26 12:17:47 UTC (rev 14436)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.jaas;
+
+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-Security Policy username test case leveraging JAAS container integration
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 26-May-2011
+ */
+public final class UsernameAuthorizationTestCase extends JBossWSTest
+{
+ private final String serviceURL = "http://" + getServerHost() + ":8080/jaxws-samples-wsse-policy-username-jaas";
+
+ public static Test suite()
+ {
+ return new JBossWSCXFTestSetup(UsernameAuthorizationTestCase.class, "jaxws-samples-wsse-policy-username-jaas.war");
+ }
+
+ public void test() 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, "kermit");
+ assertEquals("Secure Hello World!", proxy.sayHello());
+ }
+
+ public void testWrongPassword() 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, "snoopy");
+ try
+ {
+ proxy.sayHello();
+ fail("User snoopy shouldn't be authenticated.");
+ }
+ catch (Exception e)
+ {
+ //OK
+ }
+ }
+
+ private void setupWsse(ServiceIface proxy, String username)
+ {
+ ((BindingProvider)proxy).getRequestContext().put(SecurityConstants.USERNAME, username);
+ ((BindingProvider)proxy).getRequestContext().put(SecurityConstants.CALLBACK_HANDLER, "org.jboss.test.ws.jaxws.samples.wsse.policy.jaas.UsernamePasswordCallback");
+ }
+}
Added: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/UsernamePasswordCallback.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/UsernamePasswordCallback.java (rev 0)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/jaas/UsernamePasswordCallback.java 2011-05-26 12:17:47 UTC (rev 14436)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.jaas;
+
+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 UsernamePasswordCallback implements CallbackHandler
+{
+ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
+ {
+ WSPasswordCallback pc = (WSPasswordCallback)callbacks[0];
+ if ("kermit".equals(pc.getIdentifier()))
+ pc.setPassword("thefrog");
+ else
+ pc.setPassword("wrong password");
+ }
+}
Added: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/jaas/auth/WEB-INF/jaxws-endpoint-config.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/jaas/auth/WEB-INF/jaxws-endpoint-config.xml (rev 0)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/jaas/auth/WEB-INF/jaxws-endpoint-config.xml 2011-05-26 12:17:47 UTC (rev 14436)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jaxws-config xmlns="urn:jboss:jbossws-jaxws-config:4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:javaee="http://java.sun.com/xml/ns/javaee"
+ xsi:schemaLocation="urn:jboss:jbossws-jaxws-config:4.0 schema/jbossws-jaxws-config_4_0.xsd">
+
+ <endpoint-config>
+ <config-name>Custom WS-Security Endpoint</config-name>
+ <property>
+ <property-name>ws-security.validate.token</property-name>
+ <property-value>false</property-value>
+ </property>
+ </endpoint-config>
+
+</jaxws-config>
\ No newline at end of file
Added: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/jaas/auth/WEB-INF/jboss-web.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/jaas/auth/WEB-INF/jboss-web.xml (rev 0)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/jaas/auth/WEB-INF/jboss-web.xml 2011-05-26 12:17:47 UTC (rev 14436)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 2.4//EN" "http://www.jboss.org/j2ee/dtd/jboss-web_4_0.dtd">
+
+<jboss-web>
+ <security-domain>java:/jaas/JBossWS</security-domain>
+</jboss-web>
Added: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/jaas/auth/WEB-INF/web.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/jaas/auth/WEB-INF/web.xml (rev 0)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/jaas/auth/WEB-INF/web.xml 2011-05-26 12:17:47 UTC (rev 14436)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app
+ version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+ <servlet>
+ <servlet-name>TestService</servlet-name>
+ <servlet-class>org.jboss.test.ws.jaxws.samples.wsse.policy.jaas.ServiceImpl</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>TestService</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+</web-app>
Added: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/jaas/auth/WEB-INF/wsdl/SecurityService.wsdl
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/jaas/auth/WEB-INF/wsdl/SecurityService.wsdl (rev 0)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/jaas/auth/WEB-INF/wsdl/SecurityService.wsdl 2011-05-26 12:17:47 UTC (rev 14436)
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<definitions targetNamespace="http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy" name="SecurityService"
+ xmlns:tns="http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:wsp="http://www.w3.org/ns/ws-policy"
+ xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utilit..."
+ xmlns:wsaws="http://www.w3.org/2005/08/addressing"
+ xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"
+ xmlns:wspp="http://java.sun.com/xml/ns/wsit/policy">
+ <types>
+ <xsd:schema>
+ <xsd:import namespace="http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy" schemaLocation="SecurityService_schema1.xsd"/>
+ </xsd:schema>
+ </types>
+ <message name="sayHello">
+ <part name="parameters" element="tns:sayHello"/>
+ </message>
+ <message name="sayHelloResponse">
+ <part name="parameters" element="tns:sayHelloResponse"/>
+ </message>
+ <portType name="ServiceIface">
+ <operation name="sayHello">
+ <input message="tns:sayHello"/>
+ <output message="tns:sayHelloResponse"/>
+ </operation>
+ </portType>
+ <binding name="SecurityServicePortBinding" type="tns:ServiceIface">
+ <wsp:PolicyReference URI="#SecurityServiceUsernameUnsecureTransportPolicy"/>
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <operation name="sayHello">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ </binding>
+ <service name="SecurityService">
+ <port name="SecurityServicePort" binding="tns:SecurityServicePortBinding">
+ <soap:address location="http://@jboss.bind.address@:8080/jaxws-samples-wsse-username-unsecure-transport"/>
+ </port>
+ </service>
+
+ <wsp:Policy wsu:Id="SecurityServiceUsernameUnsecureTransportPolicy">
+ <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/securitypolicy/IncludeToken/AlwaysT...">
+ <wsp:Policy>
+ <sp:WssUsernameToken10/>
+ </wsp:Policy>
+ </sp:UsernameToken>
+ </wsp:Policy>
+ </sp:SupportingTokens>
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+
+</definitions>
Added: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/jaas/auth/WEB-INF/wsdl/SecurityService_schema1.xsd
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/jaas/auth/WEB-INF/wsdl/SecurityService_schema1.xsd (rev 0)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/jaas/auth/WEB-INF/wsdl/SecurityService_schema1.xsd 2011-05-26 12:17:47 UTC (rev 14436)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<xs:schema version="1.0" targetNamespace="http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy" xmlns:tns="http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:element name="sayHello" type="tns:sayHello"/>
+
+ <xs:element name="sayHelloResponse" type="tns:sayHelloResponse"/>
+
+ <xs:complexType name="sayHello">
+ <xs:sequence/>
+ </xs:complexType>
+
+ <xs:complexType name="sayHelloResponse">
+ <xs:sequence>
+ <xs:element name="return" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
+
13 years, 7 months
JBossWS SVN: r14435 - stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/security/authentication.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2011-05-26 08:16:19 -0400 (Thu, 26 May 2011)
New Revision: 14435
Added:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/security/authentication/SubjectCreatingPolicyInterceptor.java
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/security/authentication/SubjectCreator.java
Modified:
stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/security/authentication/SubjectCreatingInterceptor.java
Log:
[JBWS-3302] Adding UsernameToken processing interceptor for the policy-first scenario
Modified: stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/security/authentication/SubjectCreatingInterceptor.java
===================================================================
--- stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/security/authentication/SubjectCreatingInterceptor.java 2011-05-26 11:02:48 UTC (rev 14434)
+++ stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/security/authentication/SubjectCreatingInterceptor.java 2011-05-26 12:16:19 UTC (rev 14435)
@@ -21,25 +21,17 @@
*/
package org.jboss.wsf.stack.cxf.security.authentication;
-import java.security.Principal;
-import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
import javax.security.auth.Subject;
-import javax.security.auth.callback.CallbackHandler;
import org.apache.cxf.binding.soap.SoapMessage;
-import org.apache.cxf.common.security.SimplePrincipal;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.ws.security.wss4j.AbstractUsernameTokenAuthenticatingInterceptor;
-import org.jboss.logging.Logger;
-import org.jboss.security.auth.callback.CallbackHandlerPolicyContextHandler;
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.security.SecurityDomainContext;
-import org.jboss.wsf.stack.cxf.security.authentication.callback.UsernameTokenCallbackHandler;
import org.jboss.wsf.stack.cxf.security.nonce.NonceStore;
-import org.jboss.xb.binding.SimpleTypeBindings;
/**
* Interceptor which authenticates a current principal and populates Subject
@@ -50,19 +42,9 @@
*/
public class SubjectCreatingInterceptor extends AbstractUsernameTokenAuthenticatingInterceptor
{
- private static final Logger log = Logger.getLogger(SubjectCreatingInterceptor.class);
-
- private static final int TIMESTAMP_FRESHNESS_THRESHOLD = 300;
-
- private boolean propagateContext;
-
- private int timestampThreshold = TIMESTAMP_FRESHNESS_THRESHOLD;
-
- private NonceStore nonceStore;
-
- private boolean decodeNonce = true;
-
private ThreadLocal<SecurityDomainContext> sdc = new ThreadLocal<SecurityDomainContext>();
+
+ private SubjectCreator helper = new SubjectCreator();
public SubjectCreatingInterceptor()
{
@@ -94,99 +76,27 @@
@Override
public Subject createSubject(String name, String password, boolean isDigest, String nonce, String created)
{
- if (isDigest)
- {
- verifyUsernameToken(nonce, created);
- // It is not possible at the moment to figure out if the digest has been created
- // using the original nonce bytes or the bytes of the (Base64)-encoded nonce, some
- // legacy clients might use the (Base64)-encoded nonce bytes when creating a digest;
- // lets default to true and assume the nonce has been Base-64 encoded, given that
- // WSS4J client Base64-decodes the nonce before creating the digest
-
- CallbackHandler handler = new UsernameTokenCallbackHandler(nonce, created, decodeNonce);
- CallbackHandlerPolicyContextHandler.setCallbackHandler(handler);
- }
-
- // authenticate and populate Subject
-
-
- Principal principal = new SimplePrincipal(name);
- Subject subject = new Subject();
-
- SecurityDomainContext ctx = sdc.get();
- boolean TRACE = log.isTraceEnabled();
- if (TRACE)
- log.trace("About to authenticate, using security domain '" + ctx.getSecurityDomain() + "'");
-
- try
- {
- if (ctx.isValid(principal, password, subject) == false)
- {
- String msg = "Authentication failed, principal=" + principal.getName();
- log.error(msg);
- throw new SecurityException(msg);
- }
- }
- finally
- {
- if (isDigest)
- {
- // does not remove the TL entry completely but limits the potential
- // growth to a number of available threads in a container
- CallbackHandlerPolicyContextHandler.setCallbackHandler(null);
- }
- }
-
- if (TRACE)
- log.trace("Authenticated, principal=" + name);
-
- if (propagateContext)
- {
- ctx.pushSubjectContext(subject, principal, password);
- if (TRACE)
- log.trace("Security Context has been propagated");
- }
- return subject;
+ return helper.createSubject(sdc.get(), name, password, isDigest, nonce, created);
}
- private void verifyUsernameToken(String nonce, String created)
- {
- if (created != null)
- {
- Calendar cal = SimpleTypeBindings.unmarshalDateTime(created);
- Calendar ref = Calendar.getInstance();
- ref.add(Calendar.SECOND, -timestampThreshold);
- if (ref.after(cal))
- throw new SecurityException("Request rejected since a stale timestamp has been provided: " + created);
- }
-
- if (nonce != null && nonceStore != null)
- {
- if (nonceStore.hasNonce(nonce))
- throw new SecurityException(
- "Request rejected since a message with the same nonce has been recently received; nonce = " + nonce);
- nonceStore.putNonce(nonce);
- }
- }
-
public void setPropagateContext(boolean propagateContext)
{
- this.propagateContext = propagateContext;
+ this.helper.setPropagateContext(propagateContext);
}
public void setTimestampThreshold(int timestampThreshold)
{
- this.timestampThreshold = timestampThreshold;
+ this.helper.setTimestampThreshold(timestampThreshold);
}
public void setNonceStore(NonceStore nonceStore)
{
- this.nonceStore = nonceStore;
+ this.helper.setNonceStore(nonceStore);
}
public void setDecodeNonce(boolean decodeNonce)
{
- this.decodeNonce = decodeNonce;
+ this.helper.setDecodeNonce(decodeNonce);
}
}
Added: stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/security/authentication/SubjectCreatingPolicyInterceptor.java
===================================================================
--- stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/security/authentication/SubjectCreatingPolicyInterceptor.java (rev 0)
+++ stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/security/authentication/SubjectCreatingPolicyInterceptor.java 2011-05-26 12:16:19 UTC (rev 14435)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.wsf.stack.cxf.security.authentication;
+
+import javax.security.auth.Subject;
+
+import org.apache.cxf.common.security.UsernameToken;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.interceptor.security.AbstractUsernameTokenInInterceptor;
+import org.apache.cxf.message.Message;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.security.SecurityDomainContext;
+import org.jboss.wsf.stack.cxf.security.nonce.NonceStore;
+
+/**
+ * Interceptor which authenticates a current principal and populates Subject
+ * To be used for policy-first scenarios
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 26-May-2011
+ */
+public class SubjectCreatingPolicyInterceptor extends AbstractUsernameTokenInInterceptor
+{
+ private ThreadLocal<SecurityDomainContext> sdc = new ThreadLocal<SecurityDomainContext>();
+
+ private SubjectCreator helper = new SubjectCreator();
+
+ public SubjectCreatingPolicyInterceptor()
+ {
+ super();
+ helper.setPropagateContext(true);
+ }
+
+ @Override
+ public void handleMessage(Message msg) throws Fault {
+ Endpoint ep = msg.getExchange().get(Endpoint.class);
+ sdc.set(ep.getSecurityDomainContext());
+ try
+ {
+ super.handleMessage(msg);
+ }
+ finally
+ {
+ if (sdc != null)
+ {
+ sdc.remove();
+ }
+ }
+ }
+
+ @Override
+ protected Subject createSubject(UsernameToken token)
+ {
+ return helper.createSubject(sdc.get(), token.getName(), token.getPassword(), token.isHashed(), token.getNonce(),
+ token.getCreatedTime());
+ }
+
+ public void setPropagateContext(boolean propagateContext)
+ {
+ this.helper.setPropagateContext(propagateContext);
+ }
+
+ public void setTimestampThreshold(int timestampThreshold)
+ {
+ this.helper.setTimestampThreshold(timestampThreshold);
+ }
+
+ public void setNonceStore(NonceStore nonceStore)
+ {
+ this.helper.setNonceStore(nonceStore);
+ }
+
+ public void setDecodeNonce(boolean decodeNonce)
+ {
+ this.helper.setDecodeNonce(decodeNonce);
+ }
+
+}
Added: stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/security/authentication/SubjectCreator.java
===================================================================
--- stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/security/authentication/SubjectCreator.java (rev 0)
+++ stack/cxf/trunk/modules/server/src/main/java/org/jboss/wsf/stack/cxf/security/authentication/SubjectCreator.java 2011-05-26 12:16:19 UTC (rev 14435)
@@ -0,0 +1,156 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.wsf.stack.cxf.security.authentication;
+
+import java.security.Principal;
+import java.util.Calendar;
+
+import javax.security.auth.Subject;
+import javax.security.auth.callback.CallbackHandler;
+
+import org.apache.cxf.common.security.SimplePrincipal;
+import org.jboss.logging.Logger;
+import org.jboss.security.auth.callback.CallbackHandlerPolicyContextHandler;
+import org.jboss.wsf.spi.security.SecurityDomainContext;
+import org.jboss.wsf.stack.cxf.security.authentication.callback.UsernameTokenCallbackHandler;
+import org.jboss.wsf.stack.cxf.security.nonce.NonceStore;
+import org.jboss.xb.binding.SimpleTypeBindings;
+
+/**
+ * Creates Subject instances after having authenticated / authorized the provided
+ * user against the specified SecurityDomainContext.
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @author Sergey Beryozkin
+ *
+ */
+public class SubjectCreator
+{
+ private static final Logger log = Logger.getLogger(SubjectCreator.class);
+
+ private static final int TIMESTAMP_FRESHNESS_THRESHOLD = 300;
+
+ private boolean propagateContext;
+
+ private int timestampThreshold = TIMESTAMP_FRESHNESS_THRESHOLD;
+
+ private NonceStore nonceStore;
+
+ private boolean decodeNonce = true;
+
+ public Subject createSubject(SecurityDomainContext ctx, String name, String password, boolean isDigest, String nonce, String created)
+ {
+ if (isDigest)
+ {
+ verifyUsernameToken(nonce, created);
+ // It is not possible at the moment to figure out if the digest has been created
+ // using the original nonce bytes or the bytes of the (Base64)-encoded nonce, some
+ // legacy clients might use the (Base64)-encoded nonce bytes when creating a digest;
+ // lets default to true and assume the nonce has been Base-64 encoded, given that
+ // WSS4J client Base64-decodes the nonce before creating the digest
+
+ CallbackHandler handler = new UsernameTokenCallbackHandler(nonce, created, decodeNonce);
+ CallbackHandlerPolicyContextHandler.setCallbackHandler(handler);
+ }
+
+ // authenticate and populate Subject
+
+
+ Principal principal = new SimplePrincipal(name);
+ Subject subject = new Subject();
+
+ boolean TRACE = log.isTraceEnabled();
+ if (TRACE)
+ log.trace("About to authenticate, using security domain '" + ctx.getSecurityDomain() + "'");
+
+ try
+ {
+ if (ctx.isValid(principal, password, subject) == false)
+ {
+ String msg = "Authentication failed, principal=" + principal.getName();
+ log.error(msg);
+ throw new SecurityException(msg);
+ }
+ }
+ finally
+ {
+ if (isDigest)
+ {
+ // does not remove the TL entry completely but limits the potential
+ // growth to a number of available threads in a container
+ CallbackHandlerPolicyContextHandler.setCallbackHandler(null);
+ }
+ }
+
+ if (TRACE)
+ log.trace("Authenticated, principal=" + name);
+
+ if (propagateContext)
+ {
+ ctx.pushSubjectContext(subject, principal, password);
+ if (TRACE)
+ log.trace("Security Context has been propagated");
+ }
+ return subject;
+ }
+
+ private void verifyUsernameToken(String nonce, String created)
+ {
+ if (created != null)
+ {
+ Calendar cal = SimpleTypeBindings.unmarshalDateTime(created);
+ Calendar ref = Calendar.getInstance();
+ ref.add(Calendar.SECOND, -timestampThreshold);
+ if (ref.after(cal))
+ throw new SecurityException("Request rejected since a stale timestamp has been provided: " + created);
+ }
+
+ if (nonce != null && nonceStore != null)
+ {
+ if (nonceStore.hasNonce(nonce))
+ throw new SecurityException(
+ "Request rejected since a message with the same nonce has been recently received; nonce = " + nonce);
+ nonceStore.putNonce(nonce);
+ }
+ }
+
+ public void setPropagateContext(boolean propagateContext)
+ {
+ this.propagateContext = propagateContext;
+ }
+
+ public void setTimestampThreshold(int timestampThreshold)
+ {
+ this.timestampThreshold = timestampThreshold;
+ }
+
+ public void setNonceStore(NonceStore nonceStore)
+ {
+ this.nonceStore = nonceStore;
+ }
+
+ public void setDecodeNonce(boolean decodeNonce)
+ {
+ this.decodeNonce = decodeNonce;
+ }
+
+}
13 years, 7 months
JBossWS SVN: r14434 - stack/cxf/trunk/modules/resources/src/main/resources/modules/org/jboss/as/webservices/main.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2011-05-26 07:02:48 -0400 (Thu, 26 May 2011)
New Revision: 14434
Modified:
stack/cxf/trunk/modules/resources/src/main/resources/modules/org/jboss/as/webservices/main/module.xml
Log:
register org.jboss.as.webservices -> org.jboss.invocation dependency
Modified: stack/cxf/trunk/modules/resources/src/main/resources/modules/org/jboss/as/webservices/main/module.xml
===================================================================
--- stack/cxf/trunk/modules/resources/src/main/resources/modules/org/jboss/as/webservices/main/module.xml 2011-05-26 11:01:59 UTC (rev 14433)
+++ stack/cxf/trunk/modules/resources/src/main/resources/modules/org/jboss/as/webservices/main/module.xml 2011-05-26 11:02:48 UTC (rev 14434)
@@ -32,6 +32,7 @@
<module name="javax.api"/>
<module name="javax.jws.api"/>
<module name="javax.xml.ws.api"/>
+ <module name="org.jboss.invocation"/>
<module name="org.jboss.jandex"/>
<module name="org.jboss.metadata"/>
<module name="org.jboss.staxmapper"/>
13 years, 7 months
JBossWS SVN: r14433 - stack/native/trunk/modules/resources/src/main/resources/modules/org/jboss/as/webservices/main.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2011-05-26 07:01:59 -0400 (Thu, 26 May 2011)
New Revision: 14433
Modified:
stack/native/trunk/modules/resources/src/main/resources/modules/org/jboss/as/webservices/main/module.xml
Log:
restister org.jboss.as.webservices -> org.jboss.invocation dependency
Modified: stack/native/trunk/modules/resources/src/main/resources/modules/org/jboss/as/webservices/main/module.xml
===================================================================
--- stack/native/trunk/modules/resources/src/main/resources/modules/org/jboss/as/webservices/main/module.xml 2011-05-26 08:36:38 UTC (rev 14432)
+++ stack/native/trunk/modules/resources/src/main/resources/modules/org/jboss/as/webservices/main/module.xml 2011-05-26 11:01:59 UTC (rev 14433)
@@ -32,6 +32,7 @@
<module name="javax.api"/>
<module name="javax.jws.api"/>
<module name="javax.xml.ws.api"/>
+ <module name="org.jboss.invocation"/>
<module name="org.jboss.jandex"/>
<module name="org.jboss.metadata"/>
<module name="org.jboss.staxmapper"/>
13 years, 7 months
JBossWS SVN: r14432 - in stack/cxf/trunk/modules/testsuite/cxf-tests: src/test/resources/jaxws/samples/wsse/policy and 1 other directories.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2011-05-26 04:36:38 -0400 (Thu, 26 May 2011)
New Revision: 14432
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/sign-encrypt/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/sign/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/username-unsecure-transport/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/basic/username/
Removed:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/sign-encrypt/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/sign/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/username-unsecure-transport/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/username/
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml
Log:
Refactoring wsse policy tests to clean room for more advanced ones
Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml 2011-05-26 08:16:10 UTC (rev 14431)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml 2011-05-26 08:36:38 UTC (rev 14432)
@@ -220,17 +220,17 @@
<!-- jaxws-samples-wsse-policy-sign -->
<war
warfile="${tests.output.dir}/test-libs/jaxws-samples-wsse-policy-sign.war"
- webxml="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/sign/WEB-INF/web.xml">
+ webxml="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/basic/sign/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/jaxws/*.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/sign/WEB-INF">
+ <webinf dir="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/basic/sign/WEB-INF">
<include name="jaxws-endpoint-config.xml"/>
<include name="wsdl/*"/>
</webinf>
- <zipfileset dir="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/sign/WEB-INF" prefix="WEB-INF/classes">
+ <zipfileset dir="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/basic/sign/WEB-INF" prefix="WEB-INF/classes">
<include name="bob.jks" />
<include name="bob.properties" />
</zipfileset>
@@ -241,7 +241,7 @@
<!-- jaxws-samples-wsse-policy-sign-client -->
<jar destfile="${tests.output.dir}/test-libs/jaxws-samples-wsse-policy-sign-client.jar">
- <metainf dir="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/sign/META-INF">
+ <metainf dir="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/basic/sign/META-INF">
<include name="alice.properties" />
<include name="alice.jks" />
</metainf>
@@ -250,17 +250,17 @@
<!-- jaxws-samples-wsse-policy-sign-encrypt -->
<war
warfile="${tests.output.dir}/test-libs/jaxws-samples-wsse-policy-sign-encrypt.war"
- webxml="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/sign-encrypt/WEB-INF/web.xml">
+ webxml="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/basic/sign-encrypt/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/jaxws/*.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/sign-encrypt/WEB-INF">
+ <webinf dir="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/basic/sign-encrypt/WEB-INF">
<include name="jaxws-endpoint-config.xml"/>
<include name="wsdl/*"/>
</webinf>
- <zipfileset dir="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/sign-encrypt/WEB-INF" prefix="WEB-INF/classes">
+ <zipfileset dir="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/basic/sign-encrypt/WEB-INF" prefix="WEB-INF/classes">
<include name="bob.jks" />
<include name="bob.properties" />
</zipfileset>
@@ -271,7 +271,7 @@
<!-- 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/sign-encrypt/META-INF">
+ <metainf dir="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/basic/sign-encrypt/META-INF">
<include name="alice.properties" />
<include name="alice.jks" />
</metainf>
@@ -280,13 +280,13 @@
<!-- jaxws-samples-wsse-policy-username-unsecure-transport -->
<war
warfile="${tests.output.dir}/test-libs/jaxws-samples-wsse-policy-username-unsecure-transport.war"
- webxml="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/username-unsecure-transport/WEB-INF/web.xml">
+ 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/jaxws/*.class"/>
<include name="org/jboss/test/ws/jaxws/samples/wsse/policy/basic/ServerUsernamePasswordCallback.class"/>
</classes>
- <webinf dir="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/username-unsecure-transport/WEB-INF">
+ <webinf dir="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/basic/username-unsecure-transport/WEB-INF">
<include name="jaxws-endpoint-config.xml"/>
<include name="wsdl/*"/>
</webinf>
@@ -298,13 +298,13 @@
<!-- jaxws-samples-wsse-policy-username -->
<war
warfile="${tests.output.dir}/test-libs/jaxws-samples-wsse-policy-username.war"
- webxml="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/username/WEB-INF/web.xml">
+ webxml="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/basic/username/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/jaxws/*.class"/>
<include name="org/jboss/test/ws/jaxws/samples/wsse/policy/basic/ServerUsernamePasswordCallback.class"/>
</classes>
- <webinf dir="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/username/WEB-INF">
+ <webinf dir="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/basic/username/WEB-INF">
<include name="jaxws-endpoint-config.xml"/>
<include name="wsdl/*"/>
</webinf>
13 years, 7 months
JBossWS SVN: r14431 - in stack/cxf/trunk/modules/testsuite: cxf-tests/scripts and 6 other directories.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2011-05-26 04:16:10 -0400 (Thu, 26 May 2011)
New Revision: 14431
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/
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/ServerUsernamePasswordCallback.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/ServiceIface.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/ServiceImpl.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/SignEncryptTestCase.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/SignTestCase.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/UsernameOverTransportTestCase.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/UsernamePasswordCallback.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/UsernameTestCase.java
Removed:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/KeystorePasswordCallback.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/ServerUsernamePasswordCallback.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/ServiceIface.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/ServiceImpl.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/SignEncryptTestCase.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/SignTestCase.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/UsernameOverTransportTestCase.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/UsernamePasswordCallback.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/UsernameTestCase.java
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/sign-encrypt/WEB-INF/jaxws-endpoint-config.xml
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/sign-encrypt/WEB-INF/web.xml
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/sign/WEB-INF/jaxws-endpoint-config.xml
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/sign/WEB-INF/web.xml
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/username-unsecure-transport/WEB-INF/jaxws-endpoint-config.xml
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/username-unsecure-transport/WEB-INF/web.xml
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/username/WEB-INF/jaxws-endpoint-config.xml
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/username/WEB-INF/web.xml
stack/cxf/trunk/modules/testsuite/pom.xml
Log:
Refactoring wsse policy tests to clean room for more advanced ones
Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml 2011-05-26 00:06:41 UTC (rev 14430)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml 2011-05-26 08:16:10 UTC (rev 14431)
@@ -222,9 +222,9 @@
warfile="${tests.output.dir}/test-libs/jaxws-samples-wsse-policy-sign.war"
webxml="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/sign/WEB-INF/web.xml">
<classes dir="${tests.output.dir}/test-classes">
- <include name="org/jboss/test/ws/jaxws/samples/wsse/policy/Service*.class"/>
+ <include name="org/jboss/test/ws/jaxws/samples/wsse/policy/basic/Service*.class"/>
<include name="org/jboss/test/ws/jaxws/samples/wsse/policy/jaxws/*.class"/>
- <include name="org/jboss/test/ws/jaxws/samples/wsse/policy/KeystorePasswordCallback.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/sign/WEB-INF">
<include name="jaxws-endpoint-config.xml"/>
@@ -252,9 +252,9 @@
warfile="${tests.output.dir}/test-libs/jaxws-samples-wsse-policy-sign-encrypt.war"
webxml="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/sign-encrypt/WEB-INF/web.xml">
<classes dir="${tests.output.dir}/test-classes">
- <include name="org/jboss/test/ws/jaxws/samples/wsse/policy/Service*.class"/>
+ <include name="org/jboss/test/ws/jaxws/samples/wsse/policy/basic/Service*.class"/>
<include name="org/jboss/test/ws/jaxws/samples/wsse/policy/jaxws/*.class"/>
- <include name="org/jboss/test/ws/jaxws/samples/wsse/policy/KeystorePasswordCallback.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/sign-encrypt/WEB-INF">
<include name="jaxws-endpoint-config.xml"/>
@@ -282,9 +282,9 @@
warfile="${tests.output.dir}/test-libs/jaxws-samples-wsse-policy-username-unsecure-transport.war"
webxml="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/username-unsecure-transport/WEB-INF/web.xml">
<classes dir="${tests.output.dir}/test-classes">
- <include name="org/jboss/test/ws/jaxws/samples/wsse/policy/Service*.class"/>
+ <include name="org/jboss/test/ws/jaxws/samples/wsse/policy/basic/Service*.class"/>
<include name="org/jboss/test/ws/jaxws/samples/wsse/policy/jaxws/*.class"/>
- <include name="org/jboss/test/ws/jaxws/samples/wsse/policy/ServerUsernamePasswordCallback.class"/>
+ <include name="org/jboss/test/ws/jaxws/samples/wsse/policy/basic/ServerUsernamePasswordCallback.class"/>
</classes>
<webinf dir="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/username-unsecure-transport/WEB-INF">
<include name="jaxws-endpoint-config.xml"/>
@@ -300,9 +300,9 @@
warfile="${tests.output.dir}/test-libs/jaxws-samples-wsse-policy-username.war"
webxml="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/username/WEB-INF/web.xml">
<classes dir="${tests.output.dir}/test-classes">
- <include name="org/jboss/test/ws/jaxws/samples/wsse/policy/Service*.class"/>
+ <include name="org/jboss/test/ws/jaxws/samples/wsse/policy/basic/Service*.class"/>
<include name="org/jboss/test/ws/jaxws/samples/wsse/policy/jaxws/*.class"/>
- <include name="org/jboss/test/ws/jaxws/samples/wsse/policy/ServerUsernamePasswordCallback.class"/>
+ <include name="org/jboss/test/ws/jaxws/samples/wsse/policy/basic/ServerUsernamePasswordCallback.class"/>
</classes>
<webinf dir="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/username/WEB-INF">
<include name="jaxws-endpoint-config.xml"/>
Deleted: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/KeystorePasswordCallback.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/KeystorePasswordCallback.java 2011-05-26 00:06:41 UTC (rev 14430)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/KeystorePasswordCallback.java 2011-05-26 08:16:10 UTC (rev 14431)
@@ -1,70 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, 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;
-
-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");
- }
-
- /**
- * 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);
- }
-}
Deleted: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/ServerUsernamePasswordCallback.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/ServerUsernamePasswordCallback.java 2011-05-26 00:06:41 UTC (rev 14430)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/ServerUsernamePasswordCallback.java 2011-05-26 08:16:10 UTC (rev 14431)
@@ -1,40 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, 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;
-
-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 ServerUsernamePasswordCallback implements CallbackHandler
-{
- public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
- {
- WSPasswordCallback pc = (WSPasswordCallback)callbacks[0];
- //this CallbackHandler is meant for use with WSS4J 1.6, see http://ws.apache.org/wss4j/wss4j16.html
- if ("kermit".equals(pc.getIdentifier()))
- pc.setPassword("thefrog");
- }
-}
Deleted: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/ServiceIface.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/ServiceIface.java 2011-05-26 00:06:41 UTC (rev 14430)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/ServiceIface.java 2011-05-26 08:16:10 UTC (rev 14431)
@@ -1,35 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, 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;
-
-import javax.jws.WebMethod;
-import javax.jws.WebService;
-
-@WebService
-(
- targetNamespace = "http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy"
-)
-public interface ServiceIface
-{
- @WebMethod
- String sayHello();
-}
Deleted: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/ServiceImpl.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/ServiceImpl.java 2011-05-26 00:06:41 UTC (rev 14430)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/ServiceImpl.java 2011-05-26 08:16:10 UTC (rev 14431)
@@ -1,43 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, 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;
-
-import javax.jws.WebService;
-
-import org.jboss.ws.api.annotation.EndpointConfig;
-
-@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.ServiceIface"
-)
-@EndpointConfig(configFile = "WEB-INF/jaxws-endpoint-config.xml", configName = "Custom WS-Security Endpoint")
-public class ServiceImpl implements ServiceIface
-{
- public String sayHello()
- {
- return "Secure Hello World!";
- }
-}
Deleted: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/SignEncryptTestCase.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/SignEncryptTestCase.java 2011-05-26 00:06:41 UTC (rev 14430)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/SignEncryptTestCase.java 2011-05-26 08:16:10 UTC (rev 14431)
@@ -1,77 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, 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;
-
-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
- *
- * @author alessio.soldano(a)jboss.com
- * @since 29-Apr-2011
- */
-public final class SignEncryptTestCase extends JBossWSTest
-{
- private final String serviceURL = "http://" + getServerHost() + ":8080/jaxws-samples-wsse-policy-sign-encrypt";
-
- public static Test suite()
- {
- return new JBossWSCXFTestSetup(SignEncryptTestCase.class, "jaxws-samples-wsse-policy-sign-encrypt-client.jar jaxws-samples-wsse-policy-sign-encrypt.war");
- }
-
- public void test() 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);
- try
- {
- assertEquals("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)
- {
- ((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");
- }
-}
Deleted: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/SignTestCase.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/SignTestCase.java 2011-05-26 00:06:41 UTC (rev 14430)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/SignTestCase.java 2011-05-26 08:16:10 UTC (rev 14431)
@@ -1,68 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, 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;
-
-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-Security Policy sign test case
- *
- * @author alessio.soldano(a)jboss.com
- * @since 29-Apr-2011
- */
-public final class SignTestCase extends JBossWSTest
-{
- private final String serviceURL = "http://" + getServerHost() + ":8080/jaxws-samples-wsse-policy-sign";
-
- public static Test suite()
- {
- return new JBossWSCXFTestSetup(SignTestCase.class, "jaxws-samples-wsse-policy-sign-client.jar jaxws-samples-wsse-policy-sign.war");
- }
-
- public void test() 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);
- assertEquals("Secure Hello World!", proxy.sayHello());
- }
-
- private void setupWsse(ServiceIface 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"));
- //workaround CXF requiring this even if no encryption is configured
- ((BindingProvider)proxy).getRequestContext().put(SecurityConstants.ENCRYPT_PROPERTIES, Thread.currentThread().getContextClassLoader().getResource("META-INF/alice.properties"));
- }
-}
Deleted: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/UsernameOverTransportTestCase.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/UsernameOverTransportTestCase.java 2011-05-26 00:06:41 UTC (rev 14430)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/UsernameOverTransportTestCase.java 2011-05-26 08:16:10 UTC (rev 14431)
@@ -1,87 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, 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;
-
-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-Security Policy username test case (using secure transport)
- *
- * @author alessio.soldano(a)jboss.com
- * @since 29-Apr-2011
- */
-public final class UsernameOverTransportTestCase extends JBossWSTest
-{
- private final String serviceURL = "https://" + getServerHost() + ":8443/jaxws-samples-wsse-policy-username";
-
- public static Test suite()
- {
- System.setProperty("javax.net.ssl.trustStore", "/dati/truststore_abc");
- System.setProperty("javax.net.ssl.trustStorePassword", "changeit");
- System.setProperty("javax.net.ssl.trustStoreType", "jks");
- return new JBossWSCXFTestSetup(UsernameOverTransportTestCase.class, "jaxws-samples-wsse-policy-username.war");
- }
-
- public void test() 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, "kermit");
- assertEquals("Secure Hello World!", proxy.sayHello());
- }
-
- public void testWrongPassword() 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, "snoopy");
- try
- {
- proxy.sayHello();
- fail("User snoopy shouldn't be authenticated.");
- }
- catch (Exception e)
- {
- //OK
- }
- }
-
- private void setupWsse(ServiceIface proxy, String username)
- {
- ((BindingProvider)proxy).getRequestContext().put(SecurityConstants.USERNAME, username);
- ((BindingProvider)proxy).getRequestContext().put(SecurityConstants.CALLBACK_HANDLER, "org.jboss.test.ws.jaxws.samples.wsse.policy.UsernamePasswordCallback");
- }
-}
Deleted: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/UsernamePasswordCallback.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/UsernamePasswordCallback.java 2011-05-26 00:06:41 UTC (rev 14430)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/UsernamePasswordCallback.java 2011-05-26 08:16:10 UTC (rev 14431)
@@ -1,41 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, 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;
-
-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 UsernamePasswordCallback implements CallbackHandler
-{
- public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
- {
- WSPasswordCallback pc = (WSPasswordCallback)callbacks[0];
- if ("kermit".equals(pc.getIdentifier()))
- pc.setPassword("thefrog");
- else
- pc.setPassword("wrong password");
- }
-}
Deleted: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/UsernameTestCase.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/UsernameTestCase.java 2011-05-26 00:06:41 UTC (rev 14430)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/UsernameTestCase.java 2011-05-26 08:16:10 UTC (rev 14431)
@@ -1,84 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2011, 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;
-
-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-Security Policy username test case
- *
- * @author alessio.soldano(a)jboss.com
- * @since 29-Apr-2011
- */
-public final class UsernameTestCase extends JBossWSTest
-{
- private final String serviceURL = "http://" + getServerHost() + ":8080/jaxws-samples-wsse-policy-username-unsecure-transport";
-
- public static Test suite()
- {
- return new JBossWSCXFTestSetup(UsernameTestCase.class, "jaxws-samples-wsse-policy-username-unsecure-transport.war");
- }
-
- public void test() 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, "kermit");
- assertEquals("Secure Hello World!", proxy.sayHello());
- }
-
- public void testWrongPassword() 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, "snoopy");
- try
- {
- proxy.sayHello();
- fail("User snoopy shouldn't be authenticated.");
- }
- catch (Exception e)
- {
- //OK
- }
- }
-
- private void setupWsse(ServiceIface proxy, String username)
- {
- ((BindingProvider)proxy).getRequestContext().put(SecurityConstants.USERNAME, username);
- ((BindingProvider)proxy).getRequestContext().put(SecurityConstants.CALLBACK_HANDLER, "org.jboss.test.ws.jaxws.samples.wsse.policy.UsernamePasswordCallback");
- }
-}
Added: 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 (rev 0)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/KeystorePasswordCallback.java 2011-05-26 08:16:10 UTC (rev 14431)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.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");
+ }
+
+ /**
+ * 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/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/ServerUsernamePasswordCallback.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/ServerUsernamePasswordCallback.java (rev 0)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/ServerUsernamePasswordCallback.java 2011-05-26 08:16:10 UTC (rev 14431)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.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 ServerUsernamePasswordCallback implements CallbackHandler
+{
+ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
+ {
+ WSPasswordCallback pc = (WSPasswordCallback)callbacks[0];
+ //this CallbackHandler is meant for use with WSS4J 1.6, see http://ws.apache.org/wss4j/wss4j16.html
+ if ("kermit".equals(pc.getIdentifier()))
+ pc.setPassword("thefrog");
+ }
+}
Added: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/ServiceIface.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/ServiceIface.java (rev 0)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/ServiceIface.java 2011-05-26 08:16:10 UTC (rev 14431)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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 ServiceIface
+{
+ @WebMethod
+ String sayHello();
+}
Added: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/ServiceImpl.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/ServiceImpl.java (rev 0)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/ServiceImpl.java 2011-05-26 08:16:10 UTC (rev 14431)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.jboss.ws.api.annotation.EndpointConfig;
+
+@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"
+)
+@EndpointConfig(configFile = "WEB-INF/jaxws-endpoint-config.xml", configName = "Custom WS-Security Endpoint")
+public class ServiceImpl implements ServiceIface
+{
+ public String sayHello()
+ {
+ return "Secure Hello World!";
+ }
+}
Added: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/SignEncryptTestCase.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/SignEncryptTestCase.java (rev 0)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/SignEncryptTestCase.java 2011-05-26 08:16:10 UTC (rev 14431)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 29-Apr-2011
+ */
+public final class SignEncryptTestCase extends JBossWSTest
+{
+ private final String serviceURL = "http://" + getServerHost() + ":8080/jaxws-samples-wsse-policy-sign-encrypt";
+
+ public static Test suite()
+ {
+ return new JBossWSCXFTestSetup(SignEncryptTestCase.class, "jaxws-samples-wsse-policy-sign-encrypt-client.jar jaxws-samples-wsse-policy-sign-encrypt.war");
+ }
+
+ public void test() 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);
+ try
+ {
+ assertEquals("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)
+ {
+ ((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/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/SignTestCase.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/SignTestCase.java (rev 0)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/SignTestCase.java 2011-05-26 08:16:10 UTC (rev 14431)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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-Security Policy sign test case
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 29-Apr-2011
+ */
+public final class SignTestCase extends JBossWSTest
+{
+ private final String serviceURL = "http://" + getServerHost() + ":8080/jaxws-samples-wsse-policy-sign";
+
+ public static Test suite()
+ {
+ return new JBossWSCXFTestSetup(SignTestCase.class, "jaxws-samples-wsse-policy-sign-client.jar jaxws-samples-wsse-policy-sign.war");
+ }
+
+ public void test() 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);
+ assertEquals("Secure Hello World!", proxy.sayHello());
+ }
+
+ private void setupWsse(ServiceIface 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"));
+ //workaround CXF requiring this even if no encryption is configured
+ ((BindingProvider)proxy).getRequestContext().put(SecurityConstants.ENCRYPT_PROPERTIES, Thread.currentThread().getContextClassLoader().getResource("META-INF/alice.properties"));
+ }
+}
Added: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/UsernameOverTransportTestCase.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/UsernameOverTransportTestCase.java (rev 0)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/UsernameOverTransportTestCase.java 2011-05-26 08:16:10 UTC (rev 14431)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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-Security Policy username test case (using secure transport)
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 29-Apr-2011
+ */
+public final class UsernameOverTransportTestCase extends JBossWSTest
+{
+ private final String serviceURL = "https://" + getServerHost() + ":8443/jaxws-samples-wsse-policy-username";
+
+ public static Test suite()
+ {
+ System.setProperty("javax.net.ssl.trustStore", "/dati/truststore_abc");
+ System.setProperty("javax.net.ssl.trustStorePassword", "changeit");
+ System.setProperty("javax.net.ssl.trustStoreType", "jks");
+ return new JBossWSCXFTestSetup(UsernameOverTransportTestCase.class, "jaxws-samples-wsse-policy-username.war");
+ }
+
+ public void test() 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, "kermit");
+ assertEquals("Secure Hello World!", proxy.sayHello());
+ }
+
+ public void testWrongPassword() 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, "snoopy");
+ try
+ {
+ proxy.sayHello();
+ fail("User snoopy shouldn't be authenticated.");
+ }
+ catch (Exception e)
+ {
+ //OK
+ }
+ }
+
+ private void setupWsse(ServiceIface proxy, String username)
+ {
+ ((BindingProvider)proxy).getRequestContext().put(SecurityConstants.USERNAME, username);
+ ((BindingProvider)proxy).getRequestContext().put(SecurityConstants.CALLBACK_HANDLER, "org.jboss.test.ws.jaxws.samples.wsse.policy.basic.UsernamePasswordCallback");
+ }
+}
Added: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/UsernamePasswordCallback.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/UsernamePasswordCallback.java (rev 0)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/UsernamePasswordCallback.java 2011-05-26 08:16:10 UTC (rev 14431)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.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 UsernamePasswordCallback implements CallbackHandler
+{
+ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
+ {
+ WSPasswordCallback pc = (WSPasswordCallback)callbacks[0];
+ if ("kermit".equals(pc.getIdentifier()))
+ pc.setPassword("thefrog");
+ else
+ pc.setPassword("wrong password");
+ }
+}
Added: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/UsernameTestCase.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/UsernameTestCase.java (rev 0)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/basic/UsernameTestCase.java 2011-05-26 08:16:10 UTC (rev 14431)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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-Security Policy username test case
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 29-Apr-2011
+ */
+public final class UsernameTestCase extends JBossWSTest
+{
+ private final String serviceURL = "http://" + getServerHost() + ":8080/jaxws-samples-wsse-policy-username-unsecure-transport";
+
+ public static Test suite()
+ {
+ return new JBossWSCXFTestSetup(UsernameTestCase.class, "jaxws-samples-wsse-policy-username-unsecure-transport.war");
+ }
+
+ public void test() 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, "kermit");
+ assertEquals("Secure Hello World!", proxy.sayHello());
+ }
+
+ public void testWrongPassword() 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, "snoopy");
+ try
+ {
+ proxy.sayHello();
+ fail("User snoopy shouldn't be authenticated.");
+ }
+ catch (Exception e)
+ {
+ //OK
+ }
+ }
+
+ private void setupWsse(ServiceIface proxy, String username)
+ {
+ ((BindingProvider)proxy).getRequestContext().put(SecurityConstants.USERNAME, username);
+ ((BindingProvider)proxy).getRequestContext().put(SecurityConstants.CALLBACK_HANDLER, "org.jboss.test.ws.jaxws.samples.wsse.policy.basic.UsernamePasswordCallback");
+ }
+}
Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/sign/WEB-INF/jaxws-endpoint-config.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/sign/WEB-INF/jaxws-endpoint-config.xml 2011-05-26 00:06:41 UTC (rev 14430)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/sign/WEB-INF/jaxws-endpoint-config.xml 2011-05-26 08:16:10 UTC (rev 14431)
@@ -15,7 +15,7 @@
</property>
<property>
<property-name>ws-security.callback-handler</property-name>
- <property-value>org.jboss.test.ws.jaxws.samples.wsse.policy.KeystorePasswordCallback</property-value>
+ <property-value>org.jboss.test.ws.jaxws.samples.wsse.policy.basic.KeystorePasswordCallback</property-value>
</property>
</endpoint-config>
Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/sign/WEB-INF/web.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/sign/WEB-INF/web.xml 2011-05-26 00:06:41 UTC (rev 14430)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/sign/WEB-INF/web.xml 2011-05-26 08:16:10 UTC (rev 14431)
@@ -6,7 +6,7 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>TestService</servlet-name>
- <servlet-class>org.jboss.test.ws.jaxws.samples.wsse.policy.ServiceImpl</servlet-class>
+ <servlet-class>org.jboss.test.ws.jaxws.samples.wsse.policy.basic.ServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TestService</servlet-name>
Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/sign-encrypt/WEB-INF/jaxws-endpoint-config.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/sign-encrypt/WEB-INF/jaxws-endpoint-config.xml 2011-05-26 00:06:41 UTC (rev 14430)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/sign-encrypt/WEB-INF/jaxws-endpoint-config.xml 2011-05-26 08:16:10 UTC (rev 14431)
@@ -23,7 +23,7 @@
</property>
<property>
<property-name>ws-security.callback-handler</property-name>
- <property-value>org.jboss.test.ws.jaxws.samples.wsse.policy.KeystorePasswordCallback</property-value>
+ <property-value>org.jboss.test.ws.jaxws.samples.wsse.policy.basic.KeystorePasswordCallback</property-value>
</property>
</endpoint-config>
Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/sign-encrypt/WEB-INF/web.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/sign-encrypt/WEB-INF/web.xml 2011-05-26 00:06:41 UTC (rev 14430)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/sign-encrypt/WEB-INF/web.xml 2011-05-26 08:16:10 UTC (rev 14431)
@@ -6,7 +6,7 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>TestService</servlet-name>
- <servlet-class>org.jboss.test.ws.jaxws.samples.wsse.policy.ServiceImpl</servlet-class>
+ <servlet-class>org.jboss.test.ws.jaxws.samples.wsse.policy.basic.ServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TestService</servlet-name>
Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/username/WEB-INF/jaxws-endpoint-config.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/username/WEB-INF/jaxws-endpoint-config.xml 2011-05-26 00:06:41 UTC (rev 14430)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/username/WEB-INF/jaxws-endpoint-config.xml 2011-05-26 08:16:10 UTC (rev 14431)
@@ -7,7 +7,7 @@
<config-name>Custom WS-Security Endpoint</config-name>
<property>
<property-name>ws-security.callback-handler</property-name>
- <property-value>org.jboss.test.ws.jaxws.samples.wsse.policy.ServerUsernamePasswordCallback</property-value>
+ <property-value>org.jboss.test.ws.jaxws.samples.wsse.policy.basic.ServerUsernamePasswordCallback</property-value>
</property>
</endpoint-config>
Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/username/WEB-INF/web.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/username/WEB-INF/web.xml 2011-05-26 00:06:41 UTC (rev 14430)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/username/WEB-INF/web.xml 2011-05-26 08:16:10 UTC (rev 14431)
@@ -6,7 +6,7 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>TestService</servlet-name>
- <servlet-class>org.jboss.test.ws.jaxws.samples.wsse.policy.ServiceImpl</servlet-class>
+ <servlet-class>org.jboss.test.ws.jaxws.samples.wsse.policy.basic.ServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TestService</servlet-name>
Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/username-unsecure-transport/WEB-INF/jaxws-endpoint-config.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/username-unsecure-transport/WEB-INF/jaxws-endpoint-config.xml 2011-05-26 00:06:41 UTC (rev 14430)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/username-unsecure-transport/WEB-INF/jaxws-endpoint-config.xml 2011-05-26 08:16:10 UTC (rev 14431)
@@ -7,7 +7,7 @@
<config-name>Custom WS-Security Endpoint</config-name>
<property>
<property-name>ws-security.callback-handler</property-name>
- <property-value>org.jboss.test.ws.jaxws.samples.wsse.policy.ServerUsernamePasswordCallback</property-value>
+ <property-value>org.jboss.test.ws.jaxws.samples.wsse.policy.basic.ServerUsernamePasswordCallback</property-value>
</property>
</endpoint-config>
Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/username-unsecure-transport/WEB-INF/web.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/username-unsecure-transport/WEB-INF/web.xml 2011-05-26 00:06:41 UTC (rev 14430)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/username-unsecure-transport/WEB-INF/web.xml 2011-05-26 08:16:10 UTC (rev 14431)
@@ -6,7 +6,7 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>TestService</servlet-name>
- <servlet-class>org.jboss.test.ws.jaxws.samples.wsse.policy.ServiceImpl</servlet-class>
+ <servlet-class>org.jboss.test.ws.jaxws.samples.wsse.policy.basic.ServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TestService</servlet-name>
Modified: stack/cxf/trunk/modules/testsuite/pom.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/pom.xml 2011-05-26 00:06:41 UTC (rev 14430)
+++ stack/cxf/trunk/modules/testsuite/pom.xml 2011-05-26 08:16:10 UTC (rev 14431)
@@ -675,7 +675,7 @@
<excludes>
<!-- # UsernameTestCase requires trustore in jboss-web tomcat configuration-->
<exclude>org/jboss/test/ws/jaxws/samples/wssePolicy/UsernameTestCase.*</exclude>
- <exclude>org/jboss/test/ws/jaxws/samples/wsse/policy/UsernameOverTransportTestCase.*</exclude>
+ <exclude>org/jboss/test/ws/jaxws/samples/wsse/policy/basic/UsernameOverTransportTestCase.*</exclude>
<!--# [CXF-1519] Explicitly set the namespace of a WebFault-->
<exclude>org/jboss/test/ws/jaxws/jbws1904/**</exclude>
@@ -830,7 +830,7 @@
<excludes>
<!--# UsernameTestCase requires trustore in jboss-web tomcat configuration-->
<exclude>org/jboss/test/ws/jaxws/samples/wssePolicy/UsernameTestCase.*</exclude>
- <exclude>org/jboss/test/ws/jaxws/samples/wsse/policy/UsernameOverTransportTestCase.*</exclude>
+ <exclude>org/jboss/test/ws/jaxws/samples/wsse/policy/basic/UsernameOverTransportTestCase.*</exclude>
<!--# [CXF-1519] Explicitly set the namespace of a WebFault-->
<exclude>org/jboss/test/ws/jaxws/jbws1904/**</exclude>
@@ -947,7 +947,7 @@
<excludes>
<!--# UsernameTestCase requires trustore in jboss-web tomcat configuration-->
<exclude>org/jboss/test/ws/jaxws/samples/wssePolicy/UsernameTestCase.*</exclude>
- <exclude>org/jboss/test/ws/jaxws/samples/wsse/policy/UsernameOverTransportTestCase.*</exclude>
+ <exclude>org/jboss/test/ws/jaxws/samples/wsse/policy/basic/UsernameOverTransportTestCase.*</exclude>
<!--# [CXF-1519] Explicitly set the namespace of a WebFault-->
<exclude>org/jboss/test/ws/jaxws/jbws1904/**</exclude>
13 years, 7 months
JBossWS SVN: r14430 - thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11.
by jbossws-commits@lists.jboss.org
Author: bmaxwell
Date: 2011-05-25 20:06:41 -0400 (Wed, 25 May 2011)
New Revision: 14430
Modified:
thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java
Log:
[JBPAPP-6440] CXF-3544 ignore the build failed policy
Modified: thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java
===================================================================
--- thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java 2011-05-25 16:41:03 UTC (rev 14429)
+++ thirdparty/cxf/branches/cxf-2.2.6-patch-01_JBPAPP-6440/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/attachment/wsdl11/Wsdl11AttachmentPolicyProvider.java 2011-05-26 00:06:41 UTC (rev 14430)
@@ -23,6 +23,7 @@
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
+import java.util.logging.Logger;
import javax.wsdl.Definition;
import javax.wsdl.extensions.ExtensibilityElement;
@@ -30,6 +31,7 @@
import javax.xml.namespace.QName;
import org.apache.cxf.Bus;
+import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.common.util.StringUtils;
import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.service.model.AbstractDescriptionElement;
@@ -58,6 +60,7 @@
*/
public class Wsdl11AttachmentPolicyProvider extends AbstractPolicyProvider
implements PolicyProvider {
+ private static final Logger LOG = LogUtils.getL7dLogger(Wsdl11AttachmentPolicyProvider.class);
public Wsdl11AttachmentPolicyProvider() {
this(null);
@@ -179,10 +182,15 @@
if (PolicyConstants.isPolicyElem(e.getElementType())
&& !StringUtils.isEmpty(uri)) {
- Policy policy = builder.getPolicy(e.getElement());
- String fragement = "#" + uri;
- registry.register(fragement, policy);
- registry.register(di.getBaseURI() + fragement, policy);
+ try {
+ Policy policy = builder.getPolicy(e.getElement());
+ String fragement = "#" + uri;
+ registry.register(fragement, policy);
+ registry.register(di.getBaseURI() + fragement, policy);
+ } catch (Exception policyEx) {
+ //ignore the policy can not be built
+ LOG.warning("Failed to build the policy '" + uri + "':" + policyEx.getMessage());
+ }
}
}
}
13 years, 7 months
JBossWS SVN: r14429 - in stack/cxf/trunk/modules/testsuite: cxf-tests/scripts and 5 other directories.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2011-05-25 12:41:03 -0400 (Wed, 25 May 2011)
New Revision: 14429
Added:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/UsernameOverTransportTestCase.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/username-unsecure-transport/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/username-unsecure-transport/WEB-INF/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/username-unsecure-transport/WEB-INF/jaxws-endpoint-config.xml
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/username-unsecure-transport/WEB-INF/web.xml
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/username-unsecure-transport/WEB-INF/wsdl/
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/username-unsecure-transport/WEB-INF/wsdl/SecurityService.wsdl
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/username-unsecure-transport/WEB-INF/wsdl/SecurityService_schema1.xsd
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/UsernameTestCase.java
stack/cxf/trunk/modules/testsuite/pom.xml
Log:
Adding testcase for WS-SecurityPolicy w/ UsernameToken Profile and no transport level security
Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml 2011-05-25 12:05:58 UTC (rev 14428)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml 2011-05-25 16:41:03 UTC (rev 14429)
@@ -277,6 +277,24 @@
</metainf>
</jar>
+ <!-- jaxws-samples-wsse-policy-username-unsecure-transport -->
+ <war
+ warfile="${tests.output.dir}/test-libs/jaxws-samples-wsse-policy-username-unsecure-transport.war"
+ webxml="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/username-unsecure-transport/WEB-INF/web.xml">
+ <classes dir="${tests.output.dir}/test-classes">
+ <include name="org/jboss/test/ws/jaxws/samples/wsse/policy/Service*.class"/>
+ <include name="org/jboss/test/ws/jaxws/samples/wsse/policy/jaxws/*.class"/>
+ <include name="org/jboss/test/ws/jaxws/samples/wsse/policy/ServerUsernamePasswordCallback.class"/>
+ </classes>
+ <webinf dir="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/username-unsecure-transport/WEB-INF">
+ <include name="jaxws-endpoint-config.xml"/>
+ <include name="wsdl/*"/>
+ </webinf>
+ <manifest>
+ <attribute name="Dependencies" value="org.apache.ws.security"/>
+ </manifest>
+ </war>
+
<!-- jaxws-samples-wsse-policy-username -->
<war
warfile="${tests.output.dir}/test-libs/jaxws-samples-wsse-policy-username.war"
Added: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/UsernameOverTransportTestCase.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/UsernameOverTransportTestCase.java (rev 0)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/UsernameOverTransportTestCase.java 2011-05-25 16:41:03 UTC (rev 14429)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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;
+
+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-Security Policy username test case (using secure transport)
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 29-Apr-2011
+ */
+public final class UsernameOverTransportTestCase extends JBossWSTest
+{
+ private final String serviceURL = "https://" + getServerHost() + ":8443/jaxws-samples-wsse-policy-username";
+
+ public static Test suite()
+ {
+ System.setProperty("javax.net.ssl.trustStore", "/dati/truststore_abc");
+ System.setProperty("javax.net.ssl.trustStorePassword", "changeit");
+ System.setProperty("javax.net.ssl.trustStoreType", "jks");
+ return new JBossWSCXFTestSetup(UsernameOverTransportTestCase.class, "jaxws-samples-wsse-policy-username.war");
+ }
+
+ public void test() 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, "kermit");
+ assertEquals("Secure Hello World!", proxy.sayHello());
+ }
+
+ public void testWrongPassword() 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, "snoopy");
+ try
+ {
+ proxy.sayHello();
+ fail("User snoopy shouldn't be authenticated.");
+ }
+ catch (Exception e)
+ {
+ //OK
+ }
+ }
+
+ private void setupWsse(ServiceIface proxy, String username)
+ {
+ ((BindingProvider)proxy).getRequestContext().put(SecurityConstants.USERNAME, username);
+ ((BindingProvider)proxy).getRequestContext().put(SecurityConstants.CALLBACK_HANDLER, "org.jboss.test.ws.jaxws.samples.wsse.policy.UsernamePasswordCallback");
+ }
+}
Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/UsernameTestCase.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/UsernameTestCase.java 2011-05-25 12:05:58 UTC (rev 14428)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/UsernameTestCase.java 2011-05-25 16:41:03 UTC (rev 14429)
@@ -41,14 +41,11 @@
*/
public final class UsernameTestCase extends JBossWSTest
{
- private final String serviceURL = "https://" + getServerHost() + ":8443/jaxws-samples-wsse-policy-username";
+ private final String serviceURL = "http://" + getServerHost() + ":8080/jaxws-samples-wsse-policy-username-unsecure-transport";
public static Test suite()
{
- System.setProperty("javax.net.ssl.trustStore", "/dati/truststore_abc");
- System.setProperty("javax.net.ssl.trustStorePassword", "changeit");
- System.setProperty("javax.net.ssl.trustStoreType", "jks");
- return new JBossWSCXFTestSetup(UsernameTestCase.class, "jaxws-samples-wsse-policy-username.war");
+ return new JBossWSCXFTestSetup(UsernameTestCase.class, "jaxws-samples-wsse-policy-username-unsecure-transport.war");
}
public void test() throws Exception
Added: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/username-unsecure-transport/WEB-INF/jaxws-endpoint-config.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/username-unsecure-transport/WEB-INF/jaxws-endpoint-config.xml (rev 0)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/username-unsecure-transport/WEB-INF/jaxws-endpoint-config.xml 2011-05-25 16:41:03 UTC (rev 14429)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jaxws-config xmlns="urn:jboss:jbossws-jaxws-config:4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:javaee="http://java.sun.com/xml/ns/javaee"
+ xsi:schemaLocation="urn:jboss:jbossws-jaxws-config:4.0 schema/jbossws-jaxws-config_4_0.xsd">
+
+ <endpoint-config>
+ <config-name>Custom WS-Security Endpoint</config-name>
+ <property>
+ <property-name>ws-security.callback-handler</property-name>
+ <property-value>org.jboss.test.ws.jaxws.samples.wsse.policy.ServerUsernamePasswordCallback</property-value>
+ </property>
+ </endpoint-config>
+
+</jaxws-config>
\ No newline at end of file
Added: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/username-unsecure-transport/WEB-INF/web.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/username-unsecure-transport/WEB-INF/web.xml (rev 0)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/username-unsecure-transport/WEB-INF/web.xml 2011-05-25 16:41:03 UTC (rev 14429)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app
+ version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+ <servlet>
+ <servlet-name>TestService</servlet-name>
+ <servlet-class>org.jboss.test.ws.jaxws.samples.wsse.policy.ServiceImpl</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>TestService</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+</web-app>
Added: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/username-unsecure-transport/WEB-INF/wsdl/SecurityService.wsdl
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/username-unsecure-transport/WEB-INF/wsdl/SecurityService.wsdl (rev 0)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/username-unsecure-transport/WEB-INF/wsdl/SecurityService.wsdl 2011-05-25 16:41:03 UTC (rev 14429)
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<definitions targetNamespace="http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy" name="SecurityService"
+ xmlns:tns="http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:wsp="http://www.w3.org/ns/ws-policy"
+ xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utilit..."
+ xmlns:wsaws="http://www.w3.org/2005/08/addressing"
+ xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"
+ xmlns:wspp="http://java.sun.com/xml/ns/wsit/policy">
+ <types>
+ <xsd:schema>
+ <xsd:import namespace="http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy" schemaLocation="SecurityService_schema1.xsd"/>
+ </xsd:schema>
+ </types>
+ <message name="sayHello">
+ <part name="parameters" element="tns:sayHello"/>
+ </message>
+ <message name="sayHelloResponse">
+ <part name="parameters" element="tns:sayHelloResponse"/>
+ </message>
+ <portType name="ServiceIface">
+ <operation name="sayHello">
+ <input message="tns:sayHello"/>
+ <output message="tns:sayHelloResponse"/>
+ </operation>
+ </portType>
+ <binding name="SecurityServicePortBinding" type="tns:ServiceIface">
+ <wsp:PolicyReference URI="#SecurityServiceUsernameUnsecureTransportPolicy"/>
+ <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+ <operation name="sayHello">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ </binding>
+ <service name="SecurityService">
+ <port name="SecurityServicePort" binding="tns:SecurityServicePortBinding">
+ <soap:address location="http://@jboss.bind.address@:8080/jaxws-samples-wsse-username-unsecure-transport"/>
+ </port>
+ </service>
+
+ <wsp:Policy wsu:Id="SecurityServiceUsernameUnsecureTransportPolicy">
+ <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/securitypolicy/IncludeToken/AlwaysT...">
+ <wsp:Policy>
+ <sp:WssUsernameToken10/>
+ </wsp:Policy>
+ </sp:UsernameToken>
+ </wsp:Policy>
+ </sp:SupportingTokens>
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+
+</definitions>
Added: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/username-unsecure-transport/WEB-INF/wsdl/SecurityService_schema1.xsd
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/username-unsecure-transport/WEB-INF/wsdl/SecurityService_schema1.xsd (rev 0)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/username-unsecure-transport/WEB-INF/wsdl/SecurityService_schema1.xsd 2011-05-25 16:41:03 UTC (rev 14429)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<xs:schema version="1.0" targetNamespace="http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy" xmlns:tns="http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+ <xs:element name="sayHello" type="tns:sayHello"/>
+
+ <xs:element name="sayHelloResponse" type="tns:sayHelloResponse"/>
+
+ <xs:complexType name="sayHello">
+ <xs:sequence/>
+ </xs:complexType>
+
+ <xs:complexType name="sayHelloResponse">
+ <xs:sequence>
+ <xs:element name="return" type="xs:string" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
+
Modified: stack/cxf/trunk/modules/testsuite/pom.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/pom.xml 2011-05-25 12:05:58 UTC (rev 14428)
+++ stack/cxf/trunk/modules/testsuite/pom.xml 2011-05-25 16:41:03 UTC (rev 14429)
@@ -675,7 +675,7 @@
<excludes>
<!-- # UsernameTestCase requires trustore in jboss-web tomcat configuration-->
<exclude>org/jboss/test/ws/jaxws/samples/wssePolicy/UsernameTestCase.*</exclude>
- <exclude>org/jboss/test/ws/jaxws/samples/wsse/policy/UsernameTestCase.*</exclude>
+ <exclude>org/jboss/test/ws/jaxws/samples/wsse/policy/UsernameOverTransportTestCase.*</exclude>
<!--# [CXF-1519] Explicitly set the namespace of a WebFault-->
<exclude>org/jboss/test/ws/jaxws/jbws1904/**</exclude>
@@ -830,7 +830,7 @@
<excludes>
<!--# UsernameTestCase requires trustore in jboss-web tomcat configuration-->
<exclude>org/jboss/test/ws/jaxws/samples/wssePolicy/UsernameTestCase.*</exclude>
- <exclude>org/jboss/test/ws/jaxws/samples/wsse/policy/UsernameTestCase.*</exclude>
+ <exclude>org/jboss/test/ws/jaxws/samples/wsse/policy/UsernameOverTransportTestCase.*</exclude>
<!--# [CXF-1519] Explicitly set the namespace of a WebFault-->
<exclude>org/jboss/test/ws/jaxws/jbws1904/**</exclude>
@@ -947,7 +947,7 @@
<excludes>
<!--# UsernameTestCase requires trustore in jboss-web tomcat configuration-->
<exclude>org/jboss/test/ws/jaxws/samples/wssePolicy/UsernameTestCase.*</exclude>
- <exclude>org/jboss/test/ws/jaxws/samples/wsse/policy/UsernameTestCase.*</exclude>
+ <exclude>org/jboss/test/ws/jaxws/samples/wsse/policy/UsernameOverTransportTestCase.*</exclude>
<!--# [CXF-1519] Explicitly set the namespace of a WebFault-->
<exclude>org/jboss/test/ws/jaxws/jbws1904/**</exclude>
13 years, 7 months
JBossWS SVN: r14428 - stack/native/trunk/modules/testsuite.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2011-05-25 08:05:58 -0400 (Wed, 25 May 2011)
New Revision: 14428
Modified:
stack/native/trunk/modules/testsuite/pom.xml
Log:
enabling **/jaxws/evnentry/** tests
Modified: stack/native/trunk/modules/testsuite/pom.xml
===================================================================
--- stack/native/trunk/modules/testsuite/pom.xml 2011-05-25 09:46:26 UTC (rev 14427)
+++ stack/native/trunk/modules/testsuite/pom.xml 2011-05-25 12:05:58 UTC (rev 14428)
@@ -784,7 +784,6 @@
<!-- ////////////////////////// -->
<!-- AS7 integration regressions -->
- <exclude>org/jboss/test/ws/jaxws/enventry/**</exclude>
<exclude>org/jboss/test/ws/jaxws/samples/jaxbintros/JAXBIntroTestCase*</exclude>
<exclude>org/jboss/test/ws/jaxws/jbws771/**</exclude>
<exclude>org/jboss/test/ws/jaxws/jbws1422/**</exclude>
13 years, 7 months