0 Replies Latest reply on Sep 6, 2005 12:29 AM by shankarniyer

    Please Help:  JAAS

    shankarniyer

      Hi,
      I am trying to implement JAAS in Jboss.
      I use users.properties and roles.properties to define the users and roles.
      I have two methods in my enterprise bean which is accessed from a servlet.
      All deployment descriptors are properly set, which I double checked.
      One method is fro User and other for Administrator.
      My bean methods are as is as follows :


      public int MultiTwoNumber() {

      // get bean's caller using getCallerPrincipal()
      java.security.Principal principal = context.getCallerPrincipal();
      java.lang.String callerId= principal.getName();

      // check if bean's caller is granted Administrator role
      boolean isMgr = context.isCallerInRole("Administrator");

      // only set supplied message if caller is "bob" or caller is granted Mgr role
      if ( isMgr || callerId.equals("shankar") )
      results =1;
      else results=100*100;
      // return results;

      return results;
      }


      public int addTwoNumber() {

      // get bean's caller using getCallerPrincipal()
      java.security.Principal principal = context.getCallerPrincipal();
      java.lang.String callerId= principal.getName();

      // check if bean's caller is granted Administrator role
      boolean isMgr = context.isCallerInRole("User");

      // only set supplied message if caller is "bob" or caller is
      granted Mgr role
      if ( isMgr || callerId.equals("selva") )
      results =200;
      else results=1;
      // return results;
      return results;
      }
      }

      However I get the following Exception:

      [STDOUT] exception----RuntimeException; nested exception is:
      java.lang.IllegalStateException: No security context set

      Please Help,
      Thanx in Advance,
      Shankar.