User: starksm 
  Date: 02/03/03 09:20:06

  Modified:    src/main/org/jboss/ejb EnterpriseContext.java
                        InstancePool.java
                        MessageDrivenEnterpriseContext.java
                        StatelessSessionEnterpriseContext.java
  Log:
  The ejbCreate call is a secured op in which getCallerPrincipal on
  the EJBContext is a valid call. This requires that the caller of
  the method that caused the ejbCreate be associated with the EnterpriseContext.
  
  Revision  Changes    Path
  1.44      +8 -2      jboss/src/main/org/jboss/ejb/EnterpriseContext.java
  
  Index: EnterpriseContext.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/ejb/EnterpriseContext.java,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- EnterpriseContext.java    3 Feb 2002 22:59:11 -0000       1.43
  +++ EnterpriseContext.java    3 Mar 2002 17:20:05 -0000       1.44
  @@ -47,7 +47,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Sebastien Alborini</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Juha Lindfors</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Ole Husgaard</a>
  - * @version $Revision: 1.43 $
  + * @version $Revision: 1.44 $
    *
    * Revisions:
    * 2001/06/29: marcf
  @@ -99,10 +99,16 @@
      
      public EnterpriseContext(Object instance, Container con)
      {
  +      this(instance, con, null);
  +   }
  +   public EnterpriseContext(Object instance, Container con,
  +      Principal callerPrincipal)
  +   {
         this.instance = instance;
         this.con = con;
  +      this.principal = callerPrincipal;
      }
  -   
  +
      // Public --------------------------------------------------------
   
      public Object getInstance() 
  
  
  
  1.11      +15 -7     jboss/src/main/org/jboss/ejb/InstancePool.java
  
  Index: InstancePool.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/ejb/InstancePool.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- InstancePool.java 28 Dec 2001 03:47:11 -0000      1.10
  +++ InstancePool.java 3 Mar 2002 17:20:05 -0000       1.11
  @@ -6,6 +6,7 @@
    */
   package org.jboss.ejb;
   
  +import java.security.Principal;
   
   import org.jboss.monitor.StatisticsProvider;
   
  @@ -13,7 +14,7 @@
    * Defines the model for a EnterpriseContext instance pool.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Rickard �berg</a>
  - * @version $Revision: 1.10 $
  + * @version $Revision: 1.11 $
    *
    * <p><b>Revisions:</b>
    * <p><b>20010718 andreas schaefer:</b>
  @@ -30,25 +31,33 @@
      extends ContainerPlugin, StatisticsProvider
   {
      /**
  -    *  Add an instance in the Pool.
  -    *  Is used by the TimedInstancePoolFeeder thread to create instances ready for 
use by
  -    *  the interceptor.
  +    * Add an instance in the Pool.
  +    * Is used by the TimedInstancePoolFeeder thread to create instances ready for 
use by
  +    * the interceptor.
  +    * Since this can result in an ejbCreate invocation on a bean instance,
  +    * the caller principal must be associated with the EnterpriseContext
  +    * before calling ejbCreate in order for ctx.getCallerPrincipal() to
  +    * work.
       *
       * @exception Exception when an Instance can not be instantiated
       */
  -   public void add()
  +   public void add(Principal callerPrincipal)
            throws Exception;
   
      /**
       * Get an instance without identity.
       *
       * <p>Can be used by finders and create-methods, or stateless beans
  +    * Since this can result in an ejbCreate invocation on a bean instance,
  +    * the caller principal must be associated with the EnterpriseContext
  +    * before calling ejbCreate in order for ctx.getCallerPrincipal() to
  +    * work.
       *
       * @return    Context/w instance
       *
       * @throws Exception    RemoteException
       */
  -   EnterpriseContext get() throws Exception;
  +   EnterpriseContext get(Principal callerPrincipal) throws Exception;
   
      /**
       * Return an anonymous instance after invocation.
  @@ -81,4 +90,3 @@
      public int getMaxSize();
   
   }
  -
  
  
  
  1.13      +9 -8      jboss/src/main/org/jboss/ejb/MessageDrivenEnterpriseContext.java
  
  Index: MessageDrivenEnterpriseContext.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/MessageDrivenEnterpriseContext.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- MessageDrivenEnterpriseContext.java       26 Nov 2001 03:12:24 -0000      1.12
  +++ MessageDrivenEnterpriseContext.java       3 Mar 2002 17:20:05 -0000       1.13
  @@ -8,10 +8,8 @@
   
   import java.lang.reflect.Method;
   import java.lang.reflect.InvocationTargetException;
  -
  -import java.security.Principal;
  -
   import java.rmi.RemoteException;
  +import java.security.Principal;
   
   import javax.ejb.EJBContext;
   import javax.ejb.EJBHome;
  @@ -31,7 +29,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Peter Antman</a>.
    * @author <a href="mailto:[EMAIL PROTECTED]";>Rickard �berg</a>
    * @author <a href="[EMAIL PROTECTED]">Sebastien Alborini</a>
  - * @version $Revision: 1.12 $
  + * @version $Revision: 1.13 $
    */
   public class MessageDrivenEnterpriseContext
      extends EnterpriseContext
  @@ -51,7 +49,7 @@
      {
         super(instance, con);
         ctx = new MessageDrivenContextImpl();
  -    
  +
         ((MessageDrivenBean)instance).setMessageDrivenContext(ctx);
   
         try
  @@ -59,7 +57,8 @@
            Method ejbCreate = instance.getClass().getMethod("ejbCreate",
                                                             new Class[0]);
            ejbCreate.invoke(instance, new Object[0]);
  -      } catch (InvocationTargetException e)
  +      }
  +      catch (InvocationTargetException e)
         {
            Throwable ex = e.getTargetException();
            if (ex instanceof EJBException)
  @@ -81,13 +80,15 @@
      // Here we have some problems. If we are to use the Stateless stuff,
      // should we inherit from StatelessSessionEnterpriseContext or what?
   
  -   public void setEJBObject(EJBObject eo) {
  +   public void setEJBObject(EJBObject eo)
  +   {
         throw new Error("Not applicatable for MessageDrivenContext");
         //NOOP
         //ejbObject = eo;
      }
   
  -   public EJBObject getEJBObject() {
  +   public EJBObject getEJBObject()
  +   {
         throw new Error("Not applicatable for MessageDrivenContext");
         //return ejbObject;
      }
  
  
  
  1.15      +5 -4      
jboss/src/main/org/jboss/ejb/StatelessSessionEnterpriseContext.java
  
  Index: StatelessSessionEnterpriseContext.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/StatelessSessionEnterpriseContext.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- StatelessSessionEnterpriseContext.java    19 Dec 2001 05:34:29 -0000      1.14
  +++ StatelessSessionEnterpriseContext.java    3 Mar 2002 17:20:05 -0000       1.15
  @@ -9,7 +9,7 @@
   import java.lang.reflect.Method;
   import java.lang.reflect.InvocationTargetException;
   import java.rmi.RemoteException;
  -
  +import java.security.Principal;
   import javax.ejb.EJBContext;
   import javax.ejb.EJBLocalObject;
   import javax.ejb.EJBObject;
  @@ -22,7 +22,7 @@
    *      
    * @author <a href="mailto:[EMAIL PROTECTED]";>Rickard �berg</a>
    * @author <a href="[EMAIL PROTECTED]">Sebastien Alborini</a>
  - * @version $Revision: 1.14 $
  + * @version $Revision: 1.15 $
    */
   public class StatelessSessionEnterpriseContext
      extends EnterpriseContext
  @@ -39,10 +39,11 @@
      
      // Constructors --------------------------------------------------
      
  -   public StatelessSessionEnterpriseContext(Object instance, Container con)
  +   public StatelessSessionEnterpriseContext(Object instance, Container con,
  +      Principal callerPrincipal)
         throws Exception
      {
  -      super(instance, con);
  +      super(instance, con, callerPrincipal);
         ctx = new SessionContextImpl();
         
         ((SessionBean)instance).setSessionContext(ctx);
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to