Get currently authenticated user in Activiti Script Task

cancel
Showing results for 
Search instead for 
Did you mean: 
jvaidya
Active Member II

Get currently authenticated user in Activiti Script Task

I'm trying to get the username and password of the currently authenticated user in an Activiti Groovy Script Task. I'm currently using this code: 


import org.activiti.engine.impl.identity.Authentication;

out.println("Auth: " + Authentication.getName());
out.println("Auth: " + Authentication.getCredentials().toString());

But it treats Authentication as the class, so getName() returns org.activiti.engine.impl.identity.Authentication and getCredentials() fails to run. I tried using authentication.getName() but that results in a 'No such property: authentication for class...' error. 

Any ideas for how I can get this to work? 

1 Reply
cjose
Senior Member II

Re: Get currently authenticated user in Activiti Script Task

Assuming you are referring to Alfresco Process Service, you cannot decode a password back, it is a one way algorithm. Alfresco Process Services use PasswordEncoder (Spring Security 4.0.1.RELEASE API)  to encode the password and as you can see the only options are to match the stored password (if you know it) or encode a new raw password.

If you want to get the current logged in user, please use 

com.activiti.security.SecurityUtils.getCurrentUserObject();