Author: thomas.diesler(a)jboss.com
Date: 2007-10-09 10:51:00 -0400 (Tue, 09 Oct 2007)
New Revision: 4709
Added:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1840/
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1840/JBWS1840TestCase.java
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1840/SecureEndpoint.java
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1840/SecureEndpointImpl.java
stack/native/trunk/src/test/resources/jaxws/jbws1840/
Modified:
stack/native/trunk/ant-import-tests/build-jars-jaxws.xml
Log:
[JBWS-1840] Secure endpoint using @SecurityDomain
Modified: stack/native/trunk/ant-import-tests/build-jars-jaxws.xml
===================================================================
--- stack/native/trunk/ant-import-tests/build-jars-jaxws.xml 2007-10-09 13:42:41 UTC (rev
4708)
+++ stack/native/trunk/ant-import-tests/build-jars-jaxws.xml 2007-10-09 14:51:00 UTC (rev
4709)
@@ -380,6 +380,7 @@
</fileset>
</copy>
+ <!-- jaxws-jbws1799 -->
<jar destfile="${tests.output.dir}/libs/jaxws-jbws1799.jar">
<fileset dir="${tests.output.dir}/classes">
<include name="org/jboss/test/ws/jaxws/jbws1799/*.class"/>
@@ -387,6 +388,13 @@
</fileset>
</jar>
+ <!-- jaxws-jbws1840 -->
+ <jar destfile="${tests.output.dir}/libs/jaxws-jbws1840.jar">
+ <fileset dir="${tests.output.dir}/classes">
+ <include
name="org/jboss/test/ws/jaxws/jbws1840/SecureEndpointImpl.class"/>
+ </fileset>
+ </jar>
+
<!-- jaxws namespace -->
<war warfile="${tests.output.dir}/libs/jaxws-namespace.war"
webxml="${tests.output.dir}/resources/jaxws/namespace/WEB-INF/web.xml">
<classes dir="${tests.output.dir}/classes">
Added:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1840/JBWS1840TestCase.java
===================================================================
---
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1840/JBWS1840TestCase.java
(rev 0)
+++
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1840/JBWS1840TestCase.java 2007-10-09
14:51:00 UTC (rev 4709)
@@ -0,0 +1,89 @@
+/*
+ * 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.jbws1840;
+
+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.JBossWSTestSetup;
+
+/**
+ * Secure endpoint using @SecurityDomain
+ *
+ *
http://jira.jboss.org/jira/browse/JBWS-1840
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 09-Oct-2007
+ */
+public class JBWS1840TestCase extends JBossWSTest
+{
+ public final String TARGET_ENDPOINT_ADDRESS = "http://" + getServerHost() +
":8080/jaxws-jbws1840";
+
+ private static SecureEndpoint port;
+
+ public static Test suite()
+ {
+ return new JBossWSTestSetup(JBWS1840TestCase.class,
"jaxws-jbws1840.jar");
+ }
+
+ protected void setUp() throws Exception
+ {
+ if (port == null)
+ {
+ URL wsdlURL = new URL(TARGET_ENDPOINT_ADDRESS + "?wsdl");
+ QName serviceName = new QName("http://org.jboss.ws/jbws1840",
"SecureEndpointService");
+ port = Service.create(wsdlURL, serviceName).getPort(SecureEndpoint.class);
+ }
+ }
+
+ public void testNegative()
+ {
+ try
+ {
+ port.echo("Hello");
+ fail("Expected: Invalid HTTP server response [401] - Unauthorized");
+ }
+ catch (WebServiceException ex)
+ {
+ // all good
+ }
+ }
+
+ public void testPositive()
+ {
+ 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);
+
+ }
+}
Added:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1840/SecureEndpoint.java
===================================================================
--- stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1840/SecureEndpoint.java
(rev 0)
+++
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1840/SecureEndpoint.java 2007-10-09
14:51:00 UTC (rev 4709)
@@ -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.jbws1840;
+
+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/jbws1840")
+@SOAPBinding(style = Style.RPC)
+public interface SecureEndpoint
+{
+
+ @WebMethod
+ @WebResult(targetNamespace = "http://org.jboss.ws/jbws1840", partName =
"return")
+ public String echo(@WebParam(name = "arg0", partName = "arg0")
String arg0);
+
+}
Added:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1840/SecureEndpointImpl.java
===================================================================
---
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1840/SecureEndpointImpl.java
(rev 0)
+++
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1840/SecureEndpointImpl.java 2007-10-09
14:51:00 UTC (rev 4709)
@@ -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.jbws1840;
+
+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/jbws1840")
+@Stateless(name = "SecureEndpoint")
+@SOAPBinding(style = Style.RPC)
+
+@WebContext(contextRoot="/jaxws-jbws1840", 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;
+ }
+}