{"id":205,"date":"2006-09-08T18:37:41","date_gmt":"2006-09-08T22:37:41","guid":{"rendered":"http:\/\/www.dr-chuck.com\/wordpress\/?p=205"},"modified":"2011-12-17T12:20:44","modified_gmt":"2011-12-17T16:20:44","slug":"how-to-make-an-all-hands-group-in-sakai","status":"publish","type":"post","link":"https:\/\/www.dr-chuck.com\/csev-blog\/2006\/09\/how-to-make-an-all-hands-group-in-sakai\/","title":{"rendered":"How to make an All Hands Group in Sakai"},"content":{"rendered":"<p>Welcome to the experimental All Hands provider.<br \/>\nThe goal of this code is to allow the creation of Sites in Sakai in which<br \/>\nall users are automatically added.<br \/>\nThe basic idea is to make an external group provider id called &#8220;sakai.allhands&#8221; and then either produce a GroupProvider that indicates that all users are members of that group or add the code to an existing group provider.<br \/>\nIf you have an existing GroupProvider, simply add the following line of code:<br \/>\npublic Map getGroupRolesForUser(String userId)<br \/>\n{<br \/>\nMap rv = new HashMap();<br \/>\nrv.put(&#8220;sakai.allhands&#8221;,&#8221;access&#8221;); \/\/ Add this line<br \/>\nreturn rv;<br \/>\n}<br \/>\nIf you do not currently ave a GroupProvider, use the AllHandsGroupProvider provided herein.<br \/>\nTo enable this group provider, simply edit the file<br \/>\ncomponent\/src\/webapp\/WEB-INF\/components.xml<br \/>\nAnd add a bean entry as follows.   Redeploy your Sakai and Viola!<br \/>\n<?xml version=\"1.0\" encoding=\"UTF-8\"?><br \/>\n<!DOCTYPE beans PUBLIC \"-\/\/SPRING\/\/DTD BEAN\/\/EN\" \"http:\/\/www.springframework.org\/dtd\/spring-beans.dtd\"><br \/>\n<beans><br \/>\n<bean id=\"org.sakaiproject.authz.api.GroupProvider\"\nclass=\"org.sakaiproject.provider.authzGroup.AllHandsGroupProvider\"\ninit-method=\"init\"\ndestroy-method=\"destroy\"\nsingleton=\"true\"><br \/>\n<\/bean><br \/>\n<\/beans><br \/>\nThere are print statements in the code so you can be confident of that is happening.  Remove those statements before you go to production.<br \/>\nHOW TO USE THIS<br \/>\nMake a new site.  Either Setup or WorkSite Setup can be used.<br \/>\nLog in as Admin.  Use the Sites Tool to find the site you just added.  Grab the site ID using copy.<br \/>\nGo to the realm&#8217;s tool and past in the site ID and press &#8220;search&#8221; you will find the<br \/>\nrealm associated with the site.<br \/>\nClick on the realm &#8211; In the field &#8220;Provider Id&#8221; Enter &#8220;sakai.allhands&#8221; (no quotes) and save.<br \/>\nNow as people are logged in they get added to this site as &#8220;access&#8221;.  If you change someone  to maintain &#8211; they keep maintain.<br \/>\nWHY THIS WORKS?<br \/>\nWhen the user logs in, as part of their login the provider method<br \/>\ngetGroupRolesForUser(String userId)<br \/>\nThe real question being asked here is &#8220;For this user, what is the list  of Provider IDs does this person belong to and what roles does that  user have for each ID&#8221;.  We indicate that &#8220;for all the sites with  sakai.allhands the current user deserves access&#8221;.  So authzGroups  above us does magic SQL to make this so it looks for all of the sites  with the provider ID &#8220;sakai.allhands&#8221; and simply pokes  the user into those sites.<br \/>\nLook in this file:<br \/>\nauthz-impl\/impl\/src\/java\/org\/sakaiproject\/authz\/impl\/DbAuthzGroupService.java<br \/>\nLine 1554 to see the fun:<br \/>\n\/\/ for each realm that has a provider in the map, and does not have a grant for the user,<br \/>\n\/\/ add the active provided grant with the map&#8217;s role.<br \/>\n\/Chuck<br \/>\nSat Sep  9 00:34:37 CEST 2006<\/p>\n<p><!--more--><br \/>\nUnrelated nerdy bits &#8211; ignore &#8211; they are just notes regarding an approach that I did not follow through with because the trivial solution presented itself.<br \/>\nauthenticateUser() userId=usera<br \/>\ngetGroupRolesForUser() user=user1<br \/>\ngetUserRolesForGroup() id=null<br \/>\ngetUserRolesForGroup() id=null<br \/>\ngetGroupRolesForUser() user=admin<br \/>\ngetUserRolesForGroup() id=null<br \/>\ngetUserRolesForGroup() id=null<br \/>\ngetUserRolesForGroup() id=sakai.access<br \/>\n&#8212; Really this is get the map of users and roles for this group<br \/>\ngetGroupRolesForUser() user=admin<br \/>\ngetGroupRolesForUser() user=user1<br \/>\n^C<br \/>\nauthz-impl\/impl\/src\/java\/org\/sakaiproject\/authz\/impl\/DbAuthzGroupService.java<br \/>\n\/\/ Simple serialization of the existing grants.  A HashMap with each entry a list.<br \/>\n\/\/ keyed by user ID<br \/>\nMap grantMap = new HashMap();<br \/>\nfor (Iterator i = grants.iterator(); i.hasNext();)<br \/>\n{<br \/>\nUserAndRole uar = (UserAndRole) i.next();<br \/>\nList values = new ArrayList();<br \/>\nvalues.add(uar.role);<br \/>\nvalues.add(new Boolean(uar.active));<br \/>\nvalues.add(new Boolean(uar.provided));<br \/>\ngrantMap.put(uar.userId,values);<br \/>\n}<br \/>\nauthz-api\/api\/src\/java\/org\/sakaiproject\/authz\/api\/GroupProvider.java<br \/>\n\/**<br \/>\n* Access the user id &#8211; role name map for all users in the external group.<br \/>\n*<br \/>\n* @param id<br \/>\n*        The external group id.<br \/>\n* @param grantMap<br \/>\n*        A hash map keyed by userId.  Each entry in the map is a List with three elements<br \/>\n*           String current role in site<br \/>\n*           Boolean active<br \/>\n*           Boolean provided<br \/>\n* @return the user id &#8211; role name map for all users in the external group (may be empty).<br \/>\n*\/<br \/>\nMap getUserRolesForGroup(String id, Map grantMap);<br \/>\n&#8220;authz-impl\/impl\/src\/java\/org\/sakaiproject\/authz\/impl\/BaseAuthzGroupService.java&#8221; line 818 of 1448 &#8211;56%&#8211; col 4-25<br \/>\n&#8220;authz-impl\/impl\/src\/java\/org\/sakaiproject\/authz\/impl\/DbAuthzGroupService.java&#8221; line 1473 of 2069 &#8211;71%&#8211; col 35-49<br \/>\n\/\/ for each realm that has a provider in the map, and does not have a grant for the user,<br \/>\n\/\/ add the active provided grant with the map&#8217;s role.<br \/>\n&#8220;authz-impl\/impl\/src\/java\/org\/sakaiproject\/authz\/impl\/DbAuthzGroupService.java&#8221; line 1554 of 2069 &#8211;75%&#8211; col 5-33<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Welcome to the experimental All Hands provider. The goal of this code is to allow the creation of Sites in Sakai in which all users are automatically added. The basic idea is to make an external group provider id called &#8220;sakai.allhands&#8221; and then either produce a GroupProvider that indicates that all users are members of [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-205","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts\/205","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/comments?post=205"}],"version-history":[{"count":1,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts\/205\/revisions"}],"predecessor-version":[{"id":2311,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts\/205\/revisions\/2311"}],"wp:attachment":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/media?parent=205"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/categories?post=205"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/tags?post=205"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}