0 Replies Latest reply on Aug 14, 2009 10:49 AM by Stefan Ries

    Custom Interceptor & Reading Principal for MDB's

    Stefan Ries Newbie

      Hi,
      I have a problem with JBoss security. I implemented an interceptor in which I need to read the current principal. This basically works very well, I get the subject using the following code:

      1. (Subject) PolicyContext.getContext("javax.security.auth.Subject.container")


      The problem occurs when I have a Message Driven Bean which is annotated with @RunAs("SYSTEM"). The code above always returns null. I also tried the following code, to read the subject.

      Subject.getSubject(AccessController.getContext());

      and also reading from the sessionContext
      sctx.getCallerPrincipal()


      With all this, I didn't have success. I saw in the JBoss sources that the RunAsIdentity is sort of a special treatment which is read by the SecurityInterceptor like this:
      SecurityActions.peekRunAsIdentity()

      But calling this is not possible for me due to security restricitons and I think it's also not meant to be read like this.
      Does anybody have an idea what is the correct way to read the subject and principal in this case?

      Thanks!
      stefan