Source Code Cross Referenced for PersonImpl.java in  » Portal » uPortal_rel-2-6-1-GA » org » jasig » portal » security » provider » 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 » Portal » uPortal_rel 2 6 1 GA » org.jasig.portal.security.provider 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Copyright 2001 The JA-SIG Collaborative.  All rights reserved.
002:         *  See license distributed with this file and
003:         *  available online at http://www.uportal.org/license.html
004:         */
005:
006:        package org.jasig.portal.security.provider;
007:
008:        import java.util.Enumeration;
009:        import java.util.Hashtable;
010:        import java.util.Iterator;
011:        import java.util.List;
012:        import java.util.Map;
013:
014:        import org.jasig.portal.EntityIdentifier;
015:        import org.jasig.portal.security.IPerson;
016:        import org.jasig.portal.security.ISecurityContext;
017:        import org.jasig.portal.security.PersonFactory;
018:
019:        /**
020:         * This is a reference IPerson implementation.
021:         * @author Adam Rybicki, arybicki@unicon.net
022:         * @version $Revision: 36677 $
023:         */
024:        public class PersonImpl implements  IPerson {
025:            protected Hashtable m_Attributes = null;
026:            protected String m_FullName = null;
027:            protected int m_ID = -1;
028:            protected ISecurityContext m_securityContext = null;
029:            protected EntityIdentifier m_eid = new EntityIdentifier(null,
030:                    IPerson.class);
031:            protected boolean entityIdentifierSet = false;
032:
033:            public ISecurityContext getSecurityContext() {
034:                return m_securityContext;
035:            }
036:
037:            public void setSecurityContext(ISecurityContext securityContext) {
038:                m_securityContext = securityContext;
039:            }
040:
041:            /**
042:             * Returns an attribute for a key.  For objects represented as strings,
043:             * a <code>java.lang.String</code> will be returned.  Binary values will
044:             * be represented as byte arrays.
045:             * @param key the attribute name.
046:             * @return value the attribute value identified by the key.
047:             */
048:            public Object getAttribute(String key) {
049:                if (m_Attributes == null)
050:                    return null;
051:                Object value = m_Attributes.get(key);
052:                if (value instanceof  List)
053:                    return ((List) value).get(0);
054:                else
055:                    return value;
056:            }
057:
058:            /**
059:             * Returns multiple attributes for a key.  If only one
060:             * value exists, it will be returned in an array of size one.
061:             * @param key the attribute name
062:             * @return the array of attribute values identified by the key
063:             */
064:            public Object[] getAttributeValues(String key) {
065:                if (m_Attributes == null)
066:                    return null;
067:                Object value = m_Attributes.get(key);
068:                if (value == null) {
069:                    return null;
070:                } else if (value instanceof  List) {
071:                    return ((List) value).toArray();
072:                } else {
073:                    return new Object[] { value };
074:                }
075:            }
076:
077:            /**
078:             * Returns a <code>java.util.Enumeration</code> of all the attribute values.
079:             * @return <code>java.util.Enumeration</code> of the attributes.
080:             */
081:            public Enumeration getAttributes() {
082:                if (m_Attributes == null)
083:                    return null;
084:                return m_Attributes.elements();
085:            }
086:
087:            /**
088:             * Returns an enumeration of all of the attribute names associated with the user
089:             * @return enumeration of all of the attribute names associated with the user
090:             */
091:            public Enumeration getAttributeNames() {
092:                if (m_Attributes == null) {
093:                    return (null);
094:                } else {
095:                    return (m_Attributes.keys());
096:                }
097:            }
098:
099:            /**
100:             * Sets the specified attribute to a value.
101:             *
102:             * Reference impementation checks for the setting of the username attribute
103:             * and updates the EntityIdentifier accordingly
104:             *
105:             * @param key Attribute's name
106:             * @param value Attribute's value
107:             */
108:            public void setAttribute(String key, Object value) {
109:                if (m_Attributes == null)
110:                    m_Attributes = new Hashtable();
111:                if (value != null)
112:                    m_Attributes.put(key, value);
113:                else
114:                    m_Attributes.remove(key);
115:                if (!entityIdentifierSet && key.equals(IPerson.USERNAME)) {
116:                    m_eid = new EntityIdentifier(String.valueOf(value),
117:                            IPerson.class);
118:                }
119:            }
120:
121:            /**
122:             * Sets the specified attributes. Uses {@link #setAttribute(String, Object)}
123:             * to set each.
124:             *
125:             * @see org.jasig.portal.security.IPerson#setAttributes(java.util.Map)
126:             */
127:            public void setAttributes(final Map attrs) {
128:                for (final Iterator attrItr = attrs.keySet().iterator(); attrItr
129:                        .hasNext();) {
130:                    final String key = (String) attrItr.next();
131:                    final Object val = attrs.get(key);
132:
133:                    this .setAttribute(key, val);
134:                }
135:            }
136:
137:            /**
138:             * Returns the user's ID that was used for authentication.
139:             * Does not correlate to any eduPerson attribute but is the key
140:             * for user data in uPortal reference rdbms.
141:             * @return User's ID.
142:             */
143:            public int getID() {
144:                return m_ID;
145:            }
146:
147:            /**
148:             * Sets the user's ID.
149:             * @param sID User's ID as supplied for authentication
150:             * Does not correlate to any eduPerson attribute but is the key
151:             * for user data in uPortal reference rdbms.
152:             */
153:            public void setID(int sID) {
154:                m_ID = sID;
155:            }
156:
157:            /**
158:             * Returns the user's name that was established during authentication.
159:             * Correlates to cn (common name) in the eduPerson 1.0 specification.
160:             * @return User's name.
161:             */
162:            public String getFullName() {
163:                return m_FullName;
164:            }
165:
166:            /**
167:             * Sets the user's full name.
168:             * @param sFullName User's name as established during authentication
169:             * Correlates to cn (common name) in the eduPerson 1.0 specification.
170:             */
171:            public void setFullName(String sFullName) {
172:                m_FullName = sFullName;
173:            }
174:
175:            /**
176:             * Determines whether or not this person is a "guest" user.
177:             * <p>
178:             * This person is a "guest" if both of the following are true:
179:             * <ol>
180:             *   <li>This person has not successfully authenticated with the portal.</li>
181:             *   <li>This person's user name matches the value of the property
182:             *       <code>org.jasig.portal.security.PersonImpl.guest_user_name</code>
183:             *       in <code>portal.properties</code>.</li>
184:             * </ol>
185:             * @return <code>true</code> if person is a guest, otherwise <code>false</code>
186:             */
187:            public boolean isGuest() {
188:                boolean isGuest = false;
189:                String userName = (String) getAttribute(IPerson.USERNAME);
190:                if (userName.equals(PersonFactory.GUEST_USERNAME)
191:                        && !m_securityContext.isAuthenticated()) {
192:                    isGuest = true;
193:                }
194:                return isGuest;
195:            }
196:
197:            /**
198:             * Returns an EntityIdentifier for this person.  The key contains the value
199:             * of the eudPerson username attribute, or null
200:             *
201:             * @return EntityIdentifier with attribute 'username' as key.
202:             */
203:            public EntityIdentifier getEntityIdentifier() {
204:                return m_eid;
205:            }
206:
207:            /**
208:             * One time set of the entity identifier
209:             * @param ei
210:             */
211:            public void setEntityIdentifier(final EntityIdentifier ei) {
212:                m_eid = ei;
213:                entityIdentifierSet = true;
214:            }
215:
216:            public String toString() {
217:                StringBuffer sb = new StringBuffer();
218:                sb.append(PersonImpl.class.getName());
219:                sb.append(" fullName=[");
220:                sb.append(this .m_FullName);
221:                sb.append("]");
222:                sb.append(" id=[");
223:                sb.append(this .m_ID);
224:                sb.append("]");
225:                sb.append(" securityContext=[");
226:                sb.append(this .m_securityContext);
227:                sb.append("]");
228:                sb.append(" attributes=[");
229:                sb.append(this .m_Attributes);
230:                sb.append("]");
231:                sb.append(" isGuest:");
232:                sb.append(this.isGuest());
233:                return sb.toString();
234:            }
235:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.