I have to get administrative prevailed org.apache.sling.api.resource.ResourceResolver
.
But the API, ResourceResolverFactory.getAdministrativeResourceResolver(Map<String,Object> authenticationInfo)
is depricated.
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.