[jboss-cvs] JBossCache/src/org/jboss/cache/aop/util ...
Brian Stansberry
brian.stansberry at jboss.com
Sun Aug 13 16:10:11 EDT 2006
User: bstansberry
Date: 06/08/13 16:10:11
Added: src/org/jboss/cache/aop/util Tag:
Branch_JBossCache_1_4_0_MUX SecurityActions.java
Log:
Update to 1.4.0.SP1
Revision Changes Path
No revision
No revision
1.1.4.2 +82 -0 JBossCache/src/org/jboss/cache/aop/util/Attic/SecurityActions.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: SecurityActions.java
===================================================================
RCS file: SecurityActions.java
diff -N SecurityActions.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ SecurityActions.java 13 Aug 2006 20:10:11 -0000 1.1.4.2
@@ -0,0 +1,82 @@
+/*
+* 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.cache.aop.util;
+
+import java.lang.reflect.AccessibleObject;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * Copied from aop module.
+ * @version $Revision: 1.1.4.2 $
+ */
+public 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);
+ }
+ };
+ }
+
+ public 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