Author: alessio.soldano(a)jboss.com
Date: 2008-06-04 12:04:01 -0400 (Wed, 04 Jun 2008)
New Revision: 7375
Added:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecureEndpoint.java
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecureEndpointAS5Impl.java
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecureEndpointImpl.java
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecurityDomainTestCase.java
Removed:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/jbws1840/
Modified:
framework/trunk/testsuite/test/ant-import/build-jars-jaxws.xml
framework/trunk/testsuite/test/ant-import/build-samples-jaxws.xml
Log:
[JBWS-2107] New sample using @SecurityDomain according to the container
Modified: framework/trunk/testsuite/test/ant-import/build-jars-jaxws.xml
===================================================================
--- framework/trunk/testsuite/test/ant-import/build-jars-jaxws.xml 2008-06-04 15:49:03 UTC
(rev 7374)
+++ framework/trunk/testsuite/test/ant-import/build-jars-jaxws.xml 2008-06-04 16:04:01 UTC
(rev 7375)
@@ -419,13 +419,6 @@
<fileset
file="${tests.output.dir}/test-libs/jaxws-jbws1822-two-ejb3-inside.jar"/>
</ear>
- <!-- jaxws-jbws1840 -->
- <jar destfile="${tests.output.dir}/test-libs/jaxws-jbws1840.jar">
- <fileset dir="${tests.output.dir}/test-classes">
- <include
name="org/jboss/test/ws/jaxws/jbws1840/SecureEndpointImpl.class"/>
- </fileset>
- </jar>
-
<!-- jaxws-jbws1841 -->
<jar destfile="${tests.output.dir}/test-libs/jaxws-jbws1841.jar">
<fileset dir="${tests.output.dir}/test-classes">
Modified: framework/trunk/testsuite/test/ant-import/build-samples-jaxws.xml
===================================================================
--- framework/trunk/testsuite/test/ant-import/build-samples-jaxws.xml 2008-06-04 15:49:03
UTC (rev 7374)
+++ framework/trunk/testsuite/test/ant-import/build-samples-jaxws.xml 2008-06-04 16:04:01
UTC (rev 7375)
@@ -203,6 +203,18 @@
<include name="wsdl/*"/>
</metainf>
</jar>
+
+ <!-- jaxws-samples-securityDomain -->
+ <jar
destfile="${tests.output.dir}/test-libs/jaxws-samples-securityDomain.jar">
+ <fileset dir="${tests.output.dir}/test-classes">
+ <include
name="org/jboss/test/ws/jaxws/samples/securityDomain/SecureEndpointImpl.class"/>
+ </fileset>
+ </jar>
+ <jar
destfile="${tests.output.dir}/test-libs/jaxws-samples-securityDomain-as5.jar">
+ <fileset dir="${tests.output.dir}/test-classes">
+ <include
name="org/jboss/test/ws/jaxws/samples/securityDomain/SecureEndpointAS5Impl.class"/>
+ </fileset>
+ </jar>
<!-- jaxws-samples-serviceref -->
<war
warfile="${tests.output.dir}/test-libs/jaxws-samples-serviceref.war"
webxml="${tests.output.dir}/test-resources/jaxws/samples/serviceref/WEB-INF/web.xml">
Added:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecureEndpoint.java
===================================================================
---
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecureEndpoint.java
(rev 0)
+++
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecureEndpoint.java 2008-06-04
16:04:01 UTC (rev 7375)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.securityDomain;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebResult;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+import javax.jws.soap.SOAPBinding.Style;
+
+@WebService(name = "SecureEndpoint", targetNamespace =
"http://org.jboss.ws/securityDomain")
+@SOAPBinding(style = Style.RPC)
+public interface SecureEndpoint
+{
+
+ @WebMethod
+ @WebResult(targetNamespace = "http://org.jboss.ws/securityDomain", partName
= "return")
+ public String echo(@WebParam(name = "arg0", partName = "arg0")
String arg0);
+
+}
Property changes on:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecureEndpoint.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecureEndpointAS5Impl.java
===================================================================
---
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecureEndpointAS5Impl.java
(rev 0)
+++
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecureEndpointAS5Impl.java 2008-06-04
16:04:01 UTC (rev 7375)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.securityDomain;
+
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.Stateless;
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+import javax.jws.soap.SOAPBinding.Style;
+
+import org.jboss.ejb3.annotation.SecurityDomain;
+import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.annotation.WebContext;
+
+@WebService(name = "SecureEndpoint", serviceName =
"SecureEndpointService", targetNamespace =
"http://org.jboss.ws/securityDomain")
+@Stateless(name = "SecureEndpoint")
+@SOAPBinding(style = Style.RPC)
+
+@WebContext(contextRoot="/jaxws-securityDomain", urlPattern="/*",
authMethod = "BASIC", transportGuarantee = "NONE", secureWSDLAccess =
false)
+@SecurityDomain("JBossWS")
+@RolesAllowed("friend")
+public class SecureEndpointAS5Impl
+{
+ // Provide logging
+ private static Logger log = Logger.getLogger(SecureEndpointAS5Impl.class);
+
+ @WebMethod
+ public String echo(String input)
+ {
+ log.info(input);
+ return input;
+ }
+}
Property changes on:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecureEndpointAS5Impl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecureEndpointImpl.java
===================================================================
---
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecureEndpointImpl.java
(rev 0)
+++
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecureEndpointImpl.java 2008-06-04
16:04:01 UTC (rev 7375)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.securityDomain;
+
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.Stateless;
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+import javax.jws.soap.SOAPBinding.Style;
+
+import org.jboss.annotation.security.SecurityDomain;
+import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.annotation.WebContext;
+
+@WebService(name = "SecureEndpoint", serviceName =
"SecureEndpointService", targetNamespace =
"http://org.jboss.ws/securityDomain")
+@Stateless(name = "SecureEndpoint")
+@SOAPBinding(style = Style.RPC)
+
+@WebContext(contextRoot="/jaxws-securityDomain", urlPattern="/*",
authMethod = "BASIC", transportGuarantee = "NONE", secureWSDLAccess =
false)
+@SecurityDomain("JBossWS")
+@RolesAllowed("friend")
+public class SecureEndpointImpl
+{
+ // Provide logging
+ private static Logger log = Logger.getLogger(SecureEndpointImpl.class);
+
+ @WebMethod
+ public String echo(String input)
+ {
+ log.info(input);
+ return input;
+ }
+}
Property changes on:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecureEndpointImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecurityDomainTestCase.java
===================================================================
---
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecurityDomainTestCase.java
(rev 0)
+++
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecurityDomainTestCase.java 2008-06-04
16:04:01 UTC (rev 7375)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.securityDomain;
+
+//$Id$
+
+import java.net.URL;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceException;
+
+import junit.framework.Test;
+
+import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestHelper;
+import org.jboss.wsf.test.JBossWSTestSetup;
+
+/**
+ * Secure endpoint using
+ *
+ * @SecurityDomain
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 04-Jun-2008
+ */
+public class SecurityDomainTestCase extends JBossWSTest
+{
+ public final String TARGET_ENDPOINT_ADDRESS = "http://" + getServerHost() +
":8080/jaxws-securityDomain";
+
+ public static Test suite()
+ {
+ return new JBossWSTestSetup(SecurityDomainTestCase.class, new
JBossWSTestHelper().isTargetJBoss50() ? "jaxws-samples-securityDomain-as5.jar" :
"jaxws-samples-securityDomain.jar");
+ }
+
+ private SecureEndpoint getPort() throws Exception
+ {
+ URL wsdlURL = new URL(TARGET_ENDPOINT_ADDRESS + "?wsdl");
+ QName serviceName = new QName("http://org.jboss.ws/securityDomain",
"SecureEndpointService");
+ SecureEndpoint port = Service.create(wsdlURL,
serviceName).getPort(SecureEndpoint.class);
+ return port;
+ }
+
+ public void testNegative() throws Exception
+ {
+ SecureEndpoint port = getPort();
+ try
+ {
+ port.echo("Hello");
+ fail("Expected: Invalid HTTP server response [401] - Unauthorized");
+ }
+ catch (WebServiceException ex)
+ {
+ // all good
+ }
+ }
+
+ public void testPositive() throws Exception
+ {
+ SecureEndpoint port = getPort();
+
+ Map<String, Object> reqContext =
((BindingProvider)port).getRequestContext();
+ reqContext.put(BindingProvider.USERNAME_PROPERTY, "kermit");
+ reqContext.put(BindingProvider.PASSWORD_PROPERTY, "thefrog");
+
+ String retObj = port.echo("Hello");
+ assertEquals("Hello", retObj);
+ }
+}
Property changes on:
framework/trunk/testsuite/test/java/org/jboss/test/ws/jaxws/samples/securityDomain/SecurityDomainTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF