Hi,

Here's the code I am using in my test proxy. When the method test is called 
inside session bean, the SecurityException is thrown. If I try
to call any other method session bean after that nothing happens. Could it be 
in the use of ThreadLocal? isnt it needed for multiple user control?


package org;

import java.lang.reflect.*;
import javax.ejb.*;
import javax.naming.*;

import org.jboss.logging.*;

public class TestSecurityProxy implements org.jboss.security.SecurityProxy {

  private Logger log = null;
  private ThreadLocal _ctx = new ThreadLocal();

  /**
   * init
   *
   * @param class0 Class
   * @param class1 Class
   * @param object Object
   */
  public void init(Class class0, Class class1, Object object) {
    log = Logger.getLogger(this.getClass().getName());
    p("Init security proxy");
  }

  /**
   * init
   *
   * @param class0 Class
   * @param class1 Class
   * @param class2 Class
   * @param class3 Class
   * @param object Object
   */
  public void init(Class class0, Class class1, Class class2, Class class3,
                   Object object) {
    log = Logger.getLogger(this.getClass().getName());
    p("Init security proxy");
  }

  /**
   * invokeHome
   *
   * @param method Method
   * @param objectArray Object[]
   */
  public void invokeHome(Method method, Object[] objectArray) {
    p("Invoke Home");
  }


  public void setEJBContext(EJBContext ctx) {
    p("setEJBContext " + ctx);
    _ctx.set(ctx);
  }

  public void invoke(Method m, Object[] args, Object bean) throws
      SecurityException {

    if (bean instanceof TestSessionBean) {
      EJBContext ctx = (EJBContext) _ctx.get();
      String caller = ctx.getCallerPrincipal().getName();
      TestSessionBean t = (TestSessionBean) bean;
      String operation = m.getName();
      p("invoke method " + operation + " in bean " + t.toString() +
               " called by " + caller);

      if (m.getName().equals("test")) {
        int amount = 3;
        if(amount > 0)
          throw new SecurityException(
            "Failure");
      }
    }
    else {
      throw new SecurityException("Invalid bean instance for security proxy");
    }
  }
  /**
   * p1
   *
   * @param string String
   */
  private void p(String string) {
    if(log != null)
      log.debug(string);
  }
}

View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3854414#3854414

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3854414


-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to