1 Reply Latest reply on May 14, 2004 11:44 AM by dsklyut

    Obtaining current JAAS Subject

      Hi All,

      I wonder if the following code will work in JBoss:

      AccessControlContext context = AccessController.getContext();
      return Subject.getSubject(context);
      


      I would like to get a handle to the current Subject in web or ejb tier. I would like to find out the "roles" that Principal has (e.i is Principal an "Admin" or "Customer"). I wanted to use Group("Roles") as a store for them and then have an API
      Security.isAdminUser(User)

      to check on a role.

      Thanks

      Dmitry

        • 1. Re: Obtaining current JAAS Subject

          Ok, didn't think long enough before I posted.

          All this can be done simple and easy with:

          public static final boolean isAdminUser(HttpServletRequest req)
          {
          return req.isUserInRole("Admin"):
          }
          
          public static final boolean isAdminUser(EJBContext context)
          {
          return context.isCallerInRole("Admin");
          }
          
          


          Its Friday :)

          Dmitry