Source Code Cross Referenced for EmForgeUserImpl.java in  » Project-Management » EmForce » ru » emdev » EmForge » 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 » Project Management » EmForce » ru.emdev.EmForge.security 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package ru.emdev.EmForge.security;
002:
003:        import java.util.Date;
004:
005:        import org.acegisecurity.GrantedAuthority;
006:        import org.acegisecurity.userdetails.UserDetailsService;
007:        import org.apache.commons.lang.StringUtils;
008:
009:        import ru.emdev.EmForge.security.web.SiteRole;
010:
011:        /**
012:         * Simple POJO-Based implementation of EmForge User Details
013:         */
014:        public class EmForgeUserImpl implements  EmForgeUserDetails {
015:
016:            private static final long serialVersionUID = 1451145719985826674L;
017:
018:            private String m_displayName;
019:            private String m_userName;
020:            private String m_password;
021:            private String m_email;
022:
023:            private String m_managerName;
024:            private EmForgeUserDetails m_manager;
025:
026:            private GrantedAuthority[] m_roles;
027:            private boolean m_isEnabled;
028:
029:            private UserDetailsService m_userDetailsService;
030:
031:            private boolean m_isAnonymous;
032:
033:            private String m_vcUserName;
034:            private String m_vcPassword;
035:
036:            private Date m_registeredAt;
037:
038:            /**
039:             * Initializes default values
040:             */
041:            public EmForgeUserImpl() {
042:
043:                m_isAnonymous = false;
044:                m_registeredAt = new Date();
045:            }
046:
047:            /**
048:             * @param i_userName
049:             * @param i_password
050:             * @param i_displayName
051:             * @param i_email
052:             * @param i_managerName
053:             * @param i_isEnabled
054:             * @param i_roles
055:             */
056:            public EmForgeUserImpl(String i_userName, String i_password,
057:                    String i_displayName, String i_email, String i_managerName,
058:                    boolean i_isEnabled, GrantedAuthority[] i_roles) {
059:
060:                this ();
061:                m_userName = i_userName;
062:                m_password = i_password;
063:                m_displayName = i_displayName;
064:                m_email = i_email;
065:                m_managerName = i_managerName;
066:                m_isEnabled = i_isEnabled;
067:                m_roles = i_roles;
068:            }
069:
070:            /**
071:             * @param i_displayName
072:             */
073:            public void setDisplayName(String i_displayName) {
074:
075:                m_displayName = i_displayName;
076:            }
077:
078:            /**
079:             * @see ru.emdev.EmForge.security.EmForgeUserDetails#getDisplayName()
080:             */
081:            public String getDisplayName() {
082:
083:                return m_displayName;
084:            }
085:
086:            /**
087:             * @param i_email
088:             */
089:            public void setEmail(String i_email) {
090:
091:                m_email = i_email;
092:            }
093:
094:            /**
095:             * @see ru.emdev.EmForge.security.EmForgeUserDetails#getEmail()
096:             */
097:            public String getEmail() {
098:
099:                return m_email;
100:            }
101:
102:            /**
103:             * @param i_manager
104:             */
105:            public void setManager(EmForgeUserDetails i_manager) {
106:
107:                m_manager = i_manager;
108:            }
109:
110:            /**
111:             * @see ru.emdev.EmForge.security.EmForgeUserDetails#getManager()
112:             */
113:            public EmForgeUserDetails getManager() {
114:
115:                if (m_manager == null && m_managerName != null
116:                        && m_userDetailsService != null) {
117:                    m_manager = (EmForgeUserDetails) m_userDetailsService
118:                            .loadUserByUsername(m_managerName);
119:                }
120:                return m_manager;
121:            }
122:
123:            /**
124:             * @see ru.emdev.EmForge.security.EmForgeUserDetails#isAnonymous()
125:             */
126:            public boolean isAnonymous() {
127:
128:                return m_isAnonymous;
129:            }
130:
131:            /**
132:             * @param anonymousFlag
133:             */
134:            public void setAnonymous(boolean anonymousFlag) {
135:
136:                m_isAnonymous = anonymousFlag;
137:            }
138:
139:            /**
140:             * @see org.acegisecurity.userdetails.UserDetails#getAuthorities()
141:             */
142:            public GrantedAuthority[] getAuthorities() {
143:
144:                return m_roles;
145:            }
146:
147:            /**
148:             * @param i_password
149:             */
150:            public void setPassword(String i_password) {
151:
152:                m_password = i_password;
153:            }
154:
155:            /**
156:             * @see org.acegisecurity.userdetails.UserDetails#getPassword()
157:             */
158:            public String getPassword() {
159:
160:                return m_password;
161:            }
162:
163:            /**
164:             * @param i_userName
165:             */
166:            public void setUsername(String i_userName) {
167:
168:                m_userName = i_userName;
169:            }
170:
171:            /**
172:             * @see org.acegisecurity.userdetails.UserDetails#getUsername()
173:             */
174:            public String getUsername() {
175:
176:                return m_userName;
177:            }
178:
179:            /**
180:             * @see org.acegisecurity.userdetails.UserDetails#isAccountNonExpired()
181:             */
182:            public boolean isAccountNonExpired() {
183:
184:                return true;
185:            }
186:
187:            /**
188:             * @see org.acegisecurity.userdetails.UserDetails#isAccountNonLocked()
189:             */
190:            public boolean isAccountNonLocked() {
191:
192:                return true;
193:            }
194:
195:            /**
196:             * @see org.acegisecurity.userdetails.UserDetails#isCredentialsNonExpired()
197:             */
198:            public boolean isCredentialsNonExpired() {
199:
200:                return true;
201:            }
202:
203:            /**
204:             * @see org.acegisecurity.userdetails.UserDetails#isEnabled()
205:             */
206:            public boolean isEnabled() {
207:
208:                return m_isEnabled;
209:            }
210:
211:            /**
212:             * @param userDetailsService
213:             */
214:            public void setUserDetailsService(
215:                    UserDetailsService userDetailsService) {
216:
217:                m_userDetailsService = userDetailsService;
218:            }
219:
220:            /**
221:             * @see ru.emdev.EmForge.security.EmForgeUserDetails#getVcUserName()
222:             */
223:            public String getVcUserName() {
224:
225:                if (m_vcUserName != null) {
226:                    return m_vcUserName;
227:                }
228:
229:                return m_userName;
230:            }
231:
232:            /**
233:             * @param i_vcUserName
234:             */
235:            public void setVcUserName(String i_vcUserName) {
236:
237:                m_vcUserName = i_vcUserName;
238:            }
239:
240:            /**
241:             * @see ru.emdev.EmForge.security.EmForgeUserDetails#getVcPassword()
242:             */
243:            public String getVcPassword() {
244:
245:                if (m_vcPassword != null) {
246:                    return m_vcPassword;
247:                }
248:
249:                return m_password;
250:            }
251:
252:            /**
253:             * @param i_vcPassword
254:             */
255:            public void setVcPassword(String i_vcPassword) {
256:
257:                m_vcPassword = i_vcPassword;
258:            }
259:
260:            /**
261:             * @see ru.emdev.EmForge.security.EmForgeUserDetails#hasRole(java.lang.String)
262:             */
263:            public boolean hasRole(String i_role) {
264:
265:                for (GrantedAuthority authority : m_roles) {
266:                    if (authority.getAuthority().equals(i_role)) {
267:                        return true;
268:                    }
269:                }
270:
271:                return false;
272:            }
273:
274:            /**
275:             * @return <code>True</code> if the user is an admin/writer, otherwise <code>False</code>
276:             */
277:            public boolean isWriter() {
278:
279:                return hasRole(SiteRole.ADMIN.getId())
280:                        || hasRole(SiteRole.WRITER.getId());
281:            }
282:
283:            /**
284:             * @return User registration date
285:             */
286:            public Date getRegisteredAt() {
287:
288:                return m_registeredAt;
289:            }
290:
291:            /**
292:             * @see java.lang.Object#equals(java.lang.Object)
293:             */
294:            @Override
295:            public boolean equals(Object i_obj) {
296:
297:                boolean result = false;
298:
299:                if (i_obj != null) {
300:                    if (i_obj == this ) {
301:                        result = true;
302:
303:                    } else if (i_obj instanceof  EmForgeUserDetails) {
304:                        result = StringUtils.equals(
305:                                ((EmForgeUserDetails) i_obj).getUsername(),
306:                                getUsername());
307:                    }
308:                }
309:
310:                return result;
311:            }
312:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.