Source Code Cross Referenced for ScarabSecurity.java in  » Issue-Tracking » scarab-0.21 » org » tigris » scarab » services » security » 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 » Issue Tracking » scarab 0.21 » org.tigris.scarab.services.security 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.tigris.scarab.services.security;
002:
003:        /* ================================================================
004:         * Copyright (c) 2001 Collab.Net.  All rights reserved.
005:         * 
006:         * Redistribution and use in source and binary forms, with or without
007:         * modification, are permitted provided that the following conditions are
008:         * met:
009:         * 
010:         * 1. Redistributions of source code must retain the above copyright
011:         * notice, this list of conditions and the following disclaimer.
012:         * 
013:         * 2. Redistributions in binary form must reproduce the above copyright
014:         * notice, this list of conditions and the following disclaimer in the
015:         * documentation and/or other materials provided with the distribution.
016:         * 
017:         * 3. The end-user documentation included with the redistribution, if
018:         * any, must include the following acknowlegement: "This product includes
019:         * software developed by Collab.Net <http://www.Collab.Net/>."
020:         * Alternately, this acknowlegement may appear in the software itself, if
021:         * and wherever such third-party acknowlegements normally appear.
022:         * 
023:         * 4. The hosted project names must not be used to endorse or promote
024:         * products derived from this software without prior written
025:         * permission. For written permission, please contact info@collab.net.
026:         * 
027:         * 5. Products derived from this software may not use the "Tigris" or 
028:         * "Scarab" names nor may "Tigris" or "Scarab" appear in their names without 
029:         * prior written permission of Collab.Net.
030:         * 
031:         * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
032:         * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
033:         * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
034:         * IN NO EVENT SHALL COLLAB.NET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
035:         * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
036:         * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
037:         * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
038:         * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
039:         * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
040:         * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
041:         * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
042:         *
043:         * ====================================================================
044:         * 
045:         * This software consists of voluntary contributions made by many
046:         * individuals on behalf of Collab.Net.
047:         */
048:
049:        import java.util.List;
050:        import java.util.ArrayList;
051:
052:        import org.apache.commons.configuration.Configuration;
053:        import org.apache.fulcrum.Service;
054:        import org.apache.fulcrum.BaseService;
055:        import org.apache.fulcrum.TurbineServices;
056:
057:        /**
058:         * This class provides access to security properties
059:         *
060:         * @author <a href="mailto:jmcnally@collab.net">John McNally</a>
061:         * @version $Id: ScarabSecurity.java 10023 2006-03-21 15:37:06Z jorgeuriarte $
062:         */
063:        public class ScarabSecurity extends BaseService implements  Service {
064:            /** The name of the service */
065:            public static final String SERVICE_NAME = "ScarabSecurity";
066:
067:            public static final String TOOL_KEY = "services.PullService.tool.request.security";
068:
069:            private static final String SCREEN_PREFIX = "screen.";
070:            private static final String ACTION_PREFIX = "action.";
071:
072:            protected static final String MAP_PREFIX = "map.";
073:
074:            /**
075:             * String used to indicate that an Action module does not require
076:             * a permission.
077:             */
078:            public static final String NONE = "None";
079:
080:            /** 
081:             * Specifies that a User is valid as an assignee for an issue.
082:             */
083:            public static final String ISSUE__EDIT = getService()
084:                    .getPermissionImpl("Issue__Edit");
085:
086:            /**
087:             * Specifies that a User is able to mark an issue as 'deleted'
088:             */
089:            public static final String ISSUE__DELETE = getService()
090:                    .getPermissionImpl("Issue__Delete");
091:
092:            /** 
093:             * Specifies that a User is allowed to enter an issue.
094:             */
095:            public static final String ISSUE__ENTER = getService()
096:                    .getPermissionImpl("Issue__Enter");
097:
098:            /** 
099:             * Specifies that a User is allowed to view an issue.
100:             */
101:            public static final String ISSUE__VIEW = getService()
102:                    .getPermissionImpl("Issue__View");
103:
104:            /** 
105:             * Specifies that a User is allowed to search for issues.
106:             */
107:            public static final String ISSUE__SEARCH = getService()
108:                    .getPermissionImpl("Issue__Search");
109:
110:            /** 
111:             * Specifies that a User is allowed to move or copy an issue.
112:             */
113:            public static final String ISSUE__MOVE = getService()
114:                    .getPermissionImpl("Issue__Move");
115:
116:            /** 
117:             * Specifies that a User is allowed to search for issues.
118:             */
119:            public static final String ISSUE__ATTACH = getService()
120:                    .getPermissionImpl("Issue__Attach");
121:
122:            /** 
123:             * Specifies that a User is allowed to add comments to issues.
124:             */
125:            public static final String ISSUE__COMMENT = getService()
126:                    .getPermissionImpl("Issue__Comment");
127:
128:            /** 
129:             * Specifies that a User is allowed to search for issues.
130:             */
131:            public static final String ISSUE__ASSIGN = getService()
132:                    .getPermissionImpl("Issue__Assign");
133:
134:            /** 
135:             * Specifies that a User is allowed to approve a query.
136:             */
137:            public static final String ITEM__APPROVE = getService()
138:                    .getPermissionImpl("Item__Approve");
139:
140:            /** 
141:             * Specifies that a User is allowed to delete a query.
142:             */
143:            public static final String ITEM__DELETE = getService()
144:                    .getPermissionImpl("Item__Delete");
145:
146:            /** 
147:             * Specifies that a User is allowed to edit preferences.
148:             */
149:            public static final String USER__EDIT_PREFERENCES = getService()
150:                    .getPermissionImpl("User__Edit_Preferences");
151:
152:            /** 
153:             * Specifies that a User is allowed to administer a domain.
154:             */
155:            public static final String DOMAIN__ADMIN = getService()
156:                    .getPermissionImpl("Domain__Admin");
157:
158:            /** 
159:             * Specifies that a User is allowed to edit a domain.
160:             */
161:            public static final String DOMAIN__EDIT = getService()
162:                    .getPermissionImpl("Domain__Edit");
163:
164:            /** 
165:             * Specifies that a User is allowed to modify a project.
166:             */
167:            public static final String MODULE__EDIT = getService()
168:                    .getPermissionImpl("Module__Edit");
169:
170:            /** 
171:             * Specifies that a User is allowed to configure a project.
172:             */
173:            public static final String MODULE__CONFIGURE = getService()
174:                    .getPermissionImpl("Module__Configure");
175:
176:            /** 
177:             * Specifies that a User is allowed to add a project.
178:             */
179:            public static final String MODULE__ADD = getService()
180:                    .getPermissionImpl("Module__Add");
181:
182:            /**
183:             * User with this permission is allowed to approve roles requested
184:             * by other users.
185:             */
186:            public static final String USER__APPROVE_ROLES = getService()
187:                    .getPermissionImpl("User__Approve_Roles");
188:
189:            /** 
190:             * Specifies that a User is allowed to set up voting policies.
191:             */
192:            public static final String VOTE__MANAGE = getService()
193:                    .getPermissionImpl("Vote__Manage");
194:
195:            /** 
196:             * Specifies that a User can change its password.
197:             * This permission is not stored in the database, and not
198:             * shown in GUI, but rather is managed by properties file.       
199:             */
200:            public static final String USER__CHANGE_PASSWORD = getService()
201:                    .getPermissionImpl("User__Change_Password");
202:
203:            private Configuration props;
204:            private List allPermissions;
205:
206:            public ScarabSecurity() {
207:            }
208:
209:            public void init() {
210:                props = getConfiguration();
211:                setInit(true);
212:            }
213:
214:            /**
215:             * Used in getAllPermissionsImpl to build the list
216:             */
217:            private void addPerm(List perms, String perm) {
218:                if (perm != null && perm.length() > 0 && !perms.contains(perm)) {
219:                    perms.add(perm);
220:                }
221:            }
222:
223:            protected List getAllPermissionsImpl() {
224:                if (allPermissions == null) {
225:                    List tmpPerms = new ArrayList();
226:                    addPerm(tmpPerms, ScarabSecurity.ISSUE__EDIT);
227:                    addPerm(tmpPerms, ScarabSecurity.ISSUE__ENTER);
228:                    addPerm(tmpPerms, ScarabSecurity.ISSUE__SEARCH);
229:                    addPerm(tmpPerms, ScarabSecurity.ISSUE__VIEW);
230:                    addPerm(tmpPerms, ScarabSecurity.ISSUE__ASSIGN);
231:                    addPerm(tmpPerms, ScarabSecurity.ISSUE__ATTACH);
232:                    addPerm(tmpPerms, ScarabSecurity.ISSUE__COMMENT);
233:                    addPerm(tmpPerms, ScarabSecurity.ISSUE__MOVE);
234:                    addPerm(tmpPerms, ScarabSecurity.ITEM__APPROVE);
235:                    addPerm(tmpPerms, ScarabSecurity.ITEM__DELETE);
236:                    addPerm(tmpPerms, ScarabSecurity.DOMAIN__ADMIN);
237:                    addPerm(tmpPerms, ScarabSecurity.DOMAIN__EDIT);
238:                    addPerm(tmpPerms, ScarabSecurity.MODULE__EDIT);
239:                    addPerm(tmpPerms, ScarabSecurity.MODULE__CONFIGURE);
240:                    addPerm(tmpPerms, ScarabSecurity.MODULE__ADD);
241:                    addPerm(tmpPerms, ScarabSecurity.USER__EDIT_PREFERENCES);
242:                    addPerm(tmpPerms, ScarabSecurity.USER__APPROVE_ROLES);
243:                    addPerm(tmpPerms, ScarabSecurity.VOTE__MANAGE);
244:                    allPermissions = tmpPerms;
245:                }
246:
247:                return allPermissions;
248:            }
249:
250:            protected String getScreenPermissionImpl(String screen) {
251:                String t = screen.replace(',', '.');
252:                return getPermissionImpl(props.getString(SCREEN_PREFIX + t,
253:                        null));
254:            }
255:
256:            protected String getActionPermissionImpl(String action) {
257:                String perm = null;
258:                String property = props.getString(ACTION_PREFIX + action);
259:                if (NONE.equals(property)) {
260:                    perm = NONE;
261:                } else {
262:                    perm = getPermissionImpl(property);
263:                }
264:                return perm;
265:            }
266:
267:            protected String getPermissionImpl(String permConstant) {
268:                return props.getString(MAP_PREFIX + permConstant, null);
269:            }
270:
271:            // *******************************************************************
272:            // static accessors
273:            // *******************************************************************
274:
275:            public static List getAllPermissions() {
276:                return getService().getAllPermissionsImpl();
277:            }
278:
279:            public static String getScreenPermission(String screen) {
280:                return getService().getScreenPermissionImpl(screen);
281:            }
282:
283:            public static String getActionPermission(String action) {
284:                return getService().getActionPermissionImpl(action);
285:            }
286:
287:            /**
288:             * Gets the <code>ScarabSecurity</code> implementation.
289:             *
290:             * @return the ScarabSecurity implementation.
291:             */
292:            protected static final ScarabSecurity getService() {
293:                return (ScarabSecurity) TurbineServices.getInstance()
294:                        .getService(ScarabSecurity.SERVICE_NAME);
295:            }
296:
297:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.