0 Replies Latest reply on Feb 16, 2009 8:50 AM by hubaer

    Set Principal in a web application

      Hi all,

      I don't know if this here is the right forum, but hopefully I get some answers from the experts.

      We are migration a devided application (web, batch processing, web services all single applications) into a JEE application, running on JBoss.

      As far, most of the parts are running correctly, but we have a little problem with the interaction of the web with our EJB3 session / entity beans. For auditing purpose we must store the name of the user which created or modified an entity. Therefore we write an interceptor with get the principal from the SecurityAssociation class.
      To access the session beans we make a JNDI lookup like

      environment.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.security.jndi.JndiLoginInitialContextFactory");
      environment.put(Context.SECURITY_PRINCIPAL, "testName");
      environment.put(Context.SECURITY_CREDENTIALS, "testPassw");
      environment.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
      environment.put("java.naming.provider.url", "jnp://localhost:1099");
      InitialContext context = new InitialContext(environment);
      context.lookup(jndiName);
      


      But always we call SecurityAssociation.getPrincipal() in our audit interceptor we get a null object.
      We tried the same with a remote client setting the same JNDI values and got the principal from the SecurityAssociation.

      Do I miss something accessing the the session beans via JNDI inside JBoss from the web layer to the EJB layer?
      Any help is welcome.

      Thanks,
      Marco