[jboss-cvs] JBossAS SVN: r60858 - branches/Branch_4_2/server/src/main/org/jboss/ejb/plugins.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Feb 23 16:13:44 EST 2007


Author: anil.saldhana at jboss.com
Date: 2007-02-23 16:13:44 -0500 (Fri, 23 Feb 2007)
New Revision: 60858

Modified:
   branches/Branch_4_2/server/src/main/org/jboss/ejb/plugins/SecurityActions.java
Log:
JBAS-4149: peek run as identity at a particular depth

Modified: branches/Branch_4_2/server/src/main/org/jboss/ejb/plugins/SecurityActions.java
===================================================================
--- branches/Branch_4_2/server/src/main/org/jboss/ejb/plugins/SecurityActions.java	2007-02-23 21:12:45 UTC (rev 60857)
+++ branches/Branch_4_2/server/src/main/org/jboss/ejb/plugins/SecurityActions.java	2007-02-23 21:13:44 UTC (rev 60858)
@@ -38,6 +38,7 @@
 /** A collection of privileged actions for this package
  * @author Scott.Stark at jboss.org
  * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @author Anil.Saldhana at jboss.org
  * @version $Revison: $
  */
 class SecurityActions
@@ -133,7 +134,17 @@
          {
             return (RunAsIdentity)AccessController.doPrivileged(peekAction);
          }
+         
+         public RunAsIdentity peek(final int depth)
+         {
+            return (RunAsIdentity)AccessController.doPrivileged(new PrivilegedAction(){
 
+               public Object run()
+               { 
+                  return SecurityAssociation.peekRunAsIdentity(depth);
+               }});
+         }
+
          public void push(final RunAsIdentity id)
          {
             AccessController.doPrivileged(
@@ -160,6 +171,11 @@
          {
             return SecurityAssociation.peekRunAsIdentity();
          }
+         
+         public RunAsIdentity peek(int depth)
+         {
+            return SecurityAssociation.peekRunAsIdentity(depth);
+         }
 
          public void push(RunAsIdentity id)
          {
@@ -172,7 +188,9 @@
          }
       };
 
-      RunAsIdentity peek();
+      RunAsIdentity peek(); 
+      
+      RunAsIdentity peek(int depth);
 
       void push(RunAsIdentity id);
 
@@ -236,7 +254,7 @@
                else
                   throw new UndeclaredThrowableException(ex);
             }
-         }
+         } 
       };
 
       PolicyContextActions NON_PRIVILEGED = new PolicyContextActions()
@@ -245,11 +263,11 @@
             throws PolicyContextException
          {
             return (Subject) PolicyContext.getContext(SUBJECT_CONTEXT_KEY);
-         }
+         } 
       };
 
       Subject getContextSubject()
-         throws PolicyContextException;
+         throws PolicyContextException; 
    }
    
    static ClassLoader getContextClassLoader()
@@ -308,6 +326,18 @@
          return RunAsIdentityActions.PRIVILEGED.peek();
       }
    }
+   
+   static RunAsIdentity peekRunAsIdentity(int depth)
+   {
+      if(System.getSecurityManager() == null)
+      {
+         return RunAsIdentityActions.NON_PRIVILEGED.peek(depth);
+      }
+      else
+      {
+         return RunAsIdentityActions.PRIVILEGED.peek(depth);
+      }
+   }
 
    static void pushRunAsIdentity(RunAsIdentity principal)
    {




More information about the jboss-cvs-commits mailing list