Expand my Community achievements bar.

SOLVED

Question about ResourceResolverFactory getAdministrativeResourceResolver(null)

Avatar

Level 2

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

1 Accepted Solution

Avatar

Correct answer by
Level 10

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

View solution in original post

5 Replies

Avatar

Level 2

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

 

thanks again .

kevin

Avatar

Level 10

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

Avatar

Employee Advisor

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...

[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

Avatar

Correct answer by
Level 10

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