Source Code Cross Referenced for CmsDefaultUsers.java in  » Content-Management-System » opencms » org » opencms » db » 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 » Content Management System » opencms » org.opencms.db 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * File   : $Source: /usr/local/cvs/opencms/src/org/opencms/db/CmsDefaultUsers.java,v $
003:         * Date   : $Date: 2008-02-27 12:05:43 $
004:         * Version: $Revision: 1.35 $
005:         *
006:         * This library is part of OpenCms -
007:         * the Open Source Content Management System
008:         *
009:         * Copyright (c) 2002 - 2008 Alkacon Software GmbH (http://www.alkacon.com)
010:         *
011:         * This library is free software; you can redistribute it and/or
012:         * modify it under the terms of the GNU Lesser General Public
013:         * License as published by the Free Software Foundation; either
014:         * version 2.1 of the License, or (at your option) any later version.
015:         *
016:         * This library is distributed in the hope that it will be useful,
017:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
018:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019:         * Lesser General Public License for more details.
020:         *
021:         * For further information about Alkacon Software GmbH, please see the
022:         * company website: http://www.alkacon.com
023:         *
024:         * For further information about OpenCms, please see the
025:         * project website: http://www.opencms.org
026:         * 
027:         * You should have received a copy of the GNU Lesser General Public
028:         * License along with this library; if not, write to the Free Software
029:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
030:         */
031:
032:        package org.opencms.db;
033:
034:        import org.opencms.main.CmsRuntimeException;
035:        import org.opencms.security.CmsOrganizationalUnit;
036:        import org.opencms.util.CmsStringUtil;
037:
038:        /**
039:         * Provides access to the names of the OpenCms default users and groups.<p>
040:         * 
041:         * @author Alexander Kandzior 
042:         * @author Armen Markarian 
043:         * 
044:         * @version $Revision: 1.35 $
045:         * 
046:         * @since 6.0.0
047:         */
048:        public class CmsDefaultUsers {
049:
050:            /** Default name for the "Administrators" group. */
051:            protected static final String DEFAULT_GROUP_ADMINISTRATORS = "Administrators";
052:
053:            /** Default name for the "Guests" group. */
054:            protected static final String DEFAULT_GROUP_GUESTS = "Guests";
055:
056:            /** Default name for the "Projectmanagers" group. */
057:            protected static final String DEFAULT_GROUP_PROJECTMANAGERS = "Projectmanagers";
058:
059:            /** Default name for the "Users" group. */
060:            protected static final String DEFAULT_GROUP_USERS = "Users";
061:
062:            /** Default name for the "Admin" user. */
063:            protected static final String DEFAULT_USER_ADMIN = "Admin";
064:
065:            /** Default name for the "Deleted Resource" user. */
066:            protected static final String DEFAULT_USER_DELETED_RESOURCE = "Admin";
067:
068:            /** Default name for the "Export" user. */
069:            protected static final String DEFAULT_USER_EXPORT = "Export";
070:
071:            /** Default name for the "Guest" user. */
072:            protected static final String DEFAULT_USER_GUEST = "Guest";
073:
074:            /** Administrators group name. */
075:            private String m_groupAdministrators;
076:
077:            /** Guests group name. */
078:            private String m_groupGuests;
079:
080:            /** Project Managers group name. */
081:            private String m_groupProjectmanagers;
082:
083:            /** System Users group name. */
084:            private String m_groupUsers;
085:
086:            /** Administrator user name. */
087:            private String m_userAdmin;
088:
089:            /** Deleted resource user name. */
090:            private String m_userDeletedResource;
091:
092:            /** Export user name. */
093:            private String m_userExport;
094:
095:            /** Guest user name. */
096:            private String m_userGuest;
097:
098:            /**
099:             * Constructor that initializes all names with default values.<p>
100:             * 
101:             * See the constants of this class for the defaule values that are uses.<p> 
102:             */
103:            public CmsDefaultUsers() {
104:
105:                m_userAdmin = DEFAULT_USER_ADMIN;
106:                m_userGuest = DEFAULT_USER_GUEST;
107:                m_userExport = DEFAULT_USER_EXPORT;
108:                m_userDeletedResource = DEFAULT_USER_DELETED_RESOURCE;
109:                m_groupAdministrators = DEFAULT_GROUP_ADMINISTRATORS;
110:                m_groupProjectmanagers = DEFAULT_GROUP_PROJECTMANAGERS;
111:                m_groupUsers = DEFAULT_GROUP_USERS;
112:                m_groupGuests = DEFAULT_GROUP_GUESTS;
113:            }
114:
115:            /**
116:             * Public constructor. <p>
117:             * 
118:             * @param userAdmin the name of the default admin user
119:             * @param userGuest the name of the guest user
120:             * @param userExport the name of the export user
121:             * @param userDeletedResource the name of the deleted resource user, can be <code>null</code>
122:             * @param groupAdministrators the name of the administrators group
123:             * @param groupProjectmanagers the name of the project managers group
124:             * @param groupUsers the name of the users group
125:             * @param groupGuests the name of the guests group
126:             */
127:            public CmsDefaultUsers(String userAdmin, String userGuest,
128:                    String userExport, String userDeletedResource,
129:                    String groupAdministrators, String groupProjectmanagers,
130:                    String groupUsers, String groupGuests) {
131:
132:                init(userAdmin, userGuest, userExport, userDeletedResource,
133:                        groupAdministrators, groupProjectmanagers, groupUsers,
134:                        groupGuests);
135:            }
136:
137:            /**
138:             * Returns the name of the administrators group.<p>
139:             * 
140:             * @return the name of the administrators group
141:             */
142:            public String getGroupAdministrators() {
143:
144:                return m_groupAdministrators;
145:            }
146:
147:            /**
148:             * Returns the name of the guests group.<p>
149:             * 
150:             * @return the name of the guests group
151:             */
152:            public String getGroupGuests() {
153:
154:                return m_groupGuests;
155:            }
156:
157:            /**
158:             * Returns the name of the project managers group.<p>
159:             * 
160:             * @return the name of the project managers group
161:             */
162:            public String getGroupProjectmanagers() {
163:
164:                return m_groupProjectmanagers;
165:            }
166:
167:            /**
168:             * Returns the name of the users group.<p>
169:             * 
170:             * @return the name of the users group
171:             */
172:            public String getGroupUsers() {
173:
174:                return m_groupUsers;
175:            }
176:
177:            /**
178:             * Returns the name of the default administrator user.<p>
179:             * 
180:             * @return the name of the default administrator user
181:             */
182:            public String getUserAdmin() {
183:
184:                return m_userAdmin;
185:            }
186:
187:            /**
188:             * Returns the name of the default deleted resource user.<p>
189:             * 
190:             * @return the name of the default deleted resource user
191:             */
192:            public String getUserDeletedResource() {
193:
194:                return m_userDeletedResource;
195:            }
196:
197:            /**
198:             * Returns the name of the user used to generate the static export.<p>
199:             * 
200:             * @return the name of the user used to generate the static export
201:             */
202:            public String getUserExport() {
203:
204:                return m_userExport;
205:            }
206:
207:            /**
208:             * Returns the name of the default guest user.<p>
209:             * 
210:             * @return the name of the default guest user
211:             */
212:            public String getUserGuest() {
213:
214:                return m_userGuest;
215:            }
216:
217:            /**
218:             * Checks if a given group name is the name of one of the OpenCms default groups.<p>
219:             *
220:             * @param groupName the group name to check
221:             * @return <code>true</code> if group name is one of OpenCms default groups, <code>false</code> if it is not
222:             * or if <code>groupName</code> is <code>null</code> or an empty string (no trim)
223:             * 
224:             * @see #getGroupAdministrators()
225:             * @see #getGroupProjectmanagers()
226:             * @see #getGroupUsers()
227:             * @see #getGroupGuests()
228:             */
229:            public boolean isDefaultGroup(String groupName) {
230:
231:                if (CmsStringUtil.isEmptyOrWhitespaceOnly(groupName)) {
232:                    return false;
233:                }
234:
235:                // first check without ou prefix, to stay backwards compatible
236:                boolean isDefault = m_groupAdministrators.equals(groupName);
237:                isDefault = isDefault || m_groupGuests.equals(groupName);
238:                isDefault = isDefault
239:                        || m_groupProjectmanagers.equals(groupName);
240:                isDefault = isDefault || m_groupUsers.equals(groupName);
241:
242:                // now check with ou prefix
243:                isDefault = isDefault
244:                        || groupName.endsWith(CmsOrganizationalUnit.SEPARATOR
245:                                + m_groupAdministrators);
246:                isDefault = isDefault
247:                        || groupName.endsWith(CmsOrganizationalUnit.SEPARATOR
248:                                + m_groupGuests);
249:                isDefault = isDefault
250:                        || groupName.endsWith(CmsOrganizationalUnit.SEPARATOR
251:                                + m_groupProjectmanagers);
252:                isDefault = isDefault
253:                        || groupName.endsWith(CmsOrganizationalUnit.SEPARATOR
254:                                + m_groupUsers);
255:
256:                return isDefault;
257:            }
258:
259:            /**
260:             * Checks if a given user name is the name of one of the OpenCms default users.<p>
261:             *
262:             * @param userName the group name to check
263:             * 
264:             * @return <code>true</code> if user name is one of OpenCms default users, <code>false</code> if it is not
265:             * or if <code>userName</code> is <code>null</code> or an empty string (no trim)
266:             * 
267:             * @see #getUserAdmin()
268:             * @see #getUserExport()
269:             * @see #getUserGuest()
270:             * @see #getUserDeletedResource()
271:             */
272:            public boolean isDefaultUser(String userName) {
273:
274:                if (CmsStringUtil.isEmptyOrWhitespaceOnly(userName)) {
275:                    return false;
276:                }
277:
278:                // first check without ou prefix, to stay backwards compatible
279:                boolean isDefault = m_userAdmin.equals(userName);
280:                isDefault = isDefault || m_userGuest.equals(userName);
281:                isDefault = isDefault || m_userExport.equals(userName);
282:                isDefault = isDefault || m_userDeletedResource.equals(userName);
283:
284:                // now check with ou prefix
285:                isDefault = isDefault
286:                        || userName.equals(CmsOrganizationalUnit.SEPARATOR
287:                                + m_userAdmin);
288:                isDefault = isDefault
289:                        || userName.equals(CmsOrganizationalUnit.SEPARATOR
290:                                + m_userGuest);
291:                isDefault = isDefault
292:                        || userName.equals(CmsOrganizationalUnit.SEPARATOR
293:                                + m_userExport);
294:                isDefault = isDefault
295:                        || userName.equals(CmsOrganizationalUnit.SEPARATOR
296:                                + m_userDeletedResource);
297:
298:                return isDefault;
299:            }
300:
301:            /**
302:             * Checks if a given group name is the name of the guests group.<p>
303:             * 
304:             * @param groupName the group name to check
305:             * 
306:             * @return <code>true</code> if a given group name is the name of the guests group
307:             */
308:            public boolean isGroupGuests(String groupName) {
309:
310:                if (CmsStringUtil.isEmptyOrWhitespaceOnly(groupName)) {
311:                    return false;
312:                }
313:                return m_groupGuests.equals(groupName)
314:                        || groupName.endsWith(CmsOrganizationalUnit.SEPARATOR
315:                                + m_groupGuests);
316:            }
317:
318:            /**
319:             * Checks if a given user name is the name of the admin user.<p>
320:             * 
321:             * @param userName the user name to check
322:             * 
323:             * @return <code>true</code> if a given user name is the name of the admin user
324:             */
325:            public boolean isUserAdmin(String userName) {
326:
327:                if (CmsStringUtil.isEmptyOrWhitespaceOnly(userName)) {
328:                    return false;
329:                }
330:                return m_userAdmin.equals(userName);
331:            }
332:
333:            /**
334:             * Checks if a given user name is the name of the export user.<p>
335:             * 
336:             * @param userName the user name to check
337:             * 
338:             * @return <code>true</code> if a given user name is the name of the export user
339:             */
340:            public boolean isUserExport(String userName) {
341:
342:                if (CmsStringUtil.isEmptyOrWhitespaceOnly(userName)) {
343:                    return false;
344:                }
345:                return m_userExport.equals(userName);
346:            }
347:
348:            /**
349:             * Checks if a given user name is the name of the guest user.<p>
350:             * 
351:             * @param userName the user name to check
352:             * 
353:             * @return <code>true</code> if a given user name is the name of the guest user
354:             */
355:            public boolean isUserGuest(String userName) {
356:
357:                if (CmsStringUtil.isEmptyOrWhitespaceOnly(userName)) {
358:                    return false;
359:                }
360:                return m_userGuest.equals(userName);
361:            }
362:
363:            /**
364:             * Initializes this instance.<p>
365:             * 
366:             * @param userAdmin the name of the default admin user
367:             * @param userGuest the name of the guest user
368:             * @param userExport the name of the export user
369:             * @param userDeletedResource the name of the deleted resource user, can be <code>null</code>
370:             * @param groupAdministrators the name of the administrators group
371:             * @param groupProjectmanagers the name of the project managers group
372:             * @param groupUsers the name of the users group
373:             * @param groupGuests the name of the guests group
374:             */
375:            protected void init(String userAdmin, String userGuest,
376:                    String userExport, String userDeletedResource,
377:                    String groupAdministrators, String groupProjectmanagers,
378:                    String groupUsers, String groupGuests) {
379:
380:                // check if all required user and group names are not null or empty
381:                if (CmsStringUtil.isEmptyOrWhitespaceOnly(userAdmin)
382:                        || CmsStringUtil.isEmptyOrWhitespaceOnly(userGuest)
383:                        || CmsStringUtil.isEmptyOrWhitespaceOnly(userExport)
384:                        || CmsStringUtil
385:                                .isEmptyOrWhitespaceOnly(groupAdministrators)
386:                        || CmsStringUtil
387:                                .isEmptyOrWhitespaceOnly(groupProjectmanagers)
388:                        || CmsStringUtil.isEmptyOrWhitespaceOnly(groupUsers)
389:                        || CmsStringUtil.isEmptyOrWhitespaceOnly(groupGuests)) {
390:                    throw new CmsRuntimeException(Messages.get().container(
391:                            Messages.ERR_USER_GROUP_NAMES_EMPTY_0));
392:                }
393:                // set members
394:                m_userAdmin = userAdmin.trim();
395:                m_userGuest = userGuest.trim();
396:                m_userExport = userExport.trim();
397:                if (CmsStringUtil.isEmptyOrWhitespaceOnly(userDeletedResource)) {
398:                    m_userDeletedResource = userAdmin;
399:                } else {
400:                    m_userDeletedResource = userDeletedResource.trim();
401:                }
402:                m_groupAdministrators = groupAdministrators.trim();
403:                m_groupProjectmanagers = groupProjectmanagers.trim();
404:                m_groupUsers = groupUsers.trim();
405:                m_groupGuests = groupGuests.trim();
406:            }
407:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.