[jbossws-commits] JBossWS SVN: r3769 - in branches/jbossws-2.0: jbossws-core/src/main/java/org/jboss/ws/core/server and 1 other directory.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Fri Jun 29 11:12:45 EDT 2007


Author: thomas.diesler at jboss.com
Date: 2007-06-29 11:12:44 -0400 (Fri, 29 Jun 2007)
New Revision: 3769

Added:
   branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/WebServiceContextDummy.java
Modified:
   branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/WebServiceContextJSE.java
   branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvoker.java
Log:
Add dummy WebServiceContext impl

Added: branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/WebServiceContextDummy.java
===================================================================
--- branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/WebServiceContextDummy.java	                        (rev 0)
+++ branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/WebServiceContextDummy.java	2007-06-29 15:12:44 UTC (rev 3769)
@@ -0,0 +1,62 @@
+/*
+ * 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.wsf.spi.invocation;
+
+// $Id: WebServiceContextJSE.java 3146 2007-05-18 22:55:26Z thomas.diesler at jboss.com $
+
+import java.security.Principal;
+
+import javax.xml.ws.handler.MessageContext;
+
+import org.jboss.logging.Logger;
+
+/**
+ * A WebServiceContext implementation that has no access to
+ * a security context.
+ *
+ * @author Thomas.Diesler at jboss.org
+ * @since 29-Jun-2007
+ */
+public class WebServiceContextDummy extends AbstractWebServiceContext
+{
+   // provide logging
+   private static final Logger log = Logger.getLogger(WebServiceContextDummy.class);
+   
+   public WebServiceContextDummy(MessageContext msgContext)
+   {
+      super(msgContext);
+   }
+
+   @Override
+   public Principal getUserPrincipal()
+   {
+      log.warn("No security context available");
+      return null;
+   }
+
+   @Override
+   public boolean isUserInRole(String role)
+   {
+      log.warn("No security context available");
+      return false;
+   }
+}

Modified: branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/WebServiceContextJSE.java
===================================================================
--- branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/WebServiceContextJSE.java	2007-06-29 14:53:18 UTC (rev 3768)
+++ branches/jbossws-2.0/integration/spi/src/main/java/org/jboss/wsf/spi/invocation/WebServiceContextJSE.java	2007-06-29 15:12:44 UTC (rev 3769)
@@ -38,10 +38,10 @@
 {
    private HttpServletRequest httpRequest;
 
-   public WebServiceContextJSE(MessageContext messageContext)
+   public WebServiceContextJSE(MessageContext msgContext)
    {
-      super(messageContext);
-      httpRequest = (HttpServletRequest)messageContext.get(MessageContext.SERVLET_REQUEST);
+      super(msgContext);
+      httpRequest = (HttpServletRequest)msgContext.get(MessageContext.SERVLET_REQUEST);
       if (httpRequest == null)
          throw new IllegalStateException("Cannot obtain HTTPServletRequest from message context");
    }

Modified: branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvoker.java
===================================================================
--- branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvoker.java	2007-06-29 14:53:18 UTC (rev 3768)
+++ branches/jbossws-2.0/jbossws-core/src/main/java/org/jboss/ws/core/server/ServiceEndpointInvoker.java	2007-06-29 15:12:44 UTC (rev 3769)
@@ -36,6 +36,7 @@
 import javax.xml.soap.SOAPException;
 import javax.xml.soap.SOAPHeader;
 import javax.xml.ws.WebServiceContext;
+import javax.xml.ws.handler.MessageContext;
 import javax.xml.ws.http.HTTPBinding;
 
 import org.jboss.logging.Logger;
@@ -65,9 +66,11 @@
 import org.jboss.ws.metadata.umdm.OperationMetaData;
 import org.jboss.ws.metadata.umdm.ServerEndpointMetaData;
 import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.deployment.Deployment.DeploymentType;
 import org.jboss.wsf.spi.invocation.Invocation;
 import org.jboss.wsf.spi.invocation.InvocationContext;
 import org.jboss.wsf.spi.invocation.InvocationHandler;
+import org.jboss.wsf.spi.invocation.WebServiceContextDummy;
 import org.jboss.wsf.spi.invocation.WebServiceContextJSE;
 import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerMetaData.HandlerType;
 import org.jboss.wsf.spi.utils.JavaUtils;
@@ -281,7 +284,19 @@
       CommonMessageContext msgContext = MessageContextAssociation.peekMessageContext();
       if (msgContext instanceof SOAPMessageContextJAXWS)
       {
-         invContext.addAttachment(WebServiceContext.class, new WebServiceContextJSE((SOAPMessageContextJAXWS)msgContext));
+         if (ep.getService().getDeployment().getType() == DeploymentType.JAXWS_JSE)
+         {
+            WebServiceContext wsContext;
+            if (msgContext.get(MessageContext.SERVLET_REQUEST) != null)
+            {
+               wsContext = new WebServiceContextJSE((SOAPMessageContextJAXWS)msgContext);
+            }
+            else
+            {
+               wsContext = new WebServiceContextDummy((SOAPMessageContextJAXWS)msgContext);
+            }
+            invContext.addAttachment(WebServiceContext.class, wsContext);
+         }
          invContext.addAttachment(javax.xml.ws.handler.MessageContext.class, msgContext);
       }
       if (msgContext instanceof SOAPMessageContextJAXRPC)




More information about the jbossws-commits mailing list