Hi @Ashok67621, you will need to follow below 3 steps.
- Create yaml (using AC Tool) file definition to create system user and assign it to group (I have used administrator group as an example - but you can use any other group)
- user_config:
- custom-system-user:
- isMemberOf: administrators
path: /home/users/system/custom
isSystemUser: true
- Add an entry in the Apache Sling Service User Mapper Service (it can be done manually from OSGi console, or via xml/config file) - below example shows config file usage.
Name of the file: org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-custom.config
service.ranking=I"0"
user.mapping=["<bundle-symbolic-name>:<name-of-service>\=custom-system-user"]
- Get resource resolver instance that will use above user
@Reference
private ResourceResolverFactory resolverFactory;
Map<String, Object> param = new HashMap<String, Object>();
param.put(ResourceResolverFactory.SUBSERVICE, "name-of-service");
ResourceResolver resourceResolver = resourceResolverFactory.getServiceResourceResolver(param);