cancel
Showing results for 
Search instead for 
Did you mean: 

Even after customize user and group, IdentityService still create user in act_id_user and group in act_id_group table

harishashim
Champ in-the-making
Champ in-the-making
This question about doing own custom user and group table is very popular with Activiti. So I am proud the be the first guy in 2016 to ask this question again!

What I have done so far is extend ProcessEngineFactoryBean


public class ProcessEngineFactoryBeanX extends ProcessEngineFactoryBean {

   @Autowired
   UserDao userDao;

   @Autowired
   GroupDao groupDao;

   public ProcessEngineFactoryBeanX() {
      super();
   }

   @Override
   public ProcessEngine getObject() throws Exception {

      ProcessEngine processEngineObject = super.getObject();
      
      Map<Class<?>, SessionFactory> sF =((ProcessEngineConfigurationImpl)             
         processEngineObject.getProcessEngineConfiguration()).getSessionFactories();

      //There should be error thrown here if sF is null

      CustomUserEntityManagerFactory userEntityManagerFactory = new CustomUserEntityManagerFactory(
            userDao);

      CustomGroupEntityManagerFactory groupEntityManagerFactory = new CustomGroupEntityManagerFactory(
            groupDao);
      
      if (!sF.containsKey(CustomUserEntityManager.class)) {
         sF.put(CustomUserEntityManager.class,
            userEntityManagerFactory);
      }

      if (!sF.containsKey(CustomGroupEntityManager.class)) {
         sF.put(CustomGroupEntityManager.class,
               groupEntityManagerFactory);
      }
      

      return processEngineObject;
   }




And then inject the above as configuration beans bellow


@Configuration
public class ProcessEngineConfig {
   
   @Autowired
   ProcessEngineConfigurationImpl processEngineConfiguration;

   @Primary
   @Bean
   public ProcessEngineFactoryBean processEngineFactoryBean(){
      ProcessEngineFactoryBean bean = new ProcessEngineFactoryBeanX();
      bean.setProcessEngineConfiguration(processEngineConfiguration);
      return bean;
   }
}


I am pretty confident that the above works. And my custom manager and factory is now injected

However when I test with bellow code, user and group is still created in  act_id_user and act_id_group table.


   @Bean
   InitializingBean usersAndGroupsInitializer(
         final IdentityService identityService) {

      final Logger log = LoggerFactory.getLogger(this.getClass());

      return new InitializingBean() {
         public void afterPropertiesSet() throws Exception {

            Group group = identityService.newGroup("user");
            group.setName("users");
            group.setType("security-role");
            identityService.saveGroup(group);

            User admin = identityService.newUser("rootadmin");
            admin.setPassword("admin");
            identityService.saveUser(admin);

         }
      };
   }


What should then be my conclusion? Can I conclude that

- my customized identity service using own user and group table is not working?

OR

- whatever my customization, IdentityService will always create user and group in   act_id_user and act_id_group table?
3 REPLIES 3

harishashim
Champ in-the-making
Champ in-the-making
Using activiti-engine version 5.19.0.

harishashim
Champ in-the-making
Champ in-the-making
No one answering sofar?

I think this is serious issue since after customizing user and group, identity service still write to its own table. I just debug the code to verify that indeed the user and group creation happened after custom class that manage them successfully injected.

Perhaps some new stuff in version 5.19 change how to customize this functionality?

TIA
Haris

jbarrez
Star Contributor
Star Contributor
@harishashim: it just has been christmas holidays, don't expect people to answer that quickly. Also, you've been creating posts like crazy. I'm trying to answer them all, but it's not easy.

When plugging the user/group classes, nothing should be written to the tables.

When I look at the SaveUserCmd, i can see that the UserIdentityManager.class needs to be used, not the one you are using: https://github.com/Activiti/Activiti/blob/master/modules/activiti-engine/src/main/java/org/activiti/...

If you check the LDAP impl for this, you can see it implements that class too: https://github.com/Activiti/Activiti/blob/master/modules/activiti-ldap/src/main/java/org/activiti/ld...