5 Replies Latest reply on Mar 10, 2010 2:16 AM by Dmitry Egorov

    EJB3 @SecurityDomain and @RunAs or @RunAsPrincipal not worki

    Carsten Fregin Newbie

      Could someone show me, how to use @RunAs or @RunAsPrincipal?
      My try:

      SessionBean

      @Stateless
      @SecurityDomain("mysecuritydomain")
      public class CustomerControllerBean implements CustomerController{
       @PersistenceContext EntityManager em;
      
       @RolesAllowed({"AdminUser"})
       public void createCustomer(String name){
       ...create user...
       }
      }
      


      JMX Bean
      @Service (objectName="myjndi:service=testapplication")
      @RunAs("AdminUser")
      public class TestApplicationMBean implements TestApplication{
       @EJB CustomerController customerController;
       public String testAccess(String username){
       customerController.createCustomer(username);
       }
      }
      


      The access to my SessionBean is only working, if I make a login with the LoginContext with a valid user/password. My intention is to create AdminUsers through a JMX bean. Therefore, I have to permit some functions for the JMX-Bean. I do get "Authentication failure, Password Incorrect/Password Required" errors. I examined a little bit the workflow and see, that there is no principal set. (null)

      Could it be, that @RunAs is not working in the current release?
      JBoss version: 4.0.3SP1