2 Replies Latest reply on Mar 22, 2004 11:27 AM by nishantk

    JAAS within POJOs used in Web Tier

    nishantk

      Our product has an API layer, which is implemented as POJO wrapper classes around Stateless Session Beans. The APIs are accessed through a Factory class, and the constructor of the Factory class performs the authentication for the user (logs them in).

      We wanted to change the authentication layer within the POJOs to be based on JAAS. So the login performed by the factory constructor now does a login on a JAAS based login context. This login context is provided to (set in) every API class that the factory returns.

      When we utilize these API classes from a command-line client, everything works fine. However, when we use these API classes from within a web application (built on Struts, using form-based login), the authentication succeeds, but the calls to the Session Beans (via the POJOs) does not transmit the security context to the Session Bean. In other words, doing an EJBContext.getCallerPrincipal().getName() in the EJB code always returns "Unknown", the unauthenticated user.

      I believe we have everything set up correctly (including the auth.conf on the web client side that uses ClientLoginModule with multi-threading turned on). However, this still does not work. I believe it has something to do with the session threading. However, we cannot implement a Servlet Filter that executes the JAAS login again, since the Web Tier is unaware of the authentication layer. Is there any way we can manage this? We tried calling the login method on the stored loginContext in the POJO before each method invocation on the bean, but that did not help.

      Any help is greatly appreciated.

      Thanks,
      Nishant

        • 1. Re: JAAS within POJOs used in Web Tier
          wdrai

          In case of a web tier, you should configure the client-login module in login-config.xml instead of auth.conf

          • 2. Re: JAAS within POJOs used in Web Tier
            nishantk

            The login-config.xml file in $JBOSS_HOME\server\default\conf has been set up with the login module used on the server layer (a custom one that is an extension of UsernamePasswordLoginModule. Is that the login-config file you are referring to?

            Just in case I was not able to clearly explain our setup - Our application consists of the following tiers:

            Web Tier (Struts) ==> POJO API Tier ==> EJB Tier

            The login logic is all within the POJO API Tier.

            Thanks,
            Nishant