Question about ResourceResolverFactory getAdministrativeResourceResolver(null) | Community
Skip to main content
kev_var
New Participant
October 16, 2015
Solved

Question about ResourceResolverFactory getAdministrativeResourceResolver(null)

  • October 16, 2015
  • 5 replies
  • 2197 views

Hi ,

I wanted to know what happens when we pass "null" to "getAdministrativeResourceResolver" function in "org.apache.sling.api.resource.ResourceResolverFactory"? 

Does it tries to give administrative privileges based on the current loggedin user's profile or based on something else. Also does this work if we have implemented SSO for AEM?

Edit: forgot to add that I get the ResourceResolverFactory using

 
@Reference private ResourceResolverFactory resolverFactory;

;

thanks,

Kevin

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by smacdonald2008

As dgordon86 pointed out - this is deprecated in AEM 6. See this AEM community article that steps you through using the Sling getServiceResourceResolver method:

http://helpx.adobe.com/experience-manager/using/querying-experience-manager-sling.html

5 replies

smacdonald2008
New Participant
October 16, 2015
kev_var
kev_varAuthor
New Participant
October 16, 2015

So if we always pass null then under what circumstance can it fail ?(if it can that is)

 

thanks again .

kevin

smacdonald2008
New Participant
October 16, 2015

I have never seen a fail on many OSGi bundles that we run. I have always passed null as per the Javadocs. 

Daniel_Gordon
Employee
October 16, 2015

In AEM 6.0 the method getAdministrativeResourceResolver has been deprecated [0], as it is considered a security risk by providing too broad of access. A best practice is now to create a Service User with only the necessary permissions and use the method getServiceResourceResolver to get a ResourceResolver. There is a full discussion on the Sling documentation: [1]. In addition Yogesh Upadhyay provides a good tutorial on his blog: [2]

[0] - http://docs.adobe.com/content/docs/en/aem/6-0/develop/ref/diff-previous/changes/org.apache.sling.api.resource.ResourceResolverFactory.html

[1] - http://sling.apache.org/documentation/the-sling-engine/service-authentication.html

[2] - http://www.wemblog.com/2014/08/how-to-use-sessions-and-resource.html

smacdonald2008
smacdonald2008Accepted solution
New Participant
October 16, 2015

As dgordon86 pointed out - this is deprecated in AEM 6. See this AEM community article that steps you through using the Sling getServiceResourceResolver method:

http://helpx.adobe.com/experience-manager/using/querying-experience-manager-sling.html