Skip to main content
kev_var
Level 2
Oct 16, 2015 2:26 AM UTC
Solved

Question about ResourceResolverFactory getAdministrativeResourceResolver(null)

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.
smacdonald2008
smacdonald2008Accepted solution
Level 10
Oct 16, 2015 2:26 AM UTC

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
smacdonald2008Accepted solution
Level 10
Oct 16, 2015 2:26 AM UTC

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

Translate
Daniel_Gordon
Adobe Employee
Adobe Employee
Oct 16, 2015 2:26 AM UTC

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

Translate
smacdonald2008
Level 10
Oct 16, 2015 2:26 AM UTC

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

Translate
kev_var
kev_varAuthor
Level 2
Oct 16, 2015 2:26 AM UTC

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

 

thanks again .

kevin

Translate
smacdonald2008
Level 10
Oct 16, 2015 2:26 AM UTC