Hi guys,
I am using the Profile service and the UserManager factory, both of which have stopped working in the publisher in 5.6.1.
Is there an alternative, or solution which will allow me to continue using it?
My code below:
public IGProfile getUserProfile(String authorizableId) { if (!StringUtils.isEmpty(authorizableId)) { try { /** * Do not close the resolver in this case as IGProfile needs to read the props from the * SessionAndResolver, normally we need to close the SessionAndResolver. */ final SessionAndResolver sessionAndResolver = rmanager.getCurrentOrCreateNew(); final ResourceResolver resolver = sessionAndResolver.getResolver(); final Authorizable auth = userManagerFactory.createUserManager(sessionAndResolver.getSession()).get(authorizableId); final Resource profileResource = resolver.getResource(auth.getHomePath() + "/profile"); if (profileResource != null) { return profileResource.adaptTo(IGProfile.class); } } catch (NoSuchAuthorizableException e) { LOG.info("No such user '{}'", authorizableId); // No Authorizable for that ID exists so return null } catch (AccessDeniedException e) { LOG.warn("AccessDeniedExceptionto load user '{}'", authorizableId, e); } } return null; }
Thanks!
Sam
Solved! Go to Solution.
Views
Replies
Total Likes
Hi Sam,
I don't see any usage of the CQ Profile class. All I see is "IGProfile".
Regarding the UserManagerFactory, as documented, you should use the Jackrabbit UserManager instead of the CQ UserManager (https://dev.day.com/docs/en/cq/current/javadoc/com/day/cq/security/UserManager.html). The easiest way to get a Jackrabbit UserManager based on the code above would be to write
UserManager userManager = resolver.adaptTo(UserManager.class);
Regards,
Justin
Views
Replies
Total Likes
Hi Sam,
I don't see any usage of the CQ Profile class. All I see is "IGProfile".
Regarding the UserManagerFactory, as documented, you should use the Jackrabbit UserManager instead of the CQ UserManager (https://dev.day.com/docs/en/cq/current/javadoc/com/day/cq/security/UserManager.html). The easiest way to get a Jackrabbit UserManager based on the code above would be to write
UserManager userManager = resolver.adaptTo(UserManager.class);
Regards,
Justin
Views
Replies
Total Likes
To follow up with what Justin stated -- you can read a community article that talks about how to use the Jackrabbit User Manager from an OSGi bundle:
http://helpx.adobe.com/experience-manager/using/developing-aem-osgi-bundles-jackrabbit.html
Hope this helps.
Views
Replies
Total Likes