You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by st...@apache.org on 2011/03/22 13:55:31 UTC

svn commit: r1084153 - in /openwebbeans/trunk: webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/ webbeans-impl/src/main/java/org/apache/webbeans/config/ webbeans-impl/src/main/java/org/apache/webbeans/util/ webbeans-openejb/src/mai...

Author: struberg
Date: Tue Mar 22 12:55:31 2011
New Revision: 1084153

URL: http://svn.apache.org/viewvc?rev=1084153&view=rev
Log:
OWB-545 more SecurityUtil cleanup

Modified:
    openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SecurityUtil.java
    openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/EjbPlugin.java

Modified: openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java?rev=1084153&r1=1084152&r2=1084153&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java (original)
+++ openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/interceptor/OpenWebBeansEjbInterceptor.java Tue Mar 22 12:55:31 2011
@@ -64,7 +64,6 @@ import org.apache.webbeans.intercept.Inv
 import org.apache.webbeans.logger.WebBeansLogger;
 import org.apache.webbeans.proxy.JavassistProxyFactory;
 import org.apache.webbeans.spi.ContextsService;
-import org.apache.webbeans.util.SecurityUtil;
 import org.apache.webbeans.util.WebBeansUtil;
 
 /**
@@ -552,7 +551,7 @@ public class OpenWebBeansEjbInterceptor 
                 WebBeansDecoratorInterceptor lastInterceptor = new WebBeansDecoratorInterceptor(delegateHandler, instance);
                 decoratorInterceptorDataImpl = new InterceptorDataImpl(true, lastInterceptor, webBeansContext);
                 decoratorInterceptorDataImpl.setDefinedInInterceptorClass(true);
-                decoratorInterceptorDataImpl.setAroundInvoke(SecurityUtil.doPrivilegedGetDeclaredMethods(lastInterceptor.getClass())[0]);
+                decoratorInterceptorDataImpl.setAroundInvoke(webBeansContext.getSecurityService().doPrivilegedGetDeclaredMethods(lastInterceptor.getClass())[0]);
                 filteredInterceptorStack.add(decoratorInterceptorDataImpl);
             }
             

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java?rev=1084153&r1=1084152&r2=1084153&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java Tue Mar 22 12:55:31 2011
@@ -18,11 +18,12 @@
  */
 package org.apache.webbeans.config;
 
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.Properties;
 
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.logger.WebBeansLogger;
-import org.apache.webbeans.util.SecurityUtil;
 
 /**
  * Defines configuration for OpenWebBeans.
@@ -137,7 +138,7 @@ public class OpenWebBeansConfiguration
         Properties properties;
         if(System.getSecurityManager() != null)
         {
-            properties = SecurityUtil.doPrivilegedGetSystemProperties();
+            properties = doPrivilegedGetSystemProperties();
         }
         else
         {
@@ -196,6 +197,22 @@ public class OpenWebBeansConfiguration
         setPropertyFromSystemProperty(USE_BDA_BEANSXML_SCANNER, value);
 
     }
+
+    private Properties doPrivilegedGetSystemProperties()
+    {
+        return AccessController.doPrivileged(
+                new PrivilegedAction<Properties>()
+                    {
+                        @Override
+                        public Properties run()
+                        {
+                            return System.getProperties();
+                        }
+
+                    }
+                );
+    }
+
      
     private void setPropertyFromSystemProperty(String key, String value)
     {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SecurityUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SecurityUtil.java?rev=1084153&r1=1084152&r2=1084153&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SecurityUtil.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/SecurityUtil.java Tue Mar 22 12:55:31 2011
@@ -41,8 +41,6 @@ public class SecurityUtil
 
     private static final int METHOD_CLASS_GETDECLAREDFIELDS = 0x06;
     
-    private static final PrivilegedActionGetSystemProperties SYSTEM_PROPERTY_ACTION = new PrivilegedActionGetSystemProperties();
-
     public static <T> Method[] doPrivilegedGetDeclaredMethods(Class<T> clazz)
     {
         Object obj = AccessController.doPrivileged(
@@ -133,55 +131,13 @@ public class SecurityUtil
         Class<?> ret = (Class<?>)AccessController.doPrivileged(new PrivilegedActionForProxyFactory(factory));
         return ret;
     }
-    
-    public static String doPrivilegedGetSystemProperty(String propertyName, String defaultValue)
-    {
-        String value = AccessController.doPrivileged(new PrivilegedActionForProperty(propertyName, defaultValue));
-        
-        return value;
-    }
-    
+
     public static Object doPrivilegedObjectCreate(Class<?> clazz) throws PrivilegedActionException
     {
         return AccessController.doPrivileged(new PrivilegedActionForObjectCreation(clazz));
     }
 
-    public static Properties doPrivilegedGetSystemProperties()
-    {
-        return AccessController.doPrivileged(SYSTEM_PROPERTY_ACTION);
-    }
-
-    protected static class PrivilegedActionForProperty implements PrivilegedAction<String>
-    {
-        private final String propertyName;
-        
-        private final String defaultValue;
 
-        protected PrivilegedActionForProperty(String propertyName, String defaultValue)
-        {
-            this.propertyName = propertyName;
-            this.defaultValue = defaultValue;
-        }
-        
-        @Override
-        public String run()
-        {
-            return System.getProperty(this.propertyName,this.defaultValue);
-        }
-        
-    }
-    
-    protected static class PrivilegedActionGetSystemProperties implements PrivilegedAction<Properties>
-    {
-        
-        @Override
-        public Properties run()
-        {
-            return System.getProperties();
-        }
-        
-    }
-    
     protected static class PrivilegedActionForObjectCreation implements PrivilegedExceptionAction<Object>
     {
         private Class<?> clazz;

Modified: openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/EjbPlugin.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/EjbPlugin.java?rev=1084153&r1=1084152&r2=1084153&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/EjbPlugin.java (original)
+++ openwebbeans/trunk/webbeans-openejb/src/main/java/org/apache/webbeans/ejb/EjbPlugin.java Tue Mar 22 12:55:31 2011
@@ -49,6 +49,7 @@ import org.apache.openejb.core.stateful.
 import org.apache.openejb.core.stateless.StatelessContainer;
 import org.apache.openejb.loader.SystemInstance;
 import org.apache.openejb.spi.ContainerSystem;
+import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.ejb.common.util.EjbDefinitionUtility;
 import org.apache.webbeans.ejb.common.util.EjbUtility;
 import org.apache.webbeans.ejb.component.OpenEjbBean;
@@ -61,7 +62,6 @@ import org.apache.webbeans.spi.SecurityS
 import org.apache.webbeans.spi.TransactionService;
 import org.apache.webbeans.spi.plugins.AbstractOwbPlugin;
 import org.apache.webbeans.spi.plugins.OpenWebBeansEjbPlugin;
-import org.apache.webbeans.util.SecurityUtil;
 import org.apache.webbeans.util.WebBeansUtil;
 
 /**
@@ -107,6 +107,8 @@ public class EjbPlugin extends AbstractO
     /**JNDI Name strategy*/
     private final Map<String, JndiNameStrategy> nameStrategies = new TreeMap<String, JndiNameStrategy>();
 
