[jboss-cvs] JBossAS SVN: r57700 - projects/aop/trunk/aop/src/main/org/jboss/aop/proxy
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Oct 18 09:59:20 EDT 2006
Author: kabir.khan at jboss.com
Date: 2006-10-18 09:59:18 -0400 (Wed, 18 Oct 2006)
New Revision: 57700
Added:
projects/aop/trunk/aop/src/main/org/jboss/aop/proxy/SecurityActions.java
Modified:
projects/aop/trunk/aop/src/main/org/jboss/aop/proxy/ClassProxyFactory.java
projects/aop/trunk/aop/src/main/org/jboss/aop/proxy/ProxyFactory.java
Log:
Fix security exception in ClassProxyFactory.generateProxy()
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/proxy/ClassProxyFactory.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/proxy/ClassProxyFactory.java 2006-10-18 12:16:15 UTC (rev 57699)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/proxy/ClassProxyFactory.java 2006-10-18 13:59:18 UTC (rev 57700)
@@ -310,7 +310,7 @@
Class proxyClass = TransformerCommon.toClass(proxy);
Map methodmap = ClassProxyFactory.getMethodMap(proxyClass);
Field field = proxyClass.getDeclaredField("methodMap");
- field.setAccessible(true);
+ SecurityActions.setAccessible(field);
field.set(null, methodmap);
return proxyClass;
}
Modified: projects/aop/trunk/aop/src/main/org/jboss/aop/proxy/ProxyFactory.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/proxy/ProxyFactory.java 2006-10-18 12:16:15 UTC (rev 57699)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/proxy/ProxyFactory.java 2006-10-18 13:59:18 UTC (rev 57700)
@@ -120,7 +120,7 @@
Class clazz = TransformerCommon.toClass(proxy, loader);
Map methodmap = ClassProxyFactory.getMethodMap(clazz);
Field field = clazz.getDeclaredField("methodMap");
- setAccessible(field);
+ SecurityActions.setAccessible(field);
field.set(null, methodmap);
return clazz;
}
@@ -230,51 +230,4 @@
return proxy;
}
- interface SetAccessibleAction
- {
- void setAccessible(AccessibleObject accessibleObject);
-
- SetAccessibleAction PRIVILEGED = new SetAccessibleAction()
- {
- public void setAccessible(final AccessibleObject accessibleObject)
- {
- try
- {
- AccessController.doPrivileged(new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- accessibleObject.setAccessible(true);
- return null;
- }
- });
- }
- catch (PrivilegedActionException e)
- {
- throw new RuntimeException("Error setting " + accessibleObject + " as accessible ", e.getException());
- }
- }
- };
-
- SetAccessibleAction NON_PRIVILEGED = new SetAccessibleAction()
- {
- public void setAccessible(AccessibleObject accessibleObject)
- {
- accessibleObject.setAccessible(true);
- }
- };
- }
-
- static void setAccessible(AccessibleObject accessibleObject)
- {
- if (System.getSecurityManager() == null)
- {
- SetAccessibleAction.NON_PRIVILEGED.setAccessible(accessibleObject);
- }
- else
- {
- SetAccessibleAction.PRIVILEGED.setAccessible(accessibleObject);
- }
- }
-
}
Added: projects/aop/trunk/aop/src/main/org/jboss/aop/proxy/SecurityActions.java
===================================================================
--- projects/aop/trunk/aop/src/main/org/jboss/aop/proxy/SecurityActions.java 2006-10-18 12:16:15 UTC (rev 57699)
+++ projects/aop/trunk/aop/src/main/org/jboss/aop/proxy/SecurityActions.java 2006-10-18 13:59:18 UTC (rev 57700)
@@ -0,0 +1,85 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.aop.proxy;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+class SecurityActions
+{
+ interface SetAccessibleAction
+ {
+ void setAccessible(AccessibleObject accessibleObject);
+
+ SetAccessibleAction PRIVILEGED = new SetAccessibleAction()
+ {
+ public void setAccessible(final AccessibleObject accessibleObject)
+ {
+ try
+ {
+ AccessController.doPrivileged(new PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ accessibleObject.setAccessible(true);
+ return null;
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw new RuntimeException("Error setting " + accessibleObject + " as accessible ", e.getException());
+ }
+ }
+ };
+
+ SetAccessibleAction NON_PRIVILEGED = new SetAccessibleAction()
+ {
+ public void setAccessible(AccessibleObject accessibleObject)
+ {
+ accessibleObject.setAccessible(true);
+ }
+ };
+ }
+
+ static void setAccessible(AccessibleObject accessibleObject)
+ {
+ if (System.getSecurityManager() == null)
+ {
+ SetAccessibleAction.NON_PRIVILEGED.setAccessible(accessibleObject);
+ }
+ else
+ {
+ SetAccessibleAction.PRIVILEGED.setAccessible(accessibleObject);
+ }
+ }
+
+}
More information about the jboss-cvs-commits
mailing list