cancel
Showing results for 
Search instead for 
Did you mean: 

Override Default Identity Session Implementation

sorinello
Champ in-the-making
Champ in-the-making
Hello,

I am building a project which involves creating a custom implementation of Identity Service because I need to use external users/groups.

I have implemented my own Factories like I saw in the other tutorials on the internet and this forum.
I extended my UserEntityManager and GroupEntityManager classes and made my own implementation.

Everything ok until here, now I need to tell the Activiti Engine to use my custom SessionFactories.

I have read all the articles regarding this (most of them were about extending Identity Service for LDAP) but also from other sources on web.
I am not using Spring and I have to do this programmatically, but it seems that all the posts about this are from 2010-2011, and the code has changed since then, leaving me unable to accomplish my task.

I am using Activiti 5.12

Here is the code I am using at this moment:


ProcessEngineConfiguration configuration =
            ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti.cfg.xml");
Map<Class< ? >, SessionFactory> sessionFactories =
            ((ProcessEngineConfigurationImpl) configuration).getSessionFactories();
        sessionFactories.put(ActivitiUserEntityManager.class, userEntityManagerFactory);
        sessionFactories.put(ActivitiGroupEntityManager.class, groupEntityManagerFactory);
        ProcessEngine engine = configuration.buildProcessEngine();
        ProcessEngines.registerProcessEngine(engine);
        ProcessEngines.init();

The code I tried makes a cast to ProcessEngineConfigurationImpl, which does not seem very elegant.
My question is this: Is there a better and a more elegant/recommended way of achieving this ? Or my implementation is following the current way of doing this in Activiti ? Also, am I missing something about this ? All the forum topics are old now, please guide me to the new/better/recommended way.

Regards,
Sorin B.
3 REPLIES 3

trademak
Star Contributor
Star Contributor
Hi,

Your code is correct. Not a lot has changed in the Identity service classes in the last years. Only the GroupManager and UserManager are now GroupEntityManager and UserEntityManager.
And if you instantiate the engine via Java, then yes you have to cast to ProcessEngineConfigurationImpl.

Best regards,

jlilley
Champ in-the-making
Champ in-the-making
Did you ever make this work?  If so, could you share some more code?

jansi
Champ in-the-making
Champ in-the-making
Please share if you have any sample. I am looking to use spring security with activiti