0 Replies Latest reply on Nov 26, 2014 2:35 PM by Ivan Babanin

    Dynamically add roles to principal

    Ivan Babanin Newbie

      I have Swing-base application which remotely invokes EJBs on WildFly 8.0.0. I've custom LoginModule (which extends DatabaseLoginModule). When the user logs in, he gets the basic role called 'Guest'. Then he selects an module which will use for further work. After that he will gets a new portion of roles to work in selected module.

       

      So I have User entity + Guest role. For each module of Swing application I have UserModel + roles specific for module. Can I dynamically add new roles to principal?

       

      Something like this:

       

      @Stateless
      @Remote(UserManagementRemote.class)

      public class UserManagementBean implements UserManagementRemote {

        @Resource
        private SessionContext sessionContext; 
       
        public void selectModule(UserModule module) {

         sessionContext.getCallerPrincipal().add(module.getRoles());
        }

      }