FileDocCategorySizeDatePackage
RunAsSecurityInterceptor.javaAPI DocJBoss 4.2.13244Fri Jul 13 21:02:28 BST 2007org.jboss.aspects.security

RunAsSecurityInterceptor

public class RunAsSecurityInterceptor extends Object implements org.jboss.aop.advice.Interceptor
An interceptor that enforces the run-as identity declared by a bean.
author
Scott Stark.
author
Dain Sundstrom.
version
$Revision: 63638 $

Fields Summary
private static final Logger
log
protected org.jboss.security.AuthenticationManager
securityManager
protected org.jboss.security.RealmMapping
realmMapping
Constructors Summary
public RunAsSecurityInterceptor(org.jboss.security.AuthenticationManager manager, org.jboss.security.RealmMapping realmMapping)


       
   
      this.securityManager = manager;
      this.realmMapping = realmMapping;
   
Methods Summary
protected org.jboss.security.RunAsIdentitygetAnnotationRunAsIdentity(org.jboss.aop.joinpoint.Invocation invocation)

      RunAs runAs = (RunAs) invocation.resolveAnnotation(RunAs.class);
      if (runAs == null) return null;
      RunAsIdentity runAsRole = new RunAsIdentity(runAs.value(), null);
      return runAsRole;
   
public java.lang.StringgetName()

 return "RunAsSecurityInterceptor"; 
protected org.jboss.security.RunAsIdentitygetRunAsIdentity(org.jboss.aop.joinpoint.Invocation invocation)

      RunAsIdentity identity = (RunAsIdentity)invocation.getMetaData("security", "run-as");
      if (identity == null) identity = getAnnotationRunAsIdentity(invocation);
      return identity;
   
public java.lang.Objectinvoke(org.jboss.aop.joinpoint.Invocation invocation)

      RunAsIdentity runAsRole = getRunAsIdentity(invocation);
      // If a run-as role was specified, push it so that any calls made
      // by this bean will have the runAsRole available for declarative
      // security checks.
      if(runAsRole != null)
      {
         SecurityActions.pushRunAsIdentity(runAsRole);
      }
     
      try
      {
         return invocation.invokeNext();
      }
      finally
      {
         if(runAsRole != null)
         {
            SecurityActions.popRunAsIdentity();
         }
      }