Expand my Community achievements bar.

SOLVED

Enable auto-login to user in CQ author environment(5.6.1) as per the user id

Avatar

Level 2

I am trying to fetch the user password using the user id to enable auto-login to CQ author environment.

Below is what i have been trying:

Session jcrSession = resourceResolver.adaptTo(Session.class); UserManager userManager = AccessControlUtil.getUserManager(jcrSession); Authorizable authorizable = userManager.getAuthorizable(USER_ID); User user = null; if (authorizable instanceof User) { user = (User)authorizable; } SimpleCredentials credential = (SimpleCredentials)user.getCredentials(); char[] password = credential.getPassword(); out.println("Password: " + password);

I get a an exception at line 8.

java.lang.ClassCastException: org.apache.jackrabbit.core.security.authentication.CryptedSimpleCredentials cannot be cast to javax.jcr.SimpleCredentials

I know the password for a user is hashed in CQ but was trying this as suggested on an earlier post @ http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manage... 

Please suggest if retrieving password is not possible, is there a way to implement a custom authentication handler in CQ author env that covers all scenarios as in the default Login selector handler.

Thanks,

1 Accepted Solution

Avatar

Correct answer by
Level 8

Try casting to CryptedSimpleCredentials instead of SimpleCredentials

View solution in original post

1 Reply

Avatar

Correct answer by
Level 8

Try casting to CryptedSimpleCredentials instead of SimpleCredentials