Issue with System User Configuration in AEM as a Cloud Service
I’m attempting to create and configure a service user for access to certain resources within AEM as Cloud service. Below are the steps I’ve followed and the error I encountered.
public final class ResolverUtil {
private ResolverUtil() {
}
public static final String project_SERVICE_USER = "resource";
public static ResourceResolver newResolver(ResourceResolverFactory resourceResolverFactory) throws LoginException {
final Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put(ResourceResolverFactory.SUBSERVICE, "resource");
return resourceResolverFactory.getServiceResourceResolver(paramMap);
}
}RepositoryInitializer code below
org.apache.sling.jcr.repoinit.RepositoryInitializer~projectwebsite-readcf.config
// org.apache.sling.jcr.repoinit.RepositoryInitializer~projectwebsite-readcf.config
scripts = ["
# Create service user if it doesn't exist
create service user project-website-service with forced path system/cq:services/project-website
# Set ACL permissions
set principal ACL for project-website-service
allow jcr:read,jcr:write,jcr:modifyProperties,jcr:addChildNodes,jcr:removeNode,jcr:removeChildNodes on /content/dam/projectwebsite/customer
allow jcr:read on /content/dam/projectwebsite
end
"]ServiceUserMapperImpl code below
org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended~projectwebsite.cfg.json
{
"user.mapping": [
"aem-project-website.core:resource=[project-website-service]"
]
}When trying to use the service user, I receive the following error in the AEM logs:
org.apache.sling.api.resource.LoginException: Cannot derive user name for bundle aem-caat-website.core [620] and sub service resourceI am using AEM as a Cloud Service for this project.
The issue is occurring on my local AEM instance, not in the Cloud environment.
- I checked the user in localhost:4502/crx/expolorer did not see the user there under system/cq:services/project-website