Search code examples
javaaemsling

AEM: How to get administrative resource resolver, since getAdministrativeResourceResolver(Map<String,Object> authenticationInfo) is deprecated?


I have to get administrative prevailed org.apache.sling.api.resource.ResourceResolver.

But the API, ResourceResolverFactory.getAdministrativeResourceResolver(Map<String,Object> authenticationInfo) is depricated.


Solution

  • Solution by @Dileepa would work, but definitely not a good practice to hardcode passwords and also, its always good to prevent over-use of administrative resourceresolvers/sessions.

    Take a look at the implementation mentioned here in sling docs.