+    private Boolean pluginInTest = null;
+
     // This is here for standalone tests are correctly run
     // Not used in anywhere
     private boolean useInTest = false;
@@ -376,7 +378,7 @@ public class EjbPlugin extends AbstractO
         
         for (DeploymentInfo deployment : deployments)
         {
-            boolean inTest = Boolean.valueOf(SecurityUtil.doPrivilegedGetSystemProperty("EjbPlugin.test", "false"));
+            boolean inTest = isInTest();
             classLoaderEquality = deployment.getBeanClass().getClassLoader().equals(WebBeansUtil.getCurrentClassLoader());
 
             // Yes, this EJB archive is deployed within this web
@@ -412,7 +414,22 @@ public class EjbPlugin extends AbstractO
 
         return classLoaderEquality;
     }
-    
+
+    /**
+     * TODO: only migrated this over from a static method to SecurityService.
+     * TODO: we should finally get rid of this property!
+     * @Deprecated
+     */
+    private boolean isInTest()
+    {
+        if (pluginInTest == null)
+        {
+            pluginInTest = Boolean.valueOf(WebBeansContext.currentInstance().getSecurityService().doPrivilegedGetSystemProperty("EjbPlugin.test", "false"));
+        }
+
+        return pluginInTest.booleanValue();
+    }
+
     /**
      * {@inheritDoc}
      */