org.jboss.security
Class AbstractSecurityProxy

java.lang.Object
  extended byorg.jboss.security.AbstractSecurityProxy
All Implemented Interfaces:
SecurityProxy (src)
Direct Known Subclasses:
SubjectSecurityProxy (src)

public abstract class AbstractSecurityProxy
extends java.lang.Object
implements SecurityProxy (src)

An abstract implementation of SecurityProxy that wraps a non-SecurityProxy object. Subclasses of this class are used to create a SecurityProxy given a security delegate that implements methods in the EJB home or remote interface for security checks. This allows custom security classes to be written without using a JBoss specific interface. It also allows the security delegate to follow a natural proxy pattern implementation.


Field Summary
protected  java.lang.Object delegate
          The optional setContext delegate method
protected  boolean strict
          Flag which sets whether the method mapping will be performed in a strict fashion.
 
Method Summary
 void init(java.lang.Class beanHome, java.lang.Class beanRemote, java.lang.Class beanLocalHome, java.lang.Class beanLocal, java.lang.Object securityMgr)
          This method is called by the container SecurityInterceptor to intialize the proxy with the EJB home and remote interface classes that the container is housing.
 void init(java.lang.Class beanHome, java.lang.Class beanRemote, java.lang.Object securityMgr)
          This version invokes init(beanHome, beanRemote, null, null, securityMgr)
 void invoke(java.lang.reflect.Method m, java.lang.Object[] args, java.lang.Object bean)
          Called by the SecurityProxyInterceptor to allow the proxy delegate to perform a security check of the indicated remote interface method.
 void invokeHome(java.lang.reflect.Method m, java.lang.Object[] args)
          Called by the SecurityProxyInterceptor to allow the proxy delegate to perform a security check of the indicated home interface method.
protected abstract  void invokeHomeOnDelegate(java.lang.reflect.Method m, java.lang.Object[] args, java.lang.Object delegate)
          Subclasses implement this method to actually invoke the given home method on the proxy delegate.
protected abstract  void invokeOnDelegate(java.lang.reflect.Method m, java.lang.Object[] args, java.lang.Object delegate)
          Subclasses implement this method to actually invoke the given remote method on the proxy delegate.
protected  void mapHomeMethods(java.lang.Class beanHome)
          Performs a mapping from the methods declared in the beanHome class to the proxy delegate class.
protected  void mapRemoteMethods(java.lang.Class beanRemote)
          Performs a mapping from the methods declared in the beanRemote class to the proxy delegate class.
 void setEJBContext(EJBContext (src)  ctx)
          Called by the SecurityProxyInterceptor prior to a method invocation to set the context for the call.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

delegate

protected java.lang.Object delegate
The optional setContext delegate method


strict

protected boolean strict
Flag which sets whether the method mapping will be performed in a strict fashion. The proxy delegate must provide an implementation of all methods. If set to 'true', a security exception will be thrown during initialisation if a method is found for which the delegate doesn't have a matching method. This defaults to false and is obtained via reflection on the proxy delegate's 'boolean isStrict()' method.

Method Detail

invokeHomeOnDelegate

protected abstract void invokeHomeOnDelegate(java.lang.reflect.Method m,
                                             java.lang.Object[] args,
                                             java.lang.Object delegate)
                                      throws java.lang.Exception
Subclasses implement this method to actually invoke the given home method on the proxy delegate.

Throws:
java.lang.Exception
See Also:
invokeHome(Method, Object[])

invokeOnDelegate

protected abstract void invokeOnDelegate(java.lang.reflect.Method m,
                                         java.lang.Object[] args,
                                         java.lang.Object delegate)
                                  throws java.lang.Exception
Subclasses implement this method to actually invoke the given remote method on the proxy delegate.

Throws:
java.lang.Exception
See Also:
invoke(Method, Object[], Object)

init

public void init(java.lang.Class beanHome,
                 java.lang.Class beanRemote,
                 java.lang.Object securityMgr)
          throws java.lang.InstantiationException
This version invokes init(beanHome, beanRemote, null, null, securityMgr)

Specified by:
init in interface SecurityProxy (src)
Parameters:
beanHome - The EJB remote home interface class
beanRemote - The EJB remote interface class
securityMgr - The security manager from the security domain
Throws:
java.lang.InstantiationException
See Also:
init(Class, Class, Class, Class, Object)

init

public void init(java.lang.Class beanHome,
                 java.lang.Class beanRemote,
                 java.lang.Class beanLocalHome,
                 java.lang.Class beanLocal,
                 java.lang.Object securityMgr)
          throws java.lang.InstantiationException
This method is called by the container SecurityInterceptor to intialize the proxy with the EJB home and remote interface classes that the container is housing. This method creates a mapping from the home and remote classes to the proxy delegate instance. The mapping is based on method name and paramter types. In addition, the proxy delegate is inspected for a setEJBContext(EJBContext) and a setBean(Object) method so that the active EJBContext and EJB instance can be passed to the delegate prior to method invocations.

Specified by:
init in interface SecurityProxy (src)
Parameters:
beanHome - The EJB remote home interface class
beanRemote - The EJB remote interface class
beanLocalHome - The EJB local home interface class
beanLocal - The EJB local interface class
securityMgr - The security manager from the security domain
Throws:
java.lang.InstantiationException

setEJBContext

public void setEJBContext(EJBContext (src)  ctx)
Called by the SecurityProxyInterceptor prior to a method invocation to set the context for the call.

Specified by:
setEJBContext in interface SecurityProxy (src)
Parameters:
ctx - the bean's EJBContext

invokeHome

public void invokeHome(java.lang.reflect.Method m,
                       java.lang.Object[] args)
                throws java.lang.Exception
Called by the SecurityProxyInterceptor to allow the proxy delegate to perform a security check of the indicated home interface method.

Specified by:
invokeHome in interface SecurityProxy (src)
Parameters:
m - , the EJB home or local home interface method
args - , the invocation args
Throws:
java.lang.Exception

invoke

public void invoke(java.lang.reflect.Method m,
                   java.lang.Object[] args,
                   java.lang.Object bean)
            throws java.lang.Exception
Called by the SecurityProxyInterceptor to allow the proxy delegate to perform a security check of the indicated remote interface method.

Specified by:
invoke in interface SecurityProxy (src)
Parameters:
m - , the EJB remote or local interface method
args - , the invocation args
Throws:
java.lang.Exception

mapHomeMethods

protected void mapHomeMethods(java.lang.Class beanHome)
Performs a mapping from the methods declared in the beanHome class to the proxy delegate class. This allows the methods to be either named the same as the home interface method "create(...)" or as the bean class method "ejbCreate(...)". This handles both local home and remote home interface methods.


mapRemoteMethods

protected void mapRemoteMethods(java.lang.Class beanRemote)
Performs a mapping from the methods declared in the beanRemote class to the proxy delegate class. This handles both local and remote interface methods.