Source Code Cross Referenced for AllHandsGroupProvider.java in  » ERP-CRM-Financial » sakai » org » sakaiproject » provider » authzGroup » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ERP CRM Financial » sakai » org.sakaiproject.provider.authzGroup 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**********************************************************************************
002:         * $URL: https://source.sakaiproject.org/svn/providers/tags/sakai_2-4-1/allhands/src/java/org/sakaiproject/provider/authzGroup/AllHandsGroupProvider.java $
003:         * $Id: AllHandsGroupProvider.java 20456 2007-01-19 00:58:21Z jholtzman@berkeley.edu $
004:         ***********************************************************************************
005:         *
006:         * Copyright (c) 2006 The Sakai Foundation.
007:         * 
008:         * Licensed under the Educational Community License, Version 1.0 (the "License"); 
009:         * you may not use this file except in compliance with the License. 
010:         * You may obtain a copy of the License at
011:         * 
012:         *      http://www.opensource.org/licenses/ecl1.php
013:         * 
014:         * Unless required by applicable law or agreed to in writing, software 
015:         * distributed under the License is distributed on an "AS IS" BASIS, 
016:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
017:         * See the License for the specific language governing permissions and 
018:         * limitations under the License.
019:         *
020:         **********************************************************************************/package org.sakaiproject.provider.authzGroup;
021:
022:        import java.util.HashMap;
023:        import java.util.Map;
024:
025:        import org.apache.commons.logging.Log;
026:        import org.apache.commons.logging.LogFactory;
027:        import org.sakaiproject.authz.api.GroupProvider;
028:        import org.sakaiproject.util.StringUtil;
029:
030:        /**
031:         * <p>
032:         * AllHands GroupProvider allows the creation of provided authzGroups that automatically include all users.
033:         * </p>
034:         * <p>
035:         * To use, set an authzGroup's external id to one of the following:
036:         * <ul>
037:         * <li>sakai.allhands</li>
038:         * </ul>
039:         * </p>
040:         */
041:        public class AllHandsGroupProvider implements  GroupProvider {
042:            /** Our log (commons). */
043:            private static Log M_log = LogFactory
044:                    .getLog(AllHandsGroupProvider.class);
045:
046:            /**********************************************************************************************************************************************************************************************************************************************************
047:             * Init and Destroy
048:             *********************************************************************************************************************************************************************************************************************************************************/
049:
050:            /**
051:             * Final initialization, once all dependencies are set.
052:             */
053:            public void init() {
054:                try {
055:                    M_log.info("init()");
056:                } catch (Throwable t) {
057:                    M_log.warn("init(): ", t);
058:                }
059:            }
060:
061:            /**
062:             * Cleanup before shutting down.
063:             */
064:            public void destroy() {
065:                M_log.info("destroy()");
066:            }
067:
068:            /**********************************************************************************************************************************************************************************************************************************************************
069:             * GroupProvider implementation
070:             *********************************************************************************************************************************************************************************************************************************************************/
071:
072:            /**
073:             * Construct.
074:             */
075:            public AllHandsGroupProvider() {
076:            }
077:
078:            /**
079:             * {@inheritDoc}
080:             */
081:            public String getRole(String id, String user) {
082:                System.out.println("getRole() id=" + id + " user=" + user);
083:                // Apparently this is not called ???
084:                return null;
085:            }
086:
087:            /**
088:             * {@inheritDoc}
089:             * This is not necessary - because the user has already been added because they are
090:             * enrolled in the allhand.s
091:             */
092:            public Map getUserRolesForGroup(String id) {
093:                Map rv = new HashMap();
094:
095:                return rv;
096:            }
097:
098:            /**
099:             * {@inheritDoc}
100:             *
101:             * If you can do some type of directory lookup to find out some 
102:             * Attribute of this user you could conditionally auto-add them
103:             * to any number of these "virtual groups"
104:             *
105:             * You might try sakai.students, sakai.faculty, 
106:             * sakai.staff, sakai.teamleads
107:             *
108:             * There is nothing specific about the string "sakai."  these could
109:             * easily be something like course.eecs280, shib:yale.edu:faculty,
110:             * or h23.groups.ruk.dk
111:             *
112:             * One caveat - this class is respnsbile for handling the unpacking
113:             * when an admin wants to put in multiple external providers
114:             * The code below uses the common convention of using "+" (homage
115:             * to "or") to concatenate IDs.  So the user above us could set the
116:             * provider ID in the Sakai Realms Tool to be
117:             *
118:             *    h23.groups.ruk.dk+course.eecs280 
119:             *
120:             * to indicate thatr membership in either group is OK.
121:             *
122:             * To indicate membership in multiple groups in *this routine* add 
123:             * additional entries in the hash map (i.e. do not use the + notation
124:             * in this routine).
125:             */
126:
127:            public Map getGroupRolesForUser(String userId) {
128:                System.out.println("getGroupRolesForUser() user=" + userId);
129:
130:                Map rv = new HashMap();
131:
132:                rv.put("sakai.allhands", "access");
133:
134:                return rv;
135:            }
136:
137:            public String[] unpackId(String id) {
138:                String[] rv = null;
139:
140:                // if there is not a '+' return just the id
141:                int pos = id.indexOf('+');
142:                if (pos == -1) {
143:                    rv = new String[1];
144:                    rv[0] = id;
145:                }
146:
147:                // otherwise split by the '+'
148:                else {
149:                    rv = StringUtil.split(id, "+");
150:                }
151:
152:                return rv;
153:            }
154:
155:            /**
156:             * {@inheritDoc}
157:             */
158:            public String packId(String[] ids) {
159:                if (ids == null || ids.length == 0) {
160:                    return null;
161:                }
162:
163:                if (ids.length == 1) {
164:                    return ids[0];
165:                }
166:
167:                StringBuffer sb = new StringBuffer();
168:                for (int i = 0; i < ids.length; i++) {
169:                    sb.append(ids[i]);
170:                    if (i < ids.length - 1) {
171:                        sb.append("+");
172:                    }
173:                }
174:                return sb.toString();
175:            }
176:
177:            /**
178:             * {@inheritDoc}
179:             */
180:            public String preferredRole(String one, String other) {
181:                // maintain is better than access
182:                if ("maintain".equals(one) || ("maintain".equals(other)))
183:                    return "maintain";
184:
185:                // access is better than nothing
186:                if ("access".equals(one) || ("access".equals(other)))
187:                    return "access";
188:
189:                // something we don't know, so we just return the latest role found
190:                return one;
191:            }
192:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.