This does not work:
private ResourceResolver getImpersonatedResolver(String userId) { Map<String, Object> param = new HashMap<>(); try {if(StringUtils.isNotBlank(userId)){ param.put(ResourceResolverFactory.USER_IMPERSONATION, userId); return resourceResolverFactory.getResourceResolver(param); } } catch (Exception e) {log.error(e.getLocalizedMessage(), e); }return null;}
The following exception message appears:
Impersonation not allowed.
org.apache.sling.api.resource.LoginException: Impersonation not allowed.
at org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProviderFactory.getLoginException(JcrResourceProviderFactory.java:402)
at org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProviderFactory.handleImpersonation(JcrResourceProviderFactory.java:381)
at org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProviderFactory.getResourceProviderInternal(JcrResourceProviderFactory.java:344)
at org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProviderFactory.getResourceProvider(JcrResourceProviderFactory.java:209)
at org.apache.sling.resourceresolver.impl.tree.ResourceProviderFactoryHandler.login(ResourceProviderFactoryHandler.java:172)
at org.apache.sling.resourceresolver.impl.tree.RootResourceProviderEntry.loginToRequiredFactories(RootResourceProviderEntry.java:95)
at org.apache.sling.resourceresolver.impl.CommonResourceResolverFactoryImpl.getResourceResolverInternal(CommonResourceResolverFactoryImpl.java:257)
at org.apache.sling.resourceresolver.impl.CommonResourceResolverFactoryImpl.getResourceResolver(CommonResourceResolverFactoryImpl.java:158)
at org.apache.sling.resourceresolver.impl.ResourceResolverFactoryImpl.getResourceResolver(ResourceResolverFactoryImpl.java:99)
Under AEM 6.0 it worked.
Solved! Go to Solution.
Views
Replies
Total Likes
It looks like logged in User doesnt have permission to impersonate the given userId.
Have you configured the same for the logged in User in useradmin ?
Views
Replies
Total Likes
It looks like logged in User doesnt have permission to impersonate the given userId.
Have you configured the same for the logged in User in useradmin ?
Views
Replies
Total Likes
I do see the same problem at the last line, it is throwing the same exception
we have created writeService system user and added to administrators group (AEM 6.2)
Map<String, Object> param = new HashMap<String, Object>();
param.put(ResourceResolverFactory.SUBSERVICE, "writeService");
adminResolver = resourceResolverFactory.getServiceResourceResolver(param);
adminSession = adminResolver.adaptTo(Session.class);
userSession = adminSession.impersonate(new SimpleCredentials(member.getID(),"".toCharArray()));
29.11.2016 16:45:26.894 *ERROR* [JobHandler: /etc/workflow/instances/server0/2016-11-28_4/test2] com.abc.SingleMailGenerator Could not send email
javax.jcr.LoginException: Impersonation not allowed.
Views
Replies
Total Likes
See this video and article - it shows you this working:
http://scottsdigitalcommunity.blogspot.ca/2014/12/querying-adobe-experience-manager-6.html
Views
Replies
Total Likes
Views
Likes
Replies