Tracking userID across JEE application method calls


EJB design: Tracking userID across JEE application method calls

  1. Tracking userID across JEE application method calls (3 messages)

    Hello there I am implementing a JEE gateway to receive client requests via web services. I have to create an audit token at the entry point and have to use it to log all important data changes. I don’t want to corrupt my API by passing Audit token as a parameter for all method calls. I am looking to track audit token somehow but without making any reference to it inside business logic and want the interceptors to do all the logging work. Has anybody implemented a userID or some kind of session tracking without corrupting core API??? Many thanks in advance for your help. Regards J Singh
  2. Obviously you must be Authenticating your Client first! If yes then you must be having some mechanism in place (in your core API) to allow Client the subsequent method calls based upon his previous authentication. You can generate an Audit token during authentication and reterieve the same internally using the same mechanism you use to identify your client for subsequent method calls. Regards Sarabjit S. Rupaal
  3. If I have understood your requirement correctly, you want to see something like this in log message ... [time] INFO [user-id] Changing data .... .. .. [time] INFO [user-id] Changing data .... done Take a look at this : You will have to push in user-id value to MDC (thread local wrapper) and using %Xuser-id style of format you can see that log files. Hope this solves your problem Shrini
  4. Store the user ID in ThreadLocal and access it wherever required. Thanks, Vinod