5 Replies Latest reply on Nov 2, 2006 2:57 PM by soshah

    Recording user logins/logouts

    free1000

      I need to record an event in a database table when a user logs on and off of the portal.

      I'd ideally like to do this without changing the JBoss portal sources.

      I can think of a couple of hackish ways of doing this involving jsps/servlets and redirects but wonder if anyone can think of a clean way of mixing this in to the portal via configuration of any kind that avoids coupling the solution to a specific portal release.

        • 1. Re: Recording user logins/logouts
          peterj

          Just a thought. Have you looked into using AOP to accomplish this? Writing an aspect for the appropriate methods should do the trick. (And before you ask, no I have not done this.)

          • 2. Re: Recording user logins/logouts
            soshah

            Since Portal uses JAAS based authentication, you could also integrate a custom Tomcat Valve and monitor a user's authenticated session.

            Tomcat Valve would hook in from your web app's context.xml



            • 3. Re: Recording user logins/logouts
              free1000

              My first thought is that I like the idea of the custom valve for Tomcat. I'll take a look at it.

              I was thinking of the AOP approach but I'm not familiar with how that would be hooked in to the portal.

              Thanks for the ideas

              • 4. Re: Recording user logins/logouts
                free1000

                I've written a simple valve but have a problem

                I've deployed the jar file containing the class to

                JBOSS\server\default\deploy\jbossweb-tomcat55.sar

                and I've added a valve entry in the server.xml

                However I'm getting the following error

                19:01:12,750 ERROR [Digester] Begin event threw exception
                java.lang.ClassNotFoundException: No ClassLoaders found for: com.fooco.util.security.valves.UserLoggerValve
                at org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMgr3.java:306)

                It seems logical to deploy the jar file in the tomcat sar directory... can't think of where else it might need to be. Could it be a question of compiler compatability? I am compiling under JDK 5.0.

                • 5. Re: Recording user logins/logouts
                  soshah

                  Hmmm...that beats me. The class should be found if its properly installed inside a jar in the tomcat sar file.


                  As an alternative, you dont have to integrate the Valve inside of core tomcat. You can integrate a Valve within the context of just your web application.

                  See this for details on how this can be setup:

                  http://wiki.jboss.org/wiki/Wiki.jsp?page=ExtendedFormAuthenticator


                  But still, the ClassNotFound is a mystery if the jar is copied into the tomcat sar file. This should work and has worked several times in the past for me