I am using Hibernate Envers in a Tomcat environment. It works fine. I do however need to be able to add the username of the user that changed the data that is to be audited. This can be done by implementing your own version of RevisionEntity. Then you also have to implement a custom RevisionListener
that will populate the extra information you want to audit. I need to audit the username that has changed the data that are to be audited. In the documentation it is a example on how to do this with Seam. In the RevisionListener
they call:
Identity identity = (Identity) Component.getInstance("org.jboss.seam.security.identity");
To obtain the username. In my project we have split the project into seperate modules for database and web. I need to implement my custum revision listener in my database module to be able to get the currently logged in username. I can not move the RevisionListener
to the web package and introduce a dependency on the web module from the database module. How can I obtain the current username in a way that handles multiple users logged in at the same time in my custom RevisionListener`?
The best solution would be one that worked in most containers.