geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dwo...@apache.org
Subject svn commit: r937297 - in /geronimo/specs/trunk/geronimo-jcdi_1.0_spec: pom.xml src/main/java/javax/enterprise/util/AnnotationLiteral.java
Date Fri, 23 Apr 2010 13:47:45 GMT
Author: dwoods
Date: Fri Apr 23 13:47:44 2010
New Revision: 937297

URL: http://svn.apache.org/viewvc?rev=937297&view=rev
Log:
GERONIMO-5259 Annoying 'access denied' security exceptions for oenwebbeans while java2 security
is enabled.  Contributed by Ying Wang.  I also updated the pom.xml to use the specs that are
stagged for a vote right now, as newer snapshot are not needed at this time.

Modified:
    geronimo/specs/trunk/geronimo-jcdi_1.0_spec/pom.xml
    geronimo/specs/trunk/geronimo-jcdi_1.0_spec/src/main/java/javax/enterprise/util/AnnotationLiteral.java

Modified: geronimo/specs/trunk/geronimo-jcdi_1.0_spec/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jcdi_1.0_spec/pom.xml?rev=937297&r1=937296&r2=937297&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-jcdi_1.0_spec/pom.xml (original)
+++ geronimo/specs/trunk/geronimo-jcdi_1.0_spec/pom.xml Fri Apr 23 13:47:44 2010
@@ -72,25 +72,25 @@
         <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-interceptor_1.1_spec</artifactId>
-            <version>1.1-SNAPSHOT</version>
+            <version>1.0</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-el_2.2_spec</artifactId>
-            <version>1.1-SNAPSHOT</version>
+            <version>1.0</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-atinject_1.0_spec</artifactId>
-            <version>1.1-SNAPSHOT</version>
+            <version>1.0</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-annotation_1.1_spec</artifactId>
-            <version>1.1-SNAPSHOT</version>
+            <version>1.0</version>
             <scope>provided</scope>
         </dependency>
     </dependencies>

Modified: geronimo/specs/trunk/geronimo-jcdi_1.0_spec/src/main/java/javax/enterprise/util/AnnotationLiteral.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jcdi_1.0_spec/src/main/java/javax/enterprise/util/AnnotationLiteral.java?rev=937297&r1=937296&r2=937297&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-jcdi_1.0_spec/src/main/java/javax/enterprise/util/AnnotationLiteral.java
(original)
+++ geronimo/specs/trunk/geronimo-jcdi_1.0_spec/src/main/java/javax/enterprise/util/AnnotationLiteral.java
Fri Apr 23 13:47:44 2010
@@ -20,9 +20,12 @@ package javax.enterprise.util;
 
 import java.io.Serializable;
 import java.lang.annotation.Annotation;
+import java.lang.reflect.AccessibleObject;
 import java.lang.reflect.Method;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.Arrays;
 
 /**
@@ -97,7 +100,12 @@ public abstract class AnnotationLiteral<
     @Override
     public boolean equals(Object other)
     {
-        Method[] methods = this.annotationType.getDeclaredMethods();
+        Method[] methods = (Method[])AccessController.doPrivileged(new PrivilegedAction()
{
+            public Object run() 
+            {
+                return annotationType.getDeclaredMethods();
+            }
+        });
         
         if(other == this)
         {
@@ -213,7 +221,7 @@ public abstract class AnnotationLiteral<
         {
             if (!method.isAccessible())
             {
-                method.setAccessible(true);
+            	AccessController.doPrivileged(new PrivilegedActionForAccessibleObject(method,
true));
             }
 
             return method.invoke(instance, EMPTY_OBJECT_ARRAY);
@@ -224,16 +232,19 @@ public abstract class AnnotationLiteral<
         }
         finally
         {
-            method.setAccessible(access);
+            AccessController.doPrivileged(new PrivilegedActionForAccessibleObject(method,
access));
         }
-
-
     }
 
     @Override
     public int hashCode()
     {
-        Method[] methods = this.annotationType.getDeclaredMethods();
+        Method[] methods = (Method[])AccessController.doPrivileged(new PrivilegedAction()
{
+            public Object run() 
+            {
+                return annotationType.getDeclaredMethods();
+            }
+        });
 
         int hashCode = 0;
         for (Method method : methods)
@@ -301,8 +312,12 @@ public abstract class AnnotationLiteral<
     @Override
     public String toString()
     {
-        Method[] methods = this.annotationType.getDeclaredMethods();
-
+        Method[] methods = (Method[])AccessController.doPrivileged(new PrivilegedAction()
{
+            public Object run() 
+            {
+                return annotationType.getDeclaredMethods();
+            }
+        });
         StringBuilder sb = new StringBuilder("@" + annotationType().getName() + "(");
         int lenght = methods.length;
 
@@ -324,4 +339,24 @@ public abstract class AnnotationLiteral<
 
         return sb.toString();
     }
-}
\ No newline at end of file
+
+    protected static class PrivilegedActionForAccessibleObject implements PrivilegedAction<Object>

+    {
+        AccessibleObject object;
+        boolean flag;
+
+        protected PrivilegedActionForAccessibleObject(AccessibleObject object, boolean flag)

+        {
+            this.object = object;
+            this.flag = flag;
+        }
+
+        public Object run() 
+        {
+            object.setAccessible(flag);
+            return null;
+        }
+    }
+
+}
+



Mime
View raw message