Source Code Cross Referenced for AuthorizationBean.java in  » ERP-CRM-Financial » sakai » org » sakaiproject » tool » assessment » ui » bean » authz » 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.tool.assessment.ui.bean.authz 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**********************************************************************************
002:         * $URL: https://source.sakaiproject.org/svn/sam/tags/sakai_2-4-1/samigo-app/src/java/org/sakaiproject/tool/assessment/ui/bean/authz/AuthorizationBean.java $
003:         * $Id: AuthorizationBean.java 16922 2006-10-09 21:56:09Z ktsao@stanford.edu $
004:         ***********************************************************************************
005:         *
006:         * Copyright (c) 2004, 2005, 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.tool.assessment.ui.bean.authz;
021:
022:        import org.sakaiproject.tool.assessment.facade.AgentFacade;
023:        import org.sakaiproject.tool.assessment.services.PersistenceService;
024:        import org.sakaiproject.tool.assessment.ui.listener.util.ContextUtil; //import org.sakaiproject.spring.SpringBeanLocator;
025:        import java.io.Serializable;
026:        import java.util.HashMap;
027:        import javax.servlet.http.HttpServletRequest; //import javax.servlet.http.HttpServletResponse;
028:        import org.apache.commons.logging.Log;
029:        import org.apache.commons.logging.LogFactory;
030:
031:        public class AuthorizationBean implements  Serializable {
032:            /**
033:             * 
034:             */
035:            private static final long serialVersionUID = -2782949557257727817L;
036:
037:            private static Log log = LogFactory.getLog(AuthorizationBean.class);
038:
039:            private HashMap map = new HashMap();
040:            private boolean adminPrivilege = false;
041:            private boolean adminNewAssessmentPrivilege = false;
042:            private boolean adminCoreAssessmentPrivilege = false;
043:            private boolean adminPublishedAssessmentPrivilege = false;
044:            private boolean adminAssessmentPrivilege = false;
045:            private boolean adminTemplatePrivilege = false;
046:            private boolean adminQuestionPoolPrivilege = false;
047:
048:            public AuthorizationBean() {
049:            }
050:
051:            public HashMap getAuthzMap() {
052:                return map;
053:            }
054:
055:            public boolean getAdminPrivilege() {
056:                return getPrivilege("admin_privilege");
057:            }
058:
059:            public boolean getAdminNewAssessment() {
060:                return getPrivilege("admin_new_assessment");
061:            }
062:
063:            public boolean getAdminCoreAssessment() {
064:                return getPrivilege("admin_core_assessment");
065:            }
066:
067:            public boolean getAdminPublishedAssessment() {
068:                return getPrivilege("admin_published_assessment");
069:            }
070:
071:            public boolean getAdminAssessment() {
072:                return getPrivilege("admin_assessment");
073:            }
074:
075:            public boolean getAdminTemplate() {
076:                return getPrivilege("admin_template");
077:            }
078:
079:            public boolean getAdminQuestionPool() {
080:                return getPrivilege("admin_questionpool");
081:            }
082:
083:            // This method is called (via jsf/security/roleCheckStaticInclude.jsp)
084:            // when user first enter samigo in a site.
085:            // This is the time when we determine his permission in the site.
086:            // This info is stored in the AuthorizationService HashMap for the entire session.
087:            public void addAllPrivilege(String siteId) {
088:                // admin functions
089:                boolean p1 = canCreateAssessment(siteId);
090:                boolean p2 = canEditAnyAssessment(siteId);
091:                boolean p3 = canEditOwnAssessment(siteId);
092:                boolean p4 = canDeleteAnyAssessment(siteId);
093:                boolean p5 = canDeleteOwnAssessment(siteId);
094:                boolean p6 = canPublishAnyAssessment(siteId);
095:                boolean p7 = canPublishOwnAssessment(siteId);
096:                boolean p8 = canGradeAnyAssessment(siteId);
097:                boolean p9 = canGradeOwnAssessment(siteId);
098:                boolean p10 = canCreateQuestionPool(siteId);
099:                boolean p11 = canEditOwnQuestionPool(siteId);
100:                boolean p12 = canDeleteOwnQuestionPool(siteId);
101:                boolean p13 = canCopyOwnQuestionPool(siteId);
102:                boolean p14 = canCreateTemplate(siteId);
103:                boolean p15 = canEditOwnTemplate(siteId);
104:                boolean p16 = canDeleteOwnTemplate(siteId);
105:
106:                // non admin functions
107:                canTakeAssessment(siteId);
108:                canSubmitAssessmentForGrade(siteId);
109:
110:                // set adminPrivilege
111:                adminNewAssessmentPrivilege = p1;
112:                addAdminPrivilege(adminNewAssessmentPrivilege,
113:                        "admin_new_assessment", siteId);
114:
115:                adminCoreAssessmentPrivilege = p2 || p3 || p4 || p5 || p6 || p7;
116:                addAdminPrivilege(adminCoreAssessmentPrivilege,
117:                        "admin_core_assessment", siteId);
118:
119:                adminPublishedAssessmentPrivilege = p8 || p9;
120:                addAdminPrivilege(adminPublishedAssessmentPrivilege,
121:                        "admin_published_assessment", siteId);
122:
123:                adminAssessmentPrivilege = p1 || p2 || p3 || p4 || p5 || p6
124:                        || p7 || p8 || p9;
125:                addAdminPrivilege(adminAssessmentPrivilege, "admin_assessment",
126:                        siteId);
127:
128:                adminQuestionPoolPrivilege = p10 || p11 || p12 || p13;
129:                addAdminPrivilege(adminQuestionPoolPrivilege,
130:                        "admin_questionpool", siteId);
131:
132:                adminTemplatePrivilege = p14 || p15 || p16;
133:                addAdminPrivilege(adminTemplatePrivilege, "admin_template",
134:                        siteId);
135:
136:                adminPrivilege = adminAssessmentPrivilege
137:                        || adminQuestionPoolPrivilege || adminTemplatePrivilege;
138:                addAdminPrivilege(adminPrivilege, "admin_privilege", siteId);
139:            }
140:
141:            public boolean canTakeAssessment(String siteId) {
142:                return addPrivilege("take_assessment", siteId);
143:            }
144:
145:            public boolean canSubmitAssessmentForGrade(String siteId) {
146:                return addPrivilege("submit_assessment_for_grade", siteId);
147:            }
148:
149:            public boolean canCreateAssessment(String siteId) {
150:                return addPrivilege("create_assessment", siteId);
151:            }
152:
153:            public boolean canEditAnyAssessment(String siteId) {
154:                return addPrivilege("edit_any_assessment", siteId);
155:            }
156:
157:            public boolean canEditOwnAssessment(String siteId) {
158:                return addPrivilege("edit_own_assessment", siteId);
159:            }
160:
161:            public boolean canDeleteAnyAssessment(String siteId) {
162:                return addPrivilege("delete_any_assessment", siteId);
163:            }
164:
165:            public boolean canDeleteOwnAssessment(String siteId) {
166:                return addPrivilege("delete_own_assessment", siteId);
167:            }
168:
169:            public boolean canPublishAnyAssessment(String siteId) {
170:                return addPrivilege("publish_any_assessment", siteId);
171:            }
172:
173:            public boolean canPublishOwnAssessment(String siteId) {
174:                return addPrivilege("publish_own_assessment", siteId);
175:            }
176:
177:            public boolean canGradeAnyAssessment(String siteId) {
178:                return addPrivilege("grade_any_assessment", siteId);
179:            }
180:
181:            public boolean canGradeOwnAssessment(String siteId) {
182:                return addPrivilege("grade_own_assessment", siteId);
183:            }
184:
185:            public boolean canCreateQuestionPool(String siteId) {
186:                return addPrivilege("create_questionpool", siteId);
187:            }
188:
189:            public boolean canEditOwnQuestionPool(String siteId) {
190:                return addPrivilege("edit_own_questionpool", siteId);
191:            }
192:
193:            public boolean canDeleteOwnQuestionPool(String siteId) {
194:                return addPrivilege("delete_own_questionpool", siteId);
195:            }
196:
197:            public boolean canCopyOwnQuestionPool(String siteId) {
198:                return addPrivilege("copy_own_questionpool", siteId);
199:            }
200:
201:            public boolean canCreateTemplate(String siteId) {
202:                return addPrivilege("create_template", siteId);
203:            }
204:
205:            public boolean canEditOwnTemplate(String siteId) {
206:                return addPrivilege("edit_own_template", siteId);
207:            }
208:
209:            public boolean canDeleteOwnTemplate(String siteId) {
210:                return addPrivilege("delete_own_template", siteId);
211:            }
212:
213:            public boolean addPrivilege(String functionKey, String siteId) {
214:                String functionName = (String) ContextUtil
215:                        .getLocalizedString(
216:                                "org.sakaiproject.tool.assessment.bundle.AuthzPermissions",
217:                                functionKey);
218:                boolean privilege = PersistenceService.getInstance()
219:                        .getAuthzQueriesFacade().hasPrivilege(functionName);
220:                map
221:                        .put(functionName + "_" + siteId, Boolean
222:                                .valueOf(privilege));
223:                //log.debug(functionName+"_"+siteId+"="+privilege);
224:                return privilege;
225:            }
226:
227:            public void addAdminPrivilege(boolean privilege,
228:                    String functionKey, String siteId) {
229:                String functionName = (String) ContextUtil
230:                        .getLocalizedString(
231:                                "org.sakaiproject.tool.assessment.bundle.AuthzPermissions",
232:                                functionKey);
233:                map
234:                        .put(functionName + "_" + siteId, Boolean
235:                                .valueOf(privilege));
236:                //log.debug(functionName+"_"+siteId+"="+privilege);
237:            }
238:
239:            public boolean getTakeAssessment() {
240:                return getPrivilege("take_assessment");
241:            }
242:
243:            public boolean getSubmitAssessmentForGrade() {
244:                return getPrivilege("submit_assessment_for_grade");
245:            }
246:
247:            public boolean getCreateAssessment() {
248:                return getPrivilege("create_assessment");
249:            }
250:
251:            public boolean getEditAnyAssessment() {
252:                return getPrivilege("edit_any_assessment");
253:            }
254:
255:            public boolean getEditOwnAssessment() {
256:                return getPrivilege("edit_own_assessment");
257:            }
258:
259:            public boolean getDeleteAnyAssessment() {
260:                return getPrivilege("delete_any_assessment");
261:            }
262:
263:            public boolean getDeleteOwnAssessment() {
264:                return getPrivilege("delete_own_assessment");
265:            }
266:
267:            public boolean getPublishAnyAssessment() {
268:                return getPrivilege("publish_any_assessment");
269:            }
270:
271:            public boolean getPublishOwnAssessment() {
272:                return getPrivilege("publish_own_assessment");
273:            }
274:
275:            public boolean getGradeAnyAssessment() {
276:                return getPrivilege("grade_any_assessment");
277:            }
278:
279:            public boolean getGradeOwnAssessment() {
280:                return getPrivilege("grade_own_assessment");
281:            }
282:
283:            public boolean getCreateQuestionPool() {
284:                return getPrivilege("create_questionpool");
285:            }
286:
287:            public boolean getEditOwnQuestionPool() {
288:                return getPrivilege("edit_own_questionpool");
289:            }
290:
291:            public boolean getDeleteOwnQuestionPool() {
292:                return getPrivilege("delete_own_questionpool");
293:            }
294:
295:            public boolean getCopyOwnQuestionPool() {
296:                return getPrivilege("copy_own_questionpool");
297:            }
298:
299:            public boolean getCreateTemplate() {
300:                return getPrivilege("create_template");
301:            }
302:
303:            public boolean getEditOwnTemplate() {
304:                return getPrivilege("edit_own_template");
305:            }
306:
307:            public boolean getDeleteOwnTemplate() {
308:                return getPrivilege("delete_own_template");
309:            }
310:
311:            public boolean getPrivilege(String functionKey) {
312:                String siteId = AgentFacade.getCurrentSiteId();
313:                String functionName = (String) ContextUtil
314:                        .getLocalizedString(
315:                                "org.sakaiproject.tool.assessment.bundle.AuthzPermissions",
316:                                functionKey);
317:                boolean privilege = false;
318:                Object o = map.get(functionName + "_" + siteId);
319:                if (o != null)
320:                    privilege = ((Boolean) o).booleanValue();
321:                //log.debug("**** authzBean:"+functionName+"_"+siteId+"="+privilege);
322:                return privilege;
323:            }
324:
325:            // added the follwoing for ShowMediaServlet
326:            public boolean getGradeAnyAssessment(HttpServletRequest req,
327:                    String siteId) {
328:                return getPrivilege(req, "grade_any_assessment", siteId);
329:            }
330:
331:            public boolean getGradeOwnAssessment(HttpServletRequest req,
332:                    String siteId) {
333:                return getPrivilege(req, "grade_own_assessment", siteId);
334:            }
335:
336:            public boolean getPrivilege(HttpServletRequest req,
337:                    String functionKey, String siteId) {
338:                String functionName = (String) ContextUtil
339:                        .getLocalizedString(
340:                                req,
341:                                "org.sakaiproject.tool.assessment.bundle.AuthzPermissions",
342:                                functionKey);
343:                boolean privilege = false;
344:                Object o = map.get(functionName + "_" + siteId);
345:                if (o != null)
346:                    privilege = ((Boolean) o).booleanValue();
347:                return privilege;
348:            }
349:
350:        }
ww___w___.___j___a__v__a__2___s_.__c_om___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.