Author: thomas.diesler(a)jboss.com
Date: 2007-01-21 12:53:05 -0500 (Sun, 21 Jan 2007)
New Revision: 2017
Added:
trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/context/TestEndpoint.java
trunk/jbossws-tests/src/main/resources/jaxws/context/WEB-INF/jboss-web.xml
trunk/jbossws-tests/src/main/resources/jaxws/context/WEB-INF/wsdl/TestEndpoint.wsdl
Removed:
trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/context/EndpointInterface.java
trunk/jbossws-tests/src/main/resources/jaxws/context/WEB-INF/wsdl/TestService.wsdl
Modified:
trunk/integration-jboss50/.classpath
trunk/integration-jboss50/src/main/java/org/jboss/ws/integration/jboss50/ServiceEndpointInvokerEJB3.java
trunk/jbossws-tests/ant-import/build-jars-jaxws.xml
trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/context/ContextEJBTestCase.java
trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/context/ContextJSETestCase.java
trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/context/EndpointEJB.java
trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/context/EndpointJSE.java
trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/webserviceref/SecureEndpointImpl.java
trunk/jbossws-tests/src/main/resources/jaxws/context/WEB-INF/web.xml
Log:
Implement WebServiceContext.getUserPrincipal(), isUserInRole()
Modified: trunk/integration-jboss50/.classpath
===================================================================
--- trunk/integration-jboss50/.classpath 2007-01-21 13:08:14 UTC (rev 2016)
+++ trunk/integration-jboss50/.classpath 2007-01-21 17:53:05 UTC (rev 2017)
@@ -29,7 +29,7 @@
<classpathentry kind="lib"
path="/build/thirdparty/xalan.jar"/>
<classpathentry kind="lib"
path="/build/thirdparty/xercesImpl.jar"/>
<classpathentry kind="lib"
path="/build/thirdparty/mail.jar"/>
+ <classpathentry kind="lib"
path="/build/thirdparty/jbosssx-client.jar"
sourcepath="/build/thirdparty/jbosssx-src.zip"/>
<classpathentry kind="con"
path="org.eclipse.jdt.USER_LIBRARY/jboss-5.0.x"/>
- <classpathentry kind="lib"
path="/build/thirdparty/jbosssx-client.jar"
sourcepath="/build/thirdparty/jbosssx-src.zip"/>
<classpathentry kind="output" path="output-eclipse"/>
</classpath>
Modified:
trunk/integration-jboss50/src/main/java/org/jboss/ws/integration/jboss50/ServiceEndpointInvokerEJB3.java
===================================================================
---
trunk/integration-jboss50/src/main/java/org/jboss/ws/integration/jboss50/ServiceEndpointInvokerEJB3.java 2007-01-21
13:08:14 UTC (rev 2016)
+++
trunk/integration-jboss50/src/main/java/org/jboss/ws/integration/jboss50/ServiceEndpointInvokerEJB3.java 2007-01-21
17:53:05 UTC (rev 2017)
@@ -24,20 +24,27 @@
// $Id$
import java.lang.reflect.Method;
+import java.security.Principal;
+import javax.ejb.EJBContext;
import javax.management.ObjectName;
import javax.xml.rpc.soap.SOAPFaultException;
+import javax.xml.ws.handler.MessageContext;
import org.jboss.aop.Dispatcher;
+import org.jboss.aop.MethodInfo;
import org.jboss.ejb3.BeanContext;
import org.jboss.ejb3.BeanContextLifecycleCallback;
+import org.jboss.ejb3.EJBContainerInvocation;
import org.jboss.ejb3.stateless.StatelessBeanContext;
import org.jboss.ejb3.stateless.StatelessContainer;
+import org.jboss.injection.lang.reflect.BeanProperty;
import org.jboss.logging.Logger;
import org.jboss.ws.WSException;
import org.jboss.ws.core.CommonMessageContext;
import org.jboss.ws.core.EndpointInvocation;
import org.jboss.ws.core.jaxrpc.handler.SOAPMessageContextJAXRPC;
+import org.jboss.ws.core.jaxws.WebServiceContextImpl;
import org.jboss.ws.core.jaxws.handler.SOAPMessageContextJAXWS;
import org.jboss.ws.core.server.AbstractServiceEndpointInvoker;
import org.jboss.ws.core.server.ServiceEndpointInfo;
@@ -113,23 +120,15 @@
StatelessContainer container =
(StatelessContainer)dispatcher.getRegistered(objectName.getCanonicalName());
Class beanClass = container.getBeanClass();
- SOAPMessageContextJAXWS jaxwsMessageContext = null;
- SOAPMessageContextJAXRPC jaxrpcMessageContext = null;
- CommonMessageContext msgContext =
MessageContextAssociation.peekMessageContext();
- if (msgContext instanceof SOAPMessageContextJAXRPC)
- {
- jaxrpcMessageContext = (SOAPMessageContextJAXRPC)msgContext;
- jaxwsMessageContext = new SOAPMessageContextJAXWS(msgContext);
- }
- else if (msgContext instanceof SOAPMessageContextJAXWS)
- {
- jaxwsMessageContext = (SOAPMessageContextJAXWS)msgContext;
- jaxrpcMessageContext = new SOAPMessageContextJAXRPC(msgContext);
- }
-
Method implMethod = getImplMethod(beanClass, seiMethod);
- BeanContextLifecycleCallback callback = new CallbackImpl(jaxrpcMessageContext,
jaxwsMessageContext);
- Object retObj = container.localInvoke(implMethod, args, null, callback);
+ MethodInfo info = container.getMethodInfo(implMethod);
+
+ EJBContainerInvocation<StatelessContainer, StatelessBeanContext> ejb3Inv =
new EJBContainerInvocation<StatelessContainer, StatelessBeanContext>(info);
+ ejb3Inv.setAdvisor(container);
+ ejb3Inv.setArguments(args);
+ ejb3Inv.setContextCallback(new CallbackImpl());
+
+ Object retObj = ejb3Inv.invokeNext();
epInv.setReturnValue(retObj);
}
@@ -150,24 +149,67 @@
private SOAPMessageContextJAXWS jaxwsMessageContext;
private SOAPMessageContextJAXRPC jaxrpcMessageContext;
- public CallbackImpl(SOAPMessageContextJAXRPC jaxrpcMessageContext,
SOAPMessageContextJAXWS jaxwsMessageContext)
+ public CallbackImpl()
{
- this.jaxwsMessageContext = jaxwsMessageContext;
- this.jaxrpcMessageContext = jaxrpcMessageContext;
+ CommonMessageContext msgContext =
MessageContextAssociation.peekMessageContext();
+ if (msgContext instanceof SOAPMessageContextJAXRPC)
+ {
+ jaxrpcMessageContext = (SOAPMessageContextJAXRPC)msgContext;
+ jaxwsMessageContext = new SOAPMessageContextJAXWS(msgContext);
+ }
+ else if (msgContext instanceof SOAPMessageContextJAXWS)
+ {
+ jaxwsMessageContext = (SOAPMessageContextJAXWS)msgContext;
+ jaxrpcMessageContext = new SOAPMessageContextJAXRPC(msgContext);
+ }
}
- public void attached(BeanContext ctx)
+ public void attached(BeanContext beanCtx)
{
- StatelessBeanContext sbc = (StatelessBeanContext)ctx;
+ StatelessBeanContext sbc = (StatelessBeanContext)beanCtx;
sbc.setMessageContextJAXRPC(jaxrpcMessageContext);
- sbc.setMessageContextJAXWS(jaxwsMessageContext);
+
+ BeanProperty beanProp = sbc.getWebServiceContextProperty();
+ if (beanProp != null)
+ {
+ EJBContext ejbCtx = beanCtx.getEJBContext();
+ beanProp.set(beanCtx.getInstance(), new
EJB3WebServiceContextImpl(jaxwsMessageContext, ejbCtx));
+ }
}
- public void released(BeanContext ctx)
+ public void released(BeanContext beanCtx)
{
- StatelessBeanContext sbc = (StatelessBeanContext)ctx;
+ StatelessBeanContext sbc = (StatelessBeanContext)beanCtx;
sbc.setMessageContextJAXRPC(null);
- sbc.setMessageContextJAXWS(null);
+
+ BeanProperty beanProp = sbc.getWebServiceContextProperty();
+ if (beanProp != null)
+ beanProp.set(beanCtx.getInstance(), null);
}
}
+
+ /** Delegate to EJBContext
+ */
+ class EJB3WebServiceContextImpl extends WebServiceContextImpl
+ {
+ private EJBContext ejbContext;
+
+ public EJB3WebServiceContextImpl(MessageContext messageContext, EJBContext
ejbContext)
+ {
+ super(messageContext);
+ this.ejbContext = ejbContext;
+ }
+
+ @Override
+ public Principal getUserPrincipal()
+ {
+ return ejbContext.getCallerPrincipal();
+ }
+
+ @Override
+ public boolean isUserInRole(String role)
+ {
+ return ejbContext.isCallerInRole(role);
+ }
+ }
}
Modified: trunk/jbossws-tests/ant-import/build-jars-jaxws.xml
===================================================================
--- trunk/jbossws-tests/ant-import/build-jars-jaxws.xml 2007-01-21 13:08:14 UTC (rev
2016)
+++ trunk/jbossws-tests/ant-import/build-jars-jaxws.xml 2007-01-21 17:53:05 UTC (rev
2017)
@@ -50,13 +50,14 @@
<war warfile="${tests.output.dir}/libs/jaxws-context.war"
webxml="${tests.output.dir}/resources/jaxws/context/WEB-INF/web.xml">
<classes dir="${tests.output.dir}/classes">
<include
name="org/jboss/test/ws/jaxws/context/EndpointJSE.class"/>
- <include
name="org/jboss/test/ws/jaxws/context/EndpointInterface.class"/>
</classes>
+ <webinf dir="${tests.output.dir}/resources/jaxws/context/WEB-INF">
+ <include name="jboss-web.xml"/>
+ </webinf>
</war>
<jar jarfile="${tests.output.dir}/libs/jaxws-context.jar">
<fileset dir="${tests.output.dir}/classes">
<include
name="org/jboss/test/ws/jaxws/context/EndpointEJB.class"/>
- <include
name="org/jboss/test/ws/jaxws/context/EndpointInterface.class"/>
</fileset>
</jar>
Modified:
trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/context/ContextEJBTestCase.java
===================================================================
---
trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/context/ContextEJBTestCase.java 2007-01-21
13:08:14 UTC (rev 2016)
+++
trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/context/ContextEJBTestCase.java 2007-01-21
17:53:05 UTC (rev 2017)
@@ -24,18 +24,16 @@
// $Id$
import java.io.File;
-import java.net.MalformedURLException;
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.jboss.test.ws.JBossWSTest;
import org.jboss.test.ws.JBossWSTestSetup;
-import org.jboss.ws.metadata.wsdl.WSDLDefinitions;
-import org.jboss.ws.tools.wsdl.WSDLDefinitionsFactory;
/**
* Test JAXWS WebServiceContext
@@ -45,35 +43,42 @@
*/
public class ContextEJBTestCase extends JBossWSTest
{
+ private static TestEndpoint port;
+
public static Test suite()
{
- return JBossWSTestSetup.newTestSetup(ContextEJBTestCase.class,
"jaxws-context.jar");
+ return JBossWSTestSetup.newTestSetup(ContextJSETestCase.class,
"jaxws-context.jar");
}
- public void testWSDLAccess() throws MalformedURLException
+ public void setUp() throws Exception
{
- URL wsdlURL = new URL("http://" + getServerHost() +
":8080/jaxws-context?wsdl");
- WSDLDefinitionsFactory factory = WSDLDefinitionsFactory.newInstance();
- WSDLDefinitions wsdlDefinitions = factory.parse(wsdlURL);
- assertNotNull(wsdlDefinitions);
+ if (port == null)
+ {
+ URL wsdlURL = new
File("resources/jaxws/context/WEB-INF/wsdl/TestEndpoint.wsdl").toURL();
+ QName qname = new QName("http://org.jboss.ws/jaxws/context",
"TestEndpointService");
+ Service service = Service.create(wsdlURL, qname);
+ port = (TestEndpoint)service.getPort(TestEndpoint.class);
+
+ BindingProvider bp = (BindingProvider)port;
+ bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY,
"kermit");
+ bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY,
"thefrog");
+ }
}
-
- public void testClientAccess() throws Exception
+
+ public void testGetWebContext() throws Exception
{
- URL wsdlURL = new
File("resources/jaxws/context/WEB-INF/wsdl/TestService.wsdl").toURL();
- QName qname = new QName("http://org.jboss.ws/jaxws/context",
"TestService");
- Service service = Service.create(wsdlURL, qname);
- EndpointInterface port =
(EndpointInterface)service.getPort(EndpointInterface.class);
-
- if (isTargetJBoss50() == false)
- {
- System.out.println("FIXME: [JBWS-1443] - getMessageContext Not
Implemented");
- return;
- }
-
- String helloWorld = "Hello world!";
- Object retObj = port.echo(helloWorld);
- assertEquals(helloWorld + "/" + helloWorld, retObj);
+ String retStr = port.testGetMessageContext();
+ assertEquals("pass", retStr);
}
-
+
+ public void testGetUserPrincipal() throws Exception
+ {
+ String retStr = port.testGetUserPrincipal();
+ assertEquals("kermit", retStr);
+ }
+
+ public void testIsUserInRole() throws Exception
+ {
+ assertTrue("kermit is my friend",
port.testIsUserInRole("friend"));
+ }
}
Modified:
trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/context/ContextJSETestCase.java
===================================================================
---
trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/context/ContextJSETestCase.java 2007-01-21
13:08:14 UTC (rev 2016)
+++
trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/context/ContextJSETestCase.java 2007-01-21
17:53:05 UTC (rev 2017)
@@ -24,18 +24,16 @@
// $Id$
import java.io.File;
-import java.net.MalformedURLException;
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.jboss.test.ws.JBossWSTest;
import org.jboss.test.ws.JBossWSTestSetup;
-import org.jboss.ws.metadata.wsdl.WSDLDefinitions;
-import org.jboss.ws.tools.wsdl.WSDLDefinitionsFactory;
/**
* Test JAXWS WebServiceContext
@@ -45,30 +43,42 @@
*/
public class ContextJSETestCase extends JBossWSTest
{
+ private static TestEndpoint port;
+
public static Test suite()
{
return JBossWSTestSetup.newTestSetup(ContextJSETestCase.class,
"jaxws-context.war");
}
- public void testWSDLAccess() throws MalformedURLException
+ public void setUp() throws Exception
{
-
- URL wsdlURL = new URL("http://" + getServerHost() +
":8080/jaxws-context?wsdl");
- WSDLDefinitionsFactory factory = WSDLDefinitionsFactory.newInstance();
- WSDLDefinitions wsdlDefinitions = factory.parse(wsdlURL);
- assertNotNull(wsdlDefinitions);
+ if (port == null)
+ {
+ URL wsdlURL = new
File("resources/jaxws/context/WEB-INF/wsdl/TestEndpoint.wsdl").toURL();
+ QName qname = new QName("http://org.jboss.ws/jaxws/context",
"TestEndpointService");
+ Service service = Service.create(wsdlURL, qname);
+ port = (TestEndpoint)service.getPort(TestEndpoint.class);
+
+ BindingProvider bp = (BindingProvider)port;
+ bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY,
"kermit");
+ bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY,
"thefrog");
+ }
}
-
- public void testClientAccess() throws Exception
+
+ public void testGetWebContext() throws Exception
{
- URL wsdlURL = new
File("resources/jaxws/context/WEB-INF/wsdl/TestService.wsdl").toURL();
- QName qname = new QName("http://org.jboss.ws/jaxws/context",
"TestService");
- Service service = Service.create(wsdlURL, qname);
- EndpointInterface port =
(EndpointInterface)service.getPort(EndpointInterface.class);
-
- String helloWorld = "Hello world!";
- Object retObj = port.echo(helloWorld);
- assertEquals(helloWorld, retObj);
+ String retStr = port.testGetMessageContext();
+ assertEquals("pass", retStr);
}
-
+
+ public void testGetUserPrincipal() throws Exception
+ {
+ String retStr = port.testGetUserPrincipal();
+ assertEquals("kermit", retStr);
+ }
+
+ public void testIsUserInRole() throws Exception
+ {
+ assertTrue("kermit is my friend",
port.testIsUserInRole("friend"));
+ }
}
Modified:
trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/context/EndpointEJB.java
===================================================================
---
trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/context/EndpointEJB.java 2007-01-21
13:08:14 UTC (rev 2016)
+++
trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/context/EndpointEJB.java 2007-01-21
17:53:05 UTC (rev 2017)
@@ -23,57 +23,50 @@
// $Id$
+import java.security.Principal;
+
import javax.annotation.Resource;
-import javax.ejb.SessionContext;
+import javax.annotation.security.RolesAllowed;
import javax.ejb.Stateless;
+import javax.jws.WebMethod;
import javax.jws.WebService;
-import javax.xml.soap.SOAPElement;
-import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPMessage;
+import javax.jws.soap.SOAPBinding;
+import javax.jws.soap.SOAPBinding.Style;
import javax.xml.ws.WebServiceContext;
-import javax.xml.ws.WebServiceException;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+import org.jboss.annotation.security.SecurityDomain;
import org.jboss.ws.annotation.WebContext;
-@WebService(endpointInterface =
"org.jboss.test.ws.jaxws.context.EndpointInterface", serviceName =
"TestService", targetNamespace = "http://org.jboss.ws/jaxws/context")
-@WebContext(contextRoot = "/jaxws-context", urlPattern = "/*")
+@WebService(name = "TestEndpoint", targetNamespace =
"http://org.jboss.ws/jaxws/context")
+@SOAPBinding(style = Style.RPC)
@Stateless
+
+@WebContext(contextRoot = "/jaxws-context", urlPattern = "/*",
authMethod = "BASIC", transportGuarantee = "NONE", secureWSDLAccess =
false)
+@SecurityDomain("JBossWS")
+@RolesAllowed("friend")
public class EndpointEJB
{
@Resource
WebServiceContext wsCtx;
- @Resource
- SessionContext ejbCtx;
-
- public String echo(String input)
+ @WebMethod
+ public String testGetMessageContext()
{
- try
- {
- String retValue = getValueJAXWS() + "/" + getValueJAXRPC();
- return retValue;
- }
- catch (SOAPException ex)
- {
- throw new WebServiceException(ex);
- }
+ SOAPMessageContext jaxwsContext = (SOAPMessageContext)wsCtx.getMessageContext();
+ return jaxwsContext != null ? "pass" : "fail";
}
- private String getValueJAXWS() throws SOAPException
+ @WebMethod
+ public String testGetUserPrincipal()
{
- javax.xml.ws.handler.soap.SOAPMessageContext jaxwsContext =
(javax.xml.ws.handler.soap.SOAPMessageContext)wsCtx.getMessageContext();
- SOAPMessage soapMessage = jaxwsContext.getMessage();
- SOAPElement soapElement =
(SOAPElement)soapMessage.getSOAPBody().getChildElements().next();
- soapElement = (SOAPElement)soapElement.getChildElements().next();
- return soapElement.getValue();
+ Principal principal = wsCtx.getUserPrincipal();
+ return principal.getName();
}
- private String getValueJAXRPC() throws SOAPException
+ @WebMethod
+ public boolean testIsUserInRole(String role)
{
- javax.xml.rpc.handler.soap.SOAPMessageContext jaxrpcContext =
(javax.xml.rpc.handler.soap.SOAPMessageContext)ejbCtx.getMessageContext();
- SOAPMessage soapMessage = jaxrpcContext.getMessage();
- SOAPElement soapElement =
(SOAPElement)soapMessage.getSOAPBody().getChildElements().next();
- soapElement = (SOAPElement)soapElement.getChildElements().next();
- return soapElement.getValue();
+ return wsCtx.isUserInRole(role);
}
}
Deleted:
trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/context/EndpointInterface.java
===================================================================
---
trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/context/EndpointInterface.java 2007-01-21
13:08:14 UTC (rev 2016)
+++
trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/context/EndpointInterface.java 2007-01-21
17:53:05 UTC (rev 2017)
@@ -1,35 +0,0 @@
-/*
- * 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.context;
-
-import java.rmi.Remote;
-import java.rmi.RemoteException;
-
-import javax.jws.WebService;
-import javax.jws.soap.SOAPBinding;
-
-@WebService(targetNamespace = "http://org.jboss.ws/jaxws/context")
-@SOAPBinding(style = SOAPBinding.Style.RPC)
-public interface EndpointInterface extends Remote
-{
- String echo(String input) throws RemoteException;
-}
Modified:
trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/context/EndpointJSE.java
===================================================================
---
trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/context/EndpointJSE.java 2007-01-21
13:08:14 UTC (rev 2016)
+++
trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/context/EndpointJSE.java 2007-01-21
17:53:05 UTC (rev 2017)
@@ -23,34 +23,40 @@
// $Id: $
+import java.security.Principal;
+
import javax.annotation.Resource;
+import javax.jws.WebMethod;
import javax.jws.WebService;
-import javax.xml.soap.SOAPElement;
-import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPMessage;
+import javax.jws.soap.SOAPBinding;
+import javax.jws.soap.SOAPBinding.Style;
import javax.xml.ws.WebServiceContext;
-import javax.xml.ws.WebServiceException;
import javax.xml.ws.handler.soap.SOAPMessageContext;
-@WebService(endpointInterface =
"org.jboss.test.ws.jaxws.context.EndpointInterface", serviceName =
"TestService", targetNamespace = "http://org.jboss.ws/jaxws/context")
+@WebService(name = "TestEndpoint", targetNamespace =
"http://org.jboss.ws/jaxws/context")
+@SOAPBinding(style = Style.RPC)
public class EndpointJSE
{
@Resource
WebServiceContext wsCtx;
- public String echo(String input)
+ @WebMethod
+ public String testGetMessageContext()
{
- try
- {
- SOAPMessageContext msgContext = (SOAPMessageContext)wsCtx.getMessageContext();
- SOAPMessage soapMessage = msgContext.getMessage();
- SOAPElement soapElement =
(SOAPElement)soapMessage.getSOAPBody().getChildElements().next();
- soapElement = (SOAPElement)soapElement.getChildElements().next();
- return soapElement.getValue();
- }
- catch (SOAPException ex)
- {
- throw new WebServiceException(ex);
- }
+ SOAPMessageContext jaxwsContext = (SOAPMessageContext)wsCtx.getMessageContext();
+ return jaxwsContext != null ? "pass" : "fail";
}
+
+ @WebMethod
+ public String testGetUserPrincipal()
+ {
+ Principal principal = wsCtx.getUserPrincipal();
+ return principal.getName();
+ }
+
+ @WebMethod
+ public boolean testIsUserInRole(String role)
+ {
+ return wsCtx.isUserInRole(role);
+ }
}
Added:
trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/context/TestEndpoint.java
===================================================================
--- trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/context/TestEndpoint.java
(rev 0)
+++
trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/context/TestEndpoint.java 2007-01-21
17:53:05 UTC (rev 2017)
@@ -0,0 +1,53 @@
+
+package org.jboss.test.ws.jaxws.context;
+
+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;
+
+
+/**
+ * This class was generated by the JAXWS SI.
+ * JAX-WS RI 2.0-b26-ea3
+ * Generated source version: 2.0
+ *
+ */
+@WebService(name = "TestEndpoint", targetNamespace =
"http://org.jboss.ws/jaxws/context")
+@SOAPBinding(style = Style.RPC)
+public interface TestEndpoint {
+
+
+ /**
+ *
+ * @return
+ * returns java.lang.String
+ */
+ @WebMethod
+ @WebResult(targetNamespace = "http://org.jboss.ws/jaxws/context", partName
= "return")
+ public String testGetMessageContext();
+
+ /**
+ *
+ * @return
+ * returns java.lang.String
+ */
+ @WebMethod
+ @WebResult(targetNamespace = "http://org.jboss.ws/jaxws/context", partName
= "return")
+ public String testGetUserPrincipal();
+
+ /**
+ *
+ * @param arg0
+ * @return
+ * returns boolean
+ */
+ @WebMethod
+ @WebResult(targetNamespace = "http://org.jboss.ws/jaxws/context", partName
= "return")
+ public boolean testIsUserInRole(
+ @WebParam(name = "arg0", partName = "arg0")
+ String arg0);
+
+}
Property changes on:
trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/context/TestEndpoint.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/webserviceref/SecureEndpointImpl.java
===================================================================
---
trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/webserviceref/SecureEndpointImpl.java 2007-01-21
13:08:14 UTC (rev 2016)
+++
trunk/jbossws-tests/src/main/java/org/jboss/test/ws/jaxws/webserviceref/SecureEndpointImpl.java 2007-01-21
17:53:05 UTC (rev 2017)
@@ -35,10 +35,10 @@
@WebService(name = "SecureEndpoint", targetNamespace =
"http://org.jboss.ws/wsref")
@Stateless(name = "SecureEndpoint")
@SOAPBinding(style = Style.RPC)
-@RolesAllowed("friend")
@WebContext(authMethod = "BASIC", transportGuarantee = "NONE",
secureWSDLAccess = false)
@SecurityDomain("JBossWS")
+@RolesAllowed("friend")
public class SecureEndpointImpl
{
// Provide logging
Added: trunk/jbossws-tests/src/main/resources/jaxws/context/WEB-INF/jboss-web.xml
===================================================================
--- trunk/jbossws-tests/src/main/resources/jaxws/context/WEB-INF/jboss-web.xml
(rev 0)
+++ trunk/jbossws-tests/src/main/resources/jaxws/context/WEB-INF/jboss-web.xml 2007-01-21
17:53:05 UTC (rev 2017)
@@ -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>JBossWS</security-domain>
+</jboss-web>
\ No newline at end of file
Property changes on:
trunk/jbossws-tests/src/main/resources/jaxws/context/WEB-INF/jboss-web.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: trunk/jbossws-tests/src/main/resources/jaxws/context/WEB-INF/web.xml
===================================================================
--- trunk/jbossws-tests/src/main/resources/jaxws/context/WEB-INF/web.xml 2007-01-21
13:08:14 UTC (rev 2016)
+++ trunk/jbossws-tests/src/main/resources/jaxws/context/WEB-INF/web.xml 2007-01-21
17:53:05 UTC (rev 2017)
@@ -1,19 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
-<web-app
xmlns="http://java.sun.com/xml/ns/j2ee"
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
- version="2.4">
-
+<web-app
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
+
<servlet>
<servlet-name>TestService</servlet-name>
<servlet-class>org.jboss.test.ws.jaxws.context.EndpointJSE</servlet-class>
</servlet>
-
+
<servlet-mapping>
<servlet-name>TestService</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
-
+
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>TestService</web-resource-name>
+ <url-pattern>/*</url-pattern>
+ <http-method>POST</http-method>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>friend</role-name>
+ </auth-constraint>
+ <user-data-constraint>
+ <transport-guarantee>NONE</transport-guarantee>
+ </user-data-constraint>
+ </security-constraint>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ <realm-name>Security Realm</realm-name>
+ </login-config>
+ <security-role>
+ <role-name>friend</role-name>
+ </security-role>
+
</web-app>
Added:
trunk/jbossws-tests/src/main/resources/jaxws/context/WEB-INF/wsdl/TestEndpoint.wsdl
===================================================================
--- trunk/jbossws-tests/src/main/resources/jaxws/context/WEB-INF/wsdl/TestEndpoint.wsdl
(rev 0)
+++
trunk/jbossws-tests/src/main/resources/jaxws/context/WEB-INF/wsdl/TestEndpoint.wsdl 2007-01-21
17:53:05 UTC (rev 2017)
@@ -0,0 +1,66 @@
+<definitions name='TestEndpointService'
targetNamespace='http://org.jboss.ws/jaxws/context'
xmlns='http://schemas.xmlsoap.org/wsdl/'
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:tns='http://org.jboss.ws/jaxws/context'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
+ <types></types>
+ <message name='TestEndpoint_testIsUserInRole'>
+ <part name='arg0' type='xsd:string'/>
+ </message>
+ <message name='TestEndpoint_testGetMessageContext'></message>
+ <message name='TestEndpoint_testGetUserPrincipal'></message>
+ <message name='TestEndpoint_testGetUserPrincipalResponse'>
+ <part name='return' type='xsd:string'/>
+ </message>
+ <message name='TestEndpoint_testGetMessageContextResponse'>
+ <part name='return' type='xsd:string'/>
+ </message>
+ <message name='TestEndpoint_testIsUserInRoleResponse'>
+ <part name='return' type='xsd:boolean'/>
+ </message>
+ <portType name='TestEndpoint'>
+ <operation name='testGetMessageContext'>
+ <input message='tns:TestEndpoint_testGetMessageContext'/>
+ <output message='tns:TestEndpoint_testGetMessageContextResponse'/>
+ </operation>
+ <operation name='testGetUserPrincipal'>
+ <input message='tns:TestEndpoint_testGetUserPrincipal'/>
+ <output message='tns:TestEndpoint_testGetUserPrincipalResponse'/>
+ </operation>
+ <operation name='testIsUserInRole' parameterOrder='arg0'>
+ <input message='tns:TestEndpoint_testIsUserInRole'/>
+ <output message='tns:TestEndpoint_testIsUserInRoleResponse'/>
+ </operation>
+ </portType>
+ <binding name='TestEndpointBinding' type='tns:TestEndpoint'>
+ <soap:binding style='rpc'
transport='http://schemas.xmlsoap.org/soap/http'/>
+ <operation name='testGetMessageContext'>
+ <soap:operation soapAction=''/>
+ <input>
+ <soap:body namespace='http://org.jboss.ws/jaxws/context'
use='literal'/>
+ </input>
+ <output>
+ <soap:body namespace='http://org.jboss.ws/jaxws/context'
use='literal'/>
+ </output>
+ </operation>
+ <operation name='testGetUserPrincipal'>
+ <soap:operation soapAction=''/>
+ <input>
+ <soap:body namespace='http://org.jboss.ws/jaxws/context'
use='literal'/>
+ </input>
+ <output>
+ <soap:body namespace='http://org.jboss.ws/jaxws/context'
use='literal'/>
+ </output>
+ </operation>
+ <operation name='testIsUserInRole'>
+ <soap:operation soapAction=''/>
+ <input>
+ <soap:body namespace='http://org.jboss.ws/jaxws/context'
use='literal'/>
+ </input>
+ <output>
+ <soap:body namespace='http://org.jboss.ws/jaxws/context'
use='literal'/>
+ </output>
+ </operation>
+ </binding>
+ <service name='TestEndpointService'>
+ <port binding='tns:TestEndpointBinding' name='TestEndpointPort'>
+ <soap:address
location='http://@jbosstest.host.name@:8080/jaxws-context'/>
+ </port>
+ </service>
+</definitions>
\ No newline at end of file
Property changes on:
trunk/jbossws-tests/src/main/resources/jaxws/context/WEB-INF/wsdl/TestEndpoint.wsdl
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted:
trunk/jbossws-tests/src/main/resources/jaxws/context/WEB-INF/wsdl/TestService.wsdl
===================================================================
---
trunk/jbossws-tests/src/main/resources/jaxws/context/WEB-INF/wsdl/TestService.wsdl 2007-01-21
13:08:14 UTC (rev 2016)
+++
trunk/jbossws-tests/src/main/resources/jaxws/context/WEB-INF/wsdl/TestService.wsdl 2007-01-21
17:53:05 UTC (rev 2017)
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<definitions name="TestService"
targetNamespace="http://org.jboss.ws/jaxws/context"
xmlns:tns="http://org.jboss.ws/jaxws/context"
-
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
- <types/>
- <message name="EndpointInterface_echo">
- <part name="String_1" type="xsd:string"/>
- </message>
- <message name="EndpointInterface_echoResponse">
- <part name="result" type="xsd:string"/>
- </message>
- <portType name="EndpointInterface">
- <operation name="echo" parameterOrder="String_1">
- <input message="tns:EndpointInterface_echo"/>
- <output message="tns:EndpointInterface_echoResponse"/>
- </operation>
- </portType>
- <binding name="EndpointInterfaceBinding"
type="tns:EndpointInterface">
- <soap:binding
transport="http://schemas.xmlsoap.org/soap/http"
style="rpc"/>
- <operation name="echo">
- <soap:operation soapAction=""/>
- <input>
- <soap:body use="literal"
namespace="http://org.jboss.ws/jaxws/context"/>
- </input>
- <output>
- <soap:body use="literal"
namespace="http://org.jboss.ws/jaxws/context"/>
- </output>
- </operation>
- </binding>
- <service name="TestService">
- <port name="EndpointInterfacePort"
binding="tns:EndpointInterfaceBinding">
- <soap:address
location="http://@jbosstest.host.name@:8080/jaxws-context"/>
- </port>
- </service>
-</definitions>