The following methods are deprecated:
- ResourceResolverFactory.getAdministrativeResourceResolver
- ResourceProviderFactory.getAdministrativeResourceProvider
- SlingRepository.loginAdministrative
Now we can use the following code :
Map<String, Object> param = new HashMap<String, Object>();
param.put(ResourceResolverFactory.SUBSERVICE, "dummyuser");
resolver = resolverFactory.getServiceResourceResolver(param);
session = repository.loginService(null, null);
We need to set the service "Apache Sling Service User Mapper". Each entry is of the form 'bundleId [ ":" subServiceName ] "=" userName' where bundleId and subServiceName identify the service and userName defines the name of the user to provide to the service. like : org.mysample.core:dummyuser=analyticsservice
Note : The user (analyticsservice described in above example) node needs to have the following properties
- jcr:primaryType="rep:SystemUser"
- jcr:uuid="<some value>"
- rep:principalName="<some value>"
- rep:authorizableId="<some value>"
Also that the user *must not have* a password , and defined user must have sufficient permissions to perform the required tasks.
How to add system user :
- Logon to : http://localhost:4502/crx/explorer/index.jsp
- Click on User Administration .
- you will get screen popup (http://localhost:4502/crx/explorer/ui/usereditor.jsp?ck=1437378510768&Path=/home/users) , click on "Create System Users" as shown in snapshot below :
This comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
Delete