{"id":6327,"date":"2019-04-18T13:21:19","date_gmt":"2019-04-18T07:51:19","guid":{"rendered":"\/?p=6327"},"modified":"2021-06-15T12:14:29","modified_gmt":"2021-06-15T06:44:29","slug":"ensure-service-user-an-acs-aem-commons-utility","status":"publish","type":"post","link":"https:\/\/www.argildx.us\/technology\/ensure-service-user-an-acs-aem-commons-utility\/","title":{"rendered":"Ensure Service User \u2013 An ACS AEM Commons Utility"},"content":{"rendered":"\n
Prior to AEM 6.2, developers used administrative resource resolver to access JCR programmatically.<\/span><\/span> Now, Ensure Service User in AEM will make the process less error prone and easier to manage.<\/span><\/p>\n Let us assume that a developer needs to access the resource from content path programmatically. Before AEM 6.2, administrative resource resolver was one of the ways to achieve the same. <\/span>In<\/span> <\/span>addition to<\/span> providing access to the content path(s)<\/span>,<\/span> administrative resource resolver provides access to the complete repository <\/span>thereby<\/span> <\/span>mak<\/span><\/i>ing<\/span><\/i> the application prone to making undesired changes<\/span><\/i> (e.g. nodes under \/libs, \/apps etc.).<\/span> <\/span><\/p>\n Since AEM 6.2, administrative resource resolver <\/span>has<\/span> <\/span>been <\/span>deprecated by Adobe and to address the above <\/span>issue <\/span>Adobe introduced \u201cService User\u201d. <\/span> <\/span><\/p>\n A service user is a JCR user with no <\/span>set <\/span>password and <\/span>limited<\/span> privileges necessary to perform a specific task. <\/span>N<\/span>o password <\/span>requirement <\/span>means that it will not be possible to login with a service user.<\/span> <\/span><\/p>\n JCR<\/span> is a<\/span>ccess<\/span>ed<\/span> <\/span>us<\/span>i<\/span>ng s<\/span>ervice users<\/span> i<\/span>nstead of the administrative resource resolver.<\/span> <\/span><\/p>\n Below are <\/span>two<\/span> plu<\/span>s<\/span> points about Service User.<\/span> <\/span><\/p>\n Again, there is lot of manual work for developer<\/span>s<\/span> to set<\/span> <\/span>up service user <\/span>i<\/span>n different environments.<\/span> <\/span><\/p>\n To overcome this problem<\/span>,<\/span> ACS Common provides a different way to bootstrap AEM project<\/span>s<\/span> with different functionality, a set of reusable components and AEM development kit. <\/span> <\/span><\/p>\n Here, we are going to discuss great utilities of ACS common named \u201cEnsure Service User\u201d. <\/span> <\/span><\/p>\n <\/span><\/p>\n Ensure Service User is provided by ACS commons. Here <\/span>is<\/span> some points about Ensure Service User.<\/span> <\/span><\/p>\n <\/span><\/p>\n Here step by step procedure are described to use \u201cEnsure Service User\u201d.<\/span> <\/span><\/p>\n com.adobe.acs.commons.users.impl.EnsureServiceUser-meetupUser.xml<\/span> <\/span><\/p>\n Here please note followings points:<\/span> <\/span><\/p>\n Principal name is name of your service user. <\/span>It<\/span> can be just principal name or principal name with relative path or principal name with absolute path. <\/span> <\/span><\/p>\n Remember, service users may only <\/span>exit<\/span> <\/span>under <\/span>\u201c<\/span><\/b>\/home\/users\/system\u201d<\/span><\/b> path.<\/span> <\/span><\/p>\n For example:<\/span> <\/span><\/p>\n 1. Your <\/span><\/b>Input<\/span><\/b>: <\/span>meetup-service-user<\/span> <\/span> <\/span><\/p>\n Service User will be created under path:<\/span><\/b> \u201c\/home\/users\/system\/meetup-service-user\u201d<\/span> <\/span><\/p>\n 2. Your Input:<\/span><\/b> \/my-company\/meetup-service-user <\/span>or <\/span><\/b>my-company\/meetup-service-user <\/span>or<\/span><\/b> <\/span><\/b>\/<\/span>my-company\/meetup-service-user<\/span> <\/span><\/p>\n Service <\/span><\/b>User <\/span><\/b>will be created under path:<\/span><\/b> \u201c\/home\/users\/system\/my-company\/meetup-service-user\u201d<\/span> <\/span><\/p>\n 3. Your Input:<\/span><\/b> <\/span><\/b>\/home\/users\/system\/my-company\/m<\/span>eetup-service-user<\/span> <\/span><\/p>\nProblem <\/span><\/b>S<\/span><\/b>tatement:<\/span><\/b> <\/span><\/h5>\n
Service User:<\/span><\/b> <\/span><\/h5>\n
\n
Problems <\/span><\/b>With<\/span><\/b> Service User:<\/span><\/b> <\/span><\/h5>\n
\n
Ensure Authorizable or Ensure Service User:<\/span><\/b> <\/span><\/h5>\n
\n
How to use:<\/span><\/b> <\/span><\/h5>\n
\n
Create an OSGi configuration for service user using factory configuration<\/span><\/b> <\/span><\/h6>\n<\/li>\n<\/ol>\n
<?xml version=\"1.0\" encoding=\"UTF-8\"?> <jcr:root xmlns:sling=\"http:\/\/sling.apache.org\/jcr\/sling\/1.0\" xmlns:cq=\"http:\/\/www.day.com\/jcr\/cq\/1.0\" xmlns:jcr=\"http:\/\/www.jcp.org\/jcr\/1.0\" xmlns:nt=\"http:\/\/www.jcp.org\/jcr\/nt\/1.0\" jcr:primaryType=\"sling:OsgiConfig\" principalName=\"meetup-service-user\" type=\"add\" ensure-immediately=\"{Boolean}true\" aces=\"[type=allow;privileges=jcr:read\\,rep:write;path=\/content]\"\/> <\/pre>\n
Principal <\/span><\/b>Name:<\/span><\/b> <\/span><\/h6>\n