cancel
Showing results for 
Search instead for 
Did you mean: 

IdentitySession in Activiti 5.5

zeroone
Champ in-the-making
Champ in-the-making
Hey,

I wanted to integrate Spring Security into Activit's IdentitySession, but I was uanble to find the IdentitySession-Interface.
Could It be, that it is no longer available under the FQN: org.activiti.engine.impl.cfg.IdentitySession?

Ciao,

Christoph
30 REPLIES 30

limcheekin
Champ on-the-rise
Champ on-the-rise
what I did is to add this to "processEngineConfiguration" config in spring,

  <property name="customSessionFactories">
   <list>
    <bean class="com.xxxxx.user.ActivitiCustomUserManagerFactory">
     <property name="usersDao" ref="usersDAO"/>
    </bean>
   </list>
  </property>

And this factory will return ActivitiCustomUserManager (extends UserManager) in its openSession() method.

Similar thing should be needed for GroupManager and its Factory as well.

Thanks for writing.

I tried the following configuration:

<property name="customSessionFactories">
<list>
<bean class="org.grails.activiti.springsecurity.SpringSecurityUserManagerFactory">
<property name="usersDao" ref="usersDAO"/>
</bean>
<bean class="org.grails.activiti.springsecurity.SpringSecurityGroupManagerFactory">
<property name="groupsDao" ref="groupsDAO"/>
</bean>
</list>
</property>
and SpringSecurityUserManagerFactory implementation:

package org.grails.activiti.springsecurity;

import org.activiti.engine.impl.interceptor.Session;
import org.activiti.engine.impl.interceptor.SessionFactory;

class SpringSecurityUserManagerFactory implements SessionFactory {
public Class<?> getSessionType() {
  return UserManager.class;
}

public Session openSession() {
  return new UserManager();
}
}

Unluckily, the code above doesn't work, did I overlook anything?

Please advice.

Best regards,
Chee Kin

carlos1
Champ in-the-making
Champ in-the-making
I managed to make it work by doing what you did:


public Class<?> getSessionType() {
      return UserManager.class;
   }

   public Session openSession() {
      return new MyUserManager();
   }

Notice the  MyUserManager()

At the activity repository one can find a test that shows how to replace the IdentitySession. However that code doesn't work anymore in activiti 5.5 as mention here.

It would be nice to know if the way to replace the IdentitySession/UserManager will change in the future. I understand that activiti is currently under development but I think it is important to know if which APIs are stable besides the public APIs. Unfortunately there is no documentation about it (or at least I could not find it).

ageen
Champ in-the-making
Champ in-the-making
what I did is to add this to "processEngineConfiguration" config in spring,

  <property name="customSessionFactories">
   <list>
    <bean class="com.xxxxx.user.ActivitiCustomUserManagerFactory">
     <property name="usersDao" ref="usersDAO"/>
    </bean>
   </list>
  </property>

And this factory will return ActivitiCustomUserManager (extends UserManager) in its openSession() method.

Similar thing should be needed for GroupManager and its Factory as well.

Thanks for writing.

I tried the following configuration:

<property name="customSessionFactories">
<list>
<bean class="org.grails.activiti.springsecurity.SpringSecurityUserManagerFactory">
<property name="usersDao" ref="usersDAO"/>
</bean>
<bean class="org.grails.activiti.springsecurity.SpringSecurityGroupManagerFactory">
<property name="groupsDao" ref="groupsDAO"/>
</bean>
</list>
</property>
and SpringSecurityUserManagerFactory implementation:

package org.grails.activiti.springsecurity;

import org.activiti.engine.impl.interceptor.Session;
import org.activiti.engine.impl.interceptor.SessionFactory;

class SpringSecurityUserManagerFactory implements SessionFactory {
public Class<?> getSessionType() {
  return UserManager.class;
}

public Session openSession() {
  return new UserManager();
}
}

What error did you see? In your config, the factory has DAO reference, how come there is not such property in your actual class?

Thanks.







Unluckily, the code above doesn't work, did I overlook anything?

Please advice.

Best regards,
Chee Kin

limcheekin
Champ on-the-rise
Champ on-the-rise
What error did you see? In your config, the factory has DAO reference, how come there is not such property in your actual class?

Thanks.

Thanks for writing. It is copy and paste mistake. I basically set up the Spring application context using Spring DSL in Grails. The corrected code (my application don't need DAOs) below is for illustration only:

<property name="customSessionFactories">
<list>
  <bean class="org.grails.activiti.springsecurity.SpringSecurityUserManagerFactory" />
  <bean class="org.grails.activiti.springsecurity.SpringSecurityGroupManagerFactory" />
</list>
</property>

Best regards,
Chee Kin

limcheekin
Champ on-the-rise
Champ on-the-rise
Hi there,

When I boot up my application, I find out that the activiti engine invokes getSessionType() of SpringSecurityUserManagerFactory and SpringSecurityGroupManagerFactory, but not openSession().

Below is the way I implement the UserManager, may I know is there anything wrong?

package org.grails.activiti.springsecurity


class UserManager extends org.activiti.engine.impl.persistence.entity.UserManager {

}
Please see a complete source code here http://code.google.com/p/grails-activiti-spring-security-plugin/source/browse/src/groovy/org/grails/...

I'd love to hear from you about how to troubleshooting this problem.

Best regards,
Chee Kin

limcheekin
Champ on-the-rise
Champ on-the-rise
Hi ageen and Carlos,

I still have no idea what went wrong.

Would you mind to share the code of UserManagerFactory and UserManager implementation?

Thanks,
Chee Kin

ageen
Champ in-the-making
Champ in-the-making
In this case, I would suggest you to pull out the activiti source code (specifically the engine module and the spring module, or maybe webapp-rest code as well), to debug it and see what's going on. That's what I would do if see something similar.

limcheekin
Champ on-the-rise
Champ on-the-rise
In this case, I would suggest you to pull out the activiti source code (specifically the engine module and the spring module, or maybe webapp-rest code as well), to debug it and see what's going on. That's what I would do if see something similar.

Sure. Thanks for quick response.

Anything wrong with my implementation of UserManager class?

Best regards,
Chee Kin

auzreal
Champ in-the-making
Champ in-the-making

<property name="customSessionFactories">
<list>
<bean class="org.grails.activiti.springsecurity.SpringSecurityUserManagerFactory">
<property name="usersDao" ref="usersDAO"/>
</bean>
<bean class="org.grails.activiti.springsecurity.SpringSecurityGroupManagerFactory">
<property name="groupsDao" ref="groupsDAO"/>
</bean>
</list>
</property>
and SpringSecurityUserManagerFactory implementation:

package org.grails.activiti.springsecurity;

import org.activiti.engine.impl.interceptor.Session;
import org.activiti.engine.impl.interceptor.SessionFactory;

class SpringSecurityUserManagerFactory implements SessionFactory {
public Class<?> getSessionType() {
  return UserManager.class;
}

public Session openSession() {
  return new UserManager();
}
}
I guess you should return org.activiti.engine.impl.persistence.entity.UserManager instead of the one in package org.grails.activiti.springsecurity. In this way, the custom SessionFactory can override original UserManager settings.

ageen
Champ in-the-making
Champ in-the-making
+1 on Auzreal's point.