[jboss-cvs] JBossAS SVN: r109538 - trunk/webservices/src/main/java/org/jboss/webservices/integration/invocation.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Nov 29 10:44:41 EST 2010


Author: richard.opalka at jboss.com
Date: 2010-11-29 10:44:37 -0500 (Mon, 29 Nov 2010)
New Revision: 109538

Modified:
   trunk/webservices/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerEJB3.java
Log:
[JBWS-3171] use CurrentEJBContext utility for EJB3 security staff

Modified: trunk/webservices/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerEJB3.java
===================================================================
--- trunk/webservices/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerEJB3.java	2010-11-29 14:37:10 UTC (rev 109537)
+++ trunk/webservices/src/main/java/org/jboss/webservices/integration/invocation/InvocationHandlerEJB3.java	2010-11-29 15:44:37 UTC (rev 109538)
@@ -22,13 +22,17 @@
 package org.jboss.webservices.integration.invocation;
 
 import java.lang.reflect.Method;
+import java.security.Principal;
 
 import javax.naming.Context;
 import javax.naming.NamingException;
+import javax.xml.ws.EndpointReference;
 import javax.xml.ws.WebServiceContext;
 import javax.xml.ws.WebServiceException;
+import javax.xml.ws.handler.MessageContext;
 
 import org.jboss.ejb3.EJBContainer;
+import org.jboss.ejb3.context.CurrentEJBContext;
 import org.jboss.webservices.integration.util.ASHelper;
 import org.jboss.wsf.common.injection.ThreadLocalAwareWebServiceContext;
 import org.jboss.wsf.common.invocation.AbstractInvocationHandler;
@@ -41,6 +45,7 @@
 import org.jboss.wsf.spi.invocation.integration.ServiceEndpointContainer;
 import org.jboss.wsf.spi.ioc.IoCContainerProxy;
 import org.jboss.wsf.spi.ioc.IoCContainerProxyFactory;
+import org.w3c.dom.Element;
 
 /**
  * Handles invocations on EJB3 endpoints.
@@ -139,14 +144,14 @@
       }
       finally
       {
-     	 this.onAfterInvocation(wsInvocation);
+         this.onAfterInvocation(wsInvocation);
       }
    }
 
    public Context getJNDIContext(final Endpoint ep) throws NamingException
    {
-      final EJBContainer ejb3Container = (EJBContainer)getEjb3Container();
-      return (Context)ejb3Container.getEnc().lookup(EJB3_JNDI_PREFIX);
+      final EJBContainer ejb3Container = (EJBContainer) getEjb3Container();
+      return (Context) ejb3Container.getEnc().lookup(EJB3_JNDI_PREFIX);
    }
 
    /**
@@ -182,9 +187,44 @@
    {
       final InvocationContext invocationContext = invocation.getInvocationContext();
 
-      return invocationContext.getAttachment(WebServiceContext.class);
+      return new WebServiceContextAdapter(invocationContext.getAttachment(WebServiceContext.class));
    }
 
+   private static final class WebServiceContextAdapter implements WebServiceContext
+   {
+      private final WebServiceContext delegate;
+
+      private WebServiceContextAdapter(final WebServiceContext delegate)
+      {
+         this.delegate = delegate;
+      }
+
+      public MessageContext getMessageContext()
+      {
+         return this.delegate.getMessageContext();
+      }
+
+      public Principal getUserPrincipal()
+      {
+         return CurrentEJBContext.get().getCallerPrincipal();
+      }
+
+      public boolean isUserInRole(final String role)
+      {
+         return CurrentEJBContext.get().isCallerInRole(role);
+      }
+
+      public EndpointReference getEndpointReference(final Element... referenceParameters)
+      {
+         return delegate.getEndpointReference(referenceParameters);
+      }
+
+      public <T extends EndpointReference> T getEndpointReference(final Class<T> clazz, final Element... referenceParameters)
+      {
+         return delegate.getEndpointReference(clazz, referenceParameters);
+      }
+   }
+
    /**
     * EJB3 invocation callback allowing EJB 3 beans to access Web Service invocation properties.
     */



More information about the jboss-cvs-commits mailing list