3 Replies Latest reply on Aug 4, 2003 10:44 AM by roxburd

    How do I determine if caller has role within EJB?

    roxburd

      I'm trying to use EntityContext.isCallerInRole() in an EJB... but it doesn't work.

      JBoss 3.0.4

      When isCallerInRole() is called I get the following output to server.log:
      2003-07-18 16:51:49,456 ERROR [org.jboss.ejb.plugins.LogInterceptor] RuntimeException:
      java.lang.IllegalStateException: isCallerInRole() called with no security context. Check that a security-domain has been set for the application.
      at org.jboss.ejb.EnterpriseContext$EJBContextImpl.isCallerInRole(EnterpriseContext.java:389)

      Can some really clever person tell me
      how to set up whatever it is that's missing? Of course, I have set up an application-policy in login-conf.xml (a DatabaseServerLoginModule) and all the role-based access control is working just fine for JSP access.
      or
      tell me I'm doing it all wrong... and the right way to do it - I'm just trying to find out if the calling principal has been allocated a specific role... it shouldn't be difficult, should it???

      Many thanks,
      Dave

        • 1. Re: How do I determine if caller has role within EJB?
          jarikr

          Hi Dave,

          have you set a security domain in the jboss.xml file?
          E.g. like



          <security-domain>java:/jaas/other</security-domain>
          <unauthenticated-principal>guest</unauthenticated-principal>

          <enterprise-beans>
          ....



          hope that helps!
          Jari

          • 2. Re: How do I determine if caller has role within EJB?
            roxburd


            Hey Jari,

            Thanks, you got me back on track. I'd tried that before but I was put off progressing it when my application then started to throw security exceptions for every access of every EJB in my deployment... following your post I had another whack at it and when I'd turned off all the access controls (set method-permissions to unchecked/, * for every EJB) it worked a treat.

            Thanks again,
            Dave

            • 3. Re: How do I determine if caller has role within EJB?
              roxburd

              Follow-up:
              But then, anonymous users still can't get access because JBoss doesn't consider them to be real users so you have to set up a <login-module> using AnonLoginModule in your login.conf...