Source Code Cross Referenced for UserDO.java in  » Groupware » ivatagroupware » com » ivata » groupware » admin » security » user » 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 » Groupware » ivatagroupware » com.ivata.groupware.admin.security.user 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2001 - 2005 ivata limited.
003:         * All rights reserved.
004:         * -----------------------------------------------------------------------------
005:         * ivata groupware may be redistributed under the GNU General Public
006:         * License as published by the Free Software Foundation;
007:         * version 2 of the License.
008:         *
009:         * These programs are free software; you can redistribute them and/or
010:         * modify them under the terms of the GNU General Public License
011:         * as published by the Free Software Foundation; version 2 of the License.
012:         *
013:         * These programs are distributed in the hope that they will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016:         *
017:         * See the GNU General Public License in the file LICENSE.txt for more
018:         * details.
019:         *
020:         * If you would like a copy of the GNU General Public License write to
021:         *
022:         * Free Software Foundation, Inc.
023:         * 59 Temple Place - Suite 330
024:         * Boston, MA 02111-1307, USA.
025:         *
026:         *
027:         * To arrange commercial support and licensing, contact ivata at
028:         *                  http://www.ivata.com/contact.jsp
029:         * -----------------------------------------------------------------------------
030:         * $Log: UserDO.java,v $
031:         * Revision 1.9  2005/10/14 14:31:39  colinmacleod
032:         * Fixed bug in isMember - was only working for everyone group!
033:         * Fixed some javadoc issues.
034:         *
035:         * Revision 1.8  2005/10/03 10:21:14  colinmacleod
036:         * Fixed some style and javadoc issues.
037:         *
038:         * Revision 1.7  2005/10/02 14:08:58  colinmacleod
039:         * Added/improved log4j logging.
040:         *
041:         * Revision 1.6  2005/09/29 13:22:47  colinmacleod
042:         * Added read-only functionality to data object classes (with a check on each
043:         * setter).
044:         *
045:         * Revision 1.5  2005/09/14 16:10:22  colinmacleod
046:         * Removed unused local and class variables.
047:         * Added serialVersionUID.
048:         *
049:         * Revision 1.4  2005/04/29 02:48:20  colinmacleod
050:         * Data bugfixes.
051:         * Changed primary key back to Integer.
052:         *
053:         * Revision 1.3  2005/04/10 20:09:48  colinmacleod
054:         * Added new themes.
055:         * Changed id type to String.
056:         * Changed i tag to em and b tag to strong.
057:         * Improved PicoContainerFactory with NanoContainer scripts.
058:         *
059:         * Revision 1.2  2005/04/09 17:19:57  colinmacleod
060:         * Changed copyright text to GPL v2 explicitly.
061:         *
062:         * Revision 1.1.1.1  2005/03/10 17:51:42  colinmacleod
063:         * Restructured ivata op around Hibernate/PicoContainer.
064:         * Renamed ivata groupware.
065:         *
066:         * Revision 1.3  2004/12/31 19:28:04  colinmacleod
067:         * Added override for displayValue.
068:         *
069:         * Revision 1.2  2004/11/03 16:10:10  colinmacleod
070:         * Changed todo comments to TODO: all caps.
071:         *
072:         * Revision 1.1  2004/09/30 15:15:59  colinmacleod
073:         * Split off addressbook elements into security subproject.
074:         *
075:         * Revision 1.2  2004/07/18 21:56:17  colinmacleod
076:         * Removed person. This is a one-way relationship to make it faster.
077:         *
078:         * Revision 1.1  2004/07/13 19:15:26  colinmacleod
079:         * Moved from business.addressbook to admin.security.
080:         *
081:         * Revision 1.3  2004/03/21 21:16:07  colinmacleod
082:         * Shortened name to ivata op.
083:         *
084:         * Revision 1.2  2004/02/01 22:00:32  colinmacleod
085:         * Added full names to author tags
086:         *
087:         * Revision 1.1.1.1  2004/01/27 20:57:52  colinmacleod
088:         * Moved ivata openportal to SourceForge..
089:         *
090:         * Revision 1.8  2003/12/12 11:08:58  jano
091:         * fixing aaddressbook functionaality
092:         *
093:         * Revision 1.7  2003/11/13 16:03:16  jano
094:         * commitng everything to CVS
095:         * can deploy and application is ruuning, can login into
096:         *
097:         * Revision 1.6  2003/11/03 11:28:24  jano
098:         * commiting addressbook,
099:         * tryinjg to fix deploying problem
100:         *
101:         * Revision 1.5  2003/10/17 12:36:12  jano
102:         * fixing problems with building
103:         * converting intranet -> portal
104:         * Eclipse building
105:         *
106:         * Revision 1.4  2003/10/16 06:17:06  jano
107:         * fixing comments
108:         *
109:         * Revision 1.3  2003/10/15 13:41:12  jano
110:         * converting to XDoclet
111:         *
112:         * Revision 1.2  2003/10/15 13:18:02  colin
113:         * fixing for XDoclet
114:         *
115:         * Revision 1.6  2003/09/11 13:10:48  jano
116:         * fixing bugs with ranaming userName and with removing user from system
117:         *
118:         * Revision 1.5  2003/07/25 11:41:57  jano
119:         * adding functionality for addressBook extension
120:         *
121:         * Revision 1.4  2003/05/01 12:13:22  jano
122:         * tidy up names of sequeneces
123:         *
124:         * Revision 1.3  2003/04/09 08:52:14  jano
125:         * handling data of removing user
126:         *
127:         * Revision 1.2  2003/02/25 14:38:13  colin
128:         * implemented setModified methods on entity beans thro IvataEntityBean
129:         * superclass
130:         *
131:         * Revision 1.1  2003/02/24 19:09:21  colin
132:         * moved to business
133:         *
134:         * Revision 1.11  2003/02/04 17:43:45  colin
135:         * copyright notice
136:         *
137:         * Revision 1.10  2003/01/09 13:32:51  jano
138:         * I remove relationShip between user and Event
139:         *
140:         * Revision 1.9  2002/10/22 10:46:13  colin
141:         * resurrected LibraryItemRight to fix problems when deleting library items
142:         *
143:         * Revision 1.8  2002/10/03 12:34:16  colin
144:         * Removed LibraryItemRightBean - replaced with CMR on User
145:         *
146:         * Revision 1.7  2002/09/02 08:56:10  colin
147:         * events relationship (dont know where it came from)
148:         *
149:         * Revision 1.6  2002/07/26 14:42:22  colin
150:         * added a person CMR to the user
151:         *
152:         * Revision 1.5  2002/07/15 08:16:07  colin
153:         * added person to create
154:         *
155:         * Revision 1.4  2002/07/04 12:29:28  jano
156:         * i put readonly script to CVS and i will commit all SRC directory
157:         *
158:         * Revision 1.3  2002/06/28 13:15:23  colin
159:         * first addressbook release
160:         *
161:         * Revision 1.2  2002/06/17 07:28:52  colin
162:         * improved and extended javadoc documentation
163:         * -----------------------------------------------------------------------------
164:         */
165:        package com.ivata.groupware.admin.security.user;
166:
167:        import java.util.HashSet;
168:        import java.util.Iterator;
169:        import java.util.Set;
170:
171:        import org.apache.log4j.Logger;
172:
173:        import com.ivata.groupware.admin.security.user.group.UserGroupConstants;
174:        import com.ivata.groupware.admin.security.user.group.UserGroupDO;
175:        import com.ivata.groupware.container.persistence.BaseDO;
176:        import com.ivata.groupware.container.persistence.NamedDO;
177:
178:        /**
179:         * <p>Each user within the system has a user name, and activation information
180:         * such as a password. This class maintains this information.</p>
181:         *
182:         * @since 2002-05-05
183:         * @author Colin MacLeod
184:         * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
185:         * @version $Revision: 1.9 $
186:         *
187:         * @hibernate.class
188:         *      table="person_user"
189:         * @hibernate.cache
190:         *      usage="read-write"
191:         */
192:        public class UserDO extends BaseDO implements  NamedDO {
193:            /**
194:             * Logger for this class.
195:             */
196:            private static final Logger logger = Logger.getLogger(UserDO.class);
197:
198:            /**
199:             * Serialization version (for <code>Serializable</code> interface).
200:             */
201:            private static final long serialVersionUID = 1L;
202:            /**
203:             * <p><code>true</code> if user was deleted, and created some data in system
204:             * which we don't want to remove.</p>
205:             */
206:            private boolean deleted;
207:
208:            /**
209:             * Clear-text notes about this user. Useful to explain that the default
210:             * administrator will always be an administrator.
211:             */
212:            private String description;
213:
214:            /**
215:             * <p>Find out if a user is enabled or disabled.</p>
216:             */
217:            private boolean enabled;
218:
219:            /**
220:             * <p>Each user is a member of several groups. By default, each user is a
221:             * member of the group called "everyOne" </p>
222:             */
223:            private Set groups = new HashSet();
224:
225:            /**
226:             * <p>The user name. This name must uniquely identify the user
227:             * within the system, and should only contain alphanumeric characters.</p>
228:             */
229:            private String name;
230:
231:            /**
232:             * <p>The user's password, if the authentication is not done through the
233:             * <code>IMAP</code> webmail interface.</p>
234:             */
235:            private String password;
236:
237:            /**
238:             * Clear-text notes about this user. Useful to explain that the default
239:             * administrator will always be an administrator.
240:             *
241:             * @return Clear text description of the user's purpose in life.
242:             * @hibernate.property
243:             */
244:            public String getDescription() {
245:                if (logger.isDebugEnabled()) {
246:                    logger.debug("getDescription() - start");
247:                }
248:
249:                if (logger.isDebugEnabled()) {
250:                    logger.debug("getDescription() - end - return value = "
251:                            + description);
252:                }
253:                return description;
254:            }
255:
256:            /**
257:             * <p>If the user is deleted we will make new name.</p>
258:             * @return userName
259:             */
260:            public final String getDisplayName() {
261:                if (logger.isDebugEnabled()) {
262:                    logger.debug("getDisplayName() - start");
263:                }
264:
265:                if (isDeleted()) {
266:                    String returnString = this .getName() + " (deleted)";
267:                    if (logger.isDebugEnabled()) {
268:                        logger.debug("getDisplayName() - end - return value = "
269:                                + returnString);
270:                    }
271:                    return returnString;
272:                } else {
273:                    String returnString = this .getName();
274:                    if (logger.isDebugEnabled()) {
275:                        logger.debug("getDisplayName() - end - return value = "
276:                                + returnString);
277:                    }
278:                    return returnString;
279:                }
280:            }
281:
282:            /**
283:             * <p>
284:             * For a user, the value displayed in a choice box is just the user name.
285:             * </p>
286:             *
287:             * @see com.ivata.mask.valueobject.ValueObject#getDisplayValue()
288:             */
289:            public final String getDisplayValue() {
290:                if (logger.isDebugEnabled()) {
291:                    logger.debug("getDisplayValue() - start");
292:                }
293:
294:                if (logger.isDebugEnabled()) {
295:                    logger.debug("getDisplayValue() - end - return value = "
296:                            + name);
297:                }
298:                return name;
299:            }
300:
301:            /**
302:             * <p>Each user is a member of several groups. By default, each user is a
303:             * member of the group called "everyOne" </p>
304:             *
305:             * @return All the groups this user is a member of, as a <code>List</code>
306:             * of {@link UserGroupDO} instances.
307:             *
308:             * @hibernate.set
309:             *      role="user_group"
310:             *      table="user_group_member"
311:             * @hibernate.collection-key
312:             *      column="person_user"
313:             * @hibernate.collection-many-to-many
314:             *      class="com.ivata.groupware.admin.security.user.group.UserGroupDO"
315:             *      column="user_group"
316:             */
317:            public final Set getGroups() {
318:                if (logger.isDebugEnabled()) {
319:                    logger.debug("getGroups() - start");
320:                }
321:
322:                if (logger.isDebugEnabled()) {
323:                    logger
324:                            .debug("getGroups() - end - return value = "
325:                                    + groups);
326:                }
327:                return groups;
328:            }
329:
330:            /**
331:             * <p>
332:             * Unique identifier of this data object.
333:             * </p>
334:             *
335:             * NOTE: this is a hibernate one-to-one relationship with person, so we
336:             *       need no generator here...
337:             * @return {@inheritDoc}
338:             * @hibernate.id
339:             *      generator-class = "assigned"
340:             */
341:            public final Integer getId() {
342:                if (logger.isDebugEnabled()) {
343:                    logger.debug("getId() - start");
344:                }
345:
346:                Integer returnInteger = super .getId();
347:                if (logger.isDebugEnabled()) {
348:                    logger.debug("getId() - end - return value = "
349:                            + returnInteger);
350:                }
351:                return returnInteger;
352:            }
353:
354:            /**
355:             * <p>Get the user name. This name must uniquely identify the user
356:             * within the system, and should only contain alphanumeric characters.</p>
357:             *
358:             * @return new value for the user name. Should be unique within the intranet
359:             *      system.
360:             *
361:             * @hibernate.property
362:             */
363:            public final String getName() {
364:                if (logger.isDebugEnabled()) {
365:                    logger.debug("getName() - start");
366:                }
367:
368:                if (logger.isDebugEnabled()) {
369:                    logger.debug("getName() - end - return value = " + name);
370:                }
371:                return name;
372:            }
373:
374:            /**
375:             * <p>Get the user's password, if the authentication is not done through the
376:             * <code>IMAP</code> webmail interface.</p>
377:             *
378:             * @return new value of the user's password (encrypted).
379:             *
380:             * @hibernate.property
381:             */
382:            public final String getPassword() {
383:                if (logger.isDebugEnabled()) {
384:                    logger.debug("getPassword() - start");
385:                }
386:
387:                if (logger.isDebugEnabled()) {
388:                    logger.debug("getPassword() - end - return value = "
389:                            + password);
390:                }
391:                return password;
392:            }
393:
394:            /**
395:             * Check if the user is in a given group. This assumes the integrity of the
396:             * groups collection!
397:             *
398:             * @return <code>true</code> if this user is a member of the administrator
399:             * group.
400:             */
401:            public boolean isAdministrator() {
402:                if (logger.isDebugEnabled()) {
403:                    logger.debug("isAdministrator() - start");
404:                }
405:
406:                boolean returnboolean = isMember(UserGroupConstants.ADMINISTRATOR_GROUP);
407:                if (logger.isDebugEnabled()) {
408:                    logger.debug("isAdministrator() - end - return value = "
409:                            + returnboolean);
410:                }
411:                return returnboolean;
412:            }
413:
414:            /**
415:             * <p>If the user created data in some systems which we don't want to
416:             * remove, she will be marked logically deleted when the order to remove
417:             * is given. The user can no longer be used, but is marked as deleted.</p>
418:             *
419:             * @return <code>true</code> if this user was logically deleted
420:             *
421:             * @hibernate.property
422:             */
423:            public boolean isDeleted() {
424:                if (logger.isDebugEnabled()) {
425:                    logger.debug("isDeleted() - start");
426:                }
427:
428:                if (logger.isDebugEnabled()) {
429:                    logger.debug("isDeleted() - end - return value = "
430:                            + deleted);
431:                }
432:                return deleted;
433:            }
434:
435:            /**
436:             * <p>Find out if a user is enabled or disabled.</p>
437:             *
438:             * @return <code>true</code> if the user is currently enabled, or
439:             *     <code>false</code> if the user is prevented from accessing the
440:             *     system.
441:             *
442:             * TODO: change column to enabled
443:             * @hibernate.property
444:             *      column="enable"
445:             */
446:            public boolean isEnabled() {
447:                if (logger.isDebugEnabled()) {
448:                    logger.debug("isEnabled() - start");
449:                }
450:
451:                if (logger.isDebugEnabled()) {
452:                    logger.debug("isEnabled() - end - return value = "
453:                            + enabled);
454:                }
455:                return enabled;
456:            }
457:
458:            /**
459:             * Check if the user is in a given group. This assumes the integrity of the
460:             * groups collection!
461:             *
462:             * @param groupId The unique identifier of the group to check for
463:             * membership.
464:             * @return <code>true</code> if this user is a member of the given group.
465:             */
466:            public boolean isMember(final Integer groupId) {
467:                if (logger.isDebugEnabled()) {
468:                    logger.debug("isMember(Integer groupId = " + groupId
469:                            + ") - start");
470:                }
471:                assert (groupId != null);
472:
473:                Iterator iterator = groups.iterator();
474:                while (iterator.hasNext()) {
475:                    UserGroupDO userGroup = (UserGroupDO) iterator.next();
476:                    if (groupId.equals(userGroup.getId())) {
477:                        if (logger.isDebugEnabled()) {
478:                            logger
479:                                    .debug("isMember - end - return value = " + true);
480:                        }
481:                        return true;
482:                    }
483:                }
484:                // if it gets down here, no luck!
485:
486:                if (logger.isDebugEnabled()) {
487:                    logger
488:                            .debug("isMember(Integer) - end - return value = " + false);
489:                }
490:                return false;
491:            }
492:
493:            /**
494:             * <copyDoc>Refer to {@link #isDeleted()}.</copyDoc>
495:             *
496:             * @param deletedParam
497:             * <copyDoc>Refer to {@link #isDeleted()}.</copyDoc>
498:             */
499:            public final void setDeleted(final boolean deletedParam) {
500:                if (logger.isDebugEnabled()) {
501:                    logger.debug("setDeleted(boolean deleted = " + deletedParam
502:                            + ") - start");
503:                }
504:
505:                checkSetter();
506:                this .deleted = deletedParam;
507:
508:                if (logger.isDebugEnabled()) {
509:                    logger.debug("setDeleted(boolean) - end");
510:                }
511:            }
512:
513:            /**
514:             * Clear-text notes about this user. Useful to explain that the default
515:             * administrator will always be an administrator.
516:             *
517:             * <copyDoc>Refer to {@link #getDescription}.</copyDoc>
518:             * @param descriptionParam
519:             * <copyDoc>Refer to {@link #getDescription}.</copyDoc>
520:             */
521:            public void setDescription(final String descriptionParam) {
522:                if (logger.isDebugEnabled()) {
523:                    logger.debug("setDescription(String descriptionParam = "
524:                            + descriptionParam + ") - start");
525:                }
526:
527:                description = descriptionParam;
528:
529:                if (logger.isDebugEnabled()) {
530:                    logger.debug("setDescription(String) - end");
531:                }
532:            }
533:
534:            /**
535:             * <copyDoc>Refer to {@link #isEnabled()}.</copyDoc>
536:             *
537:             * @param enabledParam
538:             * <copyDoc>Refer to {@link #isEnabled()}.</copyDoc>
539:             */
540:            public final void setEnabled(final boolean enabledParam) {
541:                if (logger.isDebugEnabled()) {
542:                    logger.debug("setEnabled(boolean enabled = " + enabledParam
543:                            + ") - start");
544:                }
545:
546:                checkSetter();
547:                this .enabled = enabledParam;
548:
549:                if (logger.isDebugEnabled()) {
550:                    logger.debug("setEnabled(boolean) - end");
551:                }
552:            }
553:
554:            /**
555:             * <copyDoc>Refer to {@link #getGroups()}.</copyDoc>
556:             * @param groupsParam
557:             * <copyDoc>Refer to {@link #getGroups()}.</copyDoc>
558:             */
559:            public final void setGroups(final Set groupsParam) {
560:                if (logger.isDebugEnabled()) {
561:                    logger.debug("setGroups(Set groups = " + groupsParam
562:                            + ") - start");
563:                }
564:
565:                checkSetter();
566:                this .groups = groupsParam;
567:
568:                if (logger.isDebugEnabled()) {
569:                    logger.debug("setGroups(Set) - end");
570:                }
571:            }
572:
573:            /**
574:             * <copyDoc>Refer to {@link #getName()}.</copyDoc>
575:             *
576:             * @param nameParam
577:             * <copyDoc>Refer to {@link #getName()}.</copyDoc>
578:             */
579:            public final void setName(final String nameParam) {
580:                if (logger.isDebugEnabled()) {
581:                    logger.debug("setName(String name = " + nameParam
582:                            + ") - start");
583:                }
584:
585:                checkSetter();
586:                this .name = nameParam;
587:
588:                if (logger.isDebugEnabled()) {
589:                    logger.debug("setName(String) - end");
590:                }
591:            }
592:
593:            /**
594:             * <copyDoc>Refer to {@link #getPassword()}.</copyDoc>
595:             *
596:             * @param passwordParam
597:             * <copyDoc>Refer to {@link #getPassword()}.</copyDoc>
598:             */
599:            public final void setPassword(final String passwordParam) {
600:                if (logger.isDebugEnabled()) {
601:                    logger.debug("setPassword(String password = "
602:                            + passwordParam + ") - start");
603:                }
604:
605:                checkSetter();
606:                this .password = passwordParam;
607:
608:                if (logger.isDebugEnabled()) {
609:                    logger.debug("setPassword(String) - end");
610:                }
611:            }
612:
613:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.