Source Code Cross Referenced for DefaultUserProfile.java in  » Wiki-Engine » JSPWiki » com » ecyrd » jspwiki » auth » 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 » Wiki Engine » JSPWiki » com.ecyrd.jspwiki.auth.user 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         JSPWiki - a JSP-based WikiWiki clone.
003:
004:         Copyright (C) 2001-2005 Janne Jalkanen (Janne.Jalkanen@iki.fi)
005:
006:         This program is free software; you can redistribute it and/or modify
007:         it under the terms of the GNU Lesser General Public License as published by
008:         the Free Software Foundation; either version 2.1 of the License, or
009:         (at your option) any later version.
010:
011:         This program is distributed in the hope that it will be useful,
012:         but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014:         GNU Lesser General Public License for more details.
015:
016:         You should have received a copy of the GNU Lesser General Public License
017:         along with this program; if not, write to the Free Software
018:         Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
019:         */
020:        package com.ecyrd.jspwiki.auth.user;
021:
022:        import java.util.Date;
023:
024:        /**
025:         * Default implementation for representing wiki user information, such as the
026:         * login name, full name, wiki name, and e-mail address.
027:         * @author Janne Jalkanen
028:         * @author Andrew Jaquith
029:         * @since 2.3
030:         */
031:
032:        public class DefaultUserProfile implements  UserProfile {
033:            private static final String EMPTY_STRING = "";
034:
035:            private static final String WHITESPACE = "\\s";
036:
037:            private Date m_created = null;
038:
039:            private String m_email = null;
040:
041:            private String m_fullname = null;
042:
043:            private String m_loginName = null;
044:
045:            private Date m_modified = null;
046:
047:            private String m_password = null;
048:
049:            private String m_wikiname = null;
050:
051:            public boolean equals(Object o) {
052:                if ((o != null) && (o instanceof  UserProfile)) {
053:                    DefaultUserProfile u = (DefaultUserProfile) o;
054:                    return same(m_fullname, u.m_fullname)
055:                            && same(m_password, u.m_password)
056:                            && same(m_loginName, u.m_loginName)
057:                            && same(m_email, u.m_email)
058:                            && same(m_wikiname, u.m_wikiname);
059:                }
060:
061:                return false;
062:            }
063:
064:            public int hashCode() {
065:                return (m_fullname != null ? m_fullname.hashCode() : 0)
066:                        ^ (m_password != null ? m_password.hashCode() : 0)
067:                        ^ (m_loginName != null ? m_loginName.hashCode() : 0)
068:                        ^ (m_wikiname != null ? m_wikiname.hashCode() : 0)
069:                        ^ (m_email != null ? m_email.hashCode() : 0);
070:            }
071:
072:            /**
073:             * Returns the creation date
074:             * @return the creation date
075:             * @see com.ecyrd.jspwiki.auth.user.UserProfile#getCreated()
076:             */
077:            public Date getCreated() {
078:                return m_created;
079:            }
080:
081:            /**
082:             * Returns the user's e-mail address.
083:             * @return the e-mail address
084:             */
085:            public String getEmail() {
086:                return m_email;
087:            }
088:
089:            /**
090:             * Returns the user's full name.
091:             * @return the full name
092:             */
093:            public String getFullname() {
094:                return m_fullname;
095:            }
096:
097:            /**
098:             * Returns the last-modified date.
099:             * @return the last-modified date
100:             * @see com.ecyrd.jspwiki.auth.user.UserProfile#getLastModified()
101:             */
102:            public Date getLastModified() {
103:                return m_modified;
104:            }
105:
106:            /**
107:             * Returns the user's login name.
108:             * @return the login name
109:             */
110:            public String getLoginName() {
111:                return m_loginName;
112:            }
113:
114:            /**
115:             * Returns the user password for use with custom authentication. Note that
116:             * the password field is not meaningful for container authentication; the
117:             * user's private credentials are generally stored elsewhere. While it
118:             * depends on the {@link UserDatabase}implementation, in most cases the
119:             * value returned by this method will be a password hash, not the password
120:             * itself.
121:             * @return the password
122:             */
123:            public String getPassword() {
124:                return m_password;
125:            }
126:
127:            /**
128:             * Returns the user's wiki name.
129:             * @return the wiki name.
130:             */
131:            public String getWikiName() {
132:                return m_wikiname;
133:            }
134:
135:            /**
136:             * Returns <code>true</code> if the user profile is
137:             * new. This implementation checks whether
138:             * {@link #getLastModified()} returns <code>null</code>
139:             * to determine the status.
140:             * @see com.ecyrd.jspwiki.auth.user.UserProfile#isNew()
141:             */
142:            public boolean isNew() {
143:                return m_modified == null;
144:            }
145:
146:            /**
147:             * @param date the creation date
148:             * @see com.ecyrd.jspwiki.auth.user.UserProfile#setCreated(java.util.Date)
149:             */
150:            public void setCreated(Date date) {
151:                m_created = date;
152:            }
153:
154:            /**
155:             * Sets the user's e-mail address.
156:             * @param email the e-mail address
157:             */
158:            public void setEmail(String email) {
159:                m_email = email;
160:            }
161:
162:            /**
163:             * Sets the user's full name. For example, "Janne Jalkanen."
164:             * @param arg the full name
165:             */
166:            public void setFullname(String arg) {
167:                m_fullname = arg;
168:
169:                // Compute wiki name
170:                if (m_fullname != null) {
171:                    m_wikiname = m_fullname
172:                            .replaceAll(WHITESPACE, EMPTY_STRING);
173:                }
174:            }
175:
176:            /**
177:             * Sets the last-modified date.
178:             * @param date the last-modified date
179:             * @see com.ecyrd.jspwiki.auth.user.UserProfile#setLastModified(java.util.Date)
180:             */
181:            public void setLastModified(Date date) {
182:                m_modified = date;
183:            }
184:
185:            /**
186:             * Sets the name by which the user logs in. The login name is used as the
187:             * username for custom authentication (see
188:             * {@link com.ecyrd.jspwiki.auth.AuthenticationManager#login(WikiSession, String, String)}).
189:             * The login name is typically a short name ("jannej"). In contrast, the
190:             * wiki name is typically of type FirstnameLastName ("JanneJalkanen").
191:             * @param name the login name
192:             */
193:            public void setLoginName(String name) {
194:                m_loginName = name;
195:            }
196:
197:            /**
198:             * Sets the user's password for use with custom authentication. It is
199:             * <em>not</em> the responsibility of implementing classes to hash the
200:             * password; that responsibility is borne by the UserDatabase implementation
201:             * during save operations (see {@link UserDatabase#save(UserProfile)}).
202:             * Note that the password field is not meaningful for container
203:             * authentication; the user's private credentials are generally stored
204:             * elsewhere.
205:             * @param arg the password
206:             */
207:            public void setPassword(String arg) {
208:                m_password = arg;
209:            }
210:
211:            /**
212:             * No-op method. In previous versions of JSPWiki, the method
213:             * set the user's wiki name directly. Now, the wiki name is automatically
214:             * calculated based on the full name.
215:             * @param name the wiki name
216:             * @deprecated This method will be removed in a future release.
217:             */
218:            public void setWikiName(String name) {
219:            }
220:
221:            /**
222:             * Returns a string representation of this user profile.
223:             * @return the string
224:             */
225:            public String toString() {
226:                return "[DefaultUserProfile: '" + getFullname() + "']";
227:            }
228:
229:            /**
230:             * Private method that compares two objects and determines whether they are
231:             * equal. Two nulls are considered equal.
232:             * @param arg1 the first object
233:             * @param arg2 the second object
234:             * @return the result of the comparison
235:             */
236:            private boolean same(Object arg1, Object arg2) {
237:                if (arg1 == null && arg2 == null) {
238:                    return true;
239:                }
240:                if (arg1 == null || arg2 == null) {
241:                    return false;
242:                }
243:                return arg1.equals(arg2);
244:            }
245:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.