Source Code Cross Referenced for UserSession.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » core » 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 » ERP CRM Financial » Kuali Financial System » org.kuali.core 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005-2007 The Kuali Foundation.
003:         * 
004:         * Licensed under the Educational Community License, Version 1.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         * 
008:         * http://www.opensource.org/licenses/ecl1.php
009:         * 
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        package org.kuali.core;
017:
018:        import java.io.Serializable;
019:        import java.util.ArrayList;
020:        import java.util.HashMap;
021:        import java.util.Iterator;
022:        import java.util.List;
023:        import java.util.Map;
024:
025:        import org.apache.log4j.Logger;
026:        import org.kuali.core.bo.user.AuthenticationUserId;
027:        import org.kuali.core.bo.user.UniversalUser;
028:        import org.kuali.core.exceptions.UserNotFoundException;
029:        import org.kuali.core.workflow.service.KualiWorkflowDocument;
030:        import org.kuali.rice.KNSServiceLocator;
031:
032:        import edu.iu.uis.eden.clientapp.vo.NetworkIdVO;
033:        import edu.iu.uis.eden.clientapp.vo.UserVO;
034:        import edu.iu.uis.eden.exception.EdenUserNotFoundException;
035:        import edu.iu.uis.eden.exception.ResourceUnavailableException;
036:        import edu.iu.uis.eden.exception.WorkflowException;
037:
038:        /**
039:         * This class represents a User Session
040:         * 
041:         * 
042:         */
043:        public class UserSession implements  Serializable {
044:
045:            private static final long serialVersionUID = 4532616762540067557L;
046:
047:            private static final Logger LOG = Logger
048:                    .getLogger(UserSession.class);
049:
050:            private UniversalUser universalUser;
051:            private UniversalUser backdoorUser;
052:            private UserVO workflowUser;
053:            private UserVO backdoorWorkflowUser;
054:            private int nextObjectKey;
055:            private Map objectMap;
056:
057:            private transient Map workflowDocMap = new HashMap();
058:
059:            /**
060:             * Take in a netid, and construct the user from that.
061:             * 
062:             * @param networkId
063:             * @throws UserNotFoundException
064:             * @throws EdenUserNotFoundException
065:             * @throws ResourceUnavailableException
066:             */
067:            public UserSession(String networkId) throws UserNotFoundException,
068:                    WorkflowException {
069:                this .universalUser = KNSServiceLocator
070:                        .getUniversalUserService().getUniversalUser(
071:                                new AuthenticationUserId(networkId));
072:                this .workflowUser = KNSServiceLocator.getWorkflowInfoService()
073:                        .getWorkflowUser(new NetworkIdVO(networkId));
074:                this .nextObjectKey = 0;
075:                this .objectMap = new HashMap();
076:            }
077:
078:            /**
079:             * @return the networkId of the current user in the system, backdoor network id if backdoor is set
080:             */
081:            public String getNetworkId() {
082:                if (backdoorUser != null) {
083:                    return backdoorUser.getPersonUserIdentifier();
084:                } else {
085:                    return universalUser.getPersonUserIdentifier();
086:                }
087:            }
088:
089:            /**
090:             * This returns who is logged in. If the backdoor is in use, this will return the network id of the person that is standing in
091:             * as the backdoor user.
092:             * 
093:             * @return String
094:             */
095:            public String getLoggedInUserNetworkId() {
096:                return universalUser.getPersonUserIdentifier();
097:            }
098:
099:            /**
100:             * @return the KualiUser which is the current user in the system, backdoor if backdoor is set
101:             */
102:            public UniversalUser getUniversalUser() {
103:                if (backdoorUser != null) {
104:                    return backdoorUser;
105:                } else {
106:                    return universalUser;
107:                }
108:            }
109:
110:            /**
111:             * @return the workflowUser which is the current user in the system, backdoor if backdoor is set
112:             */
113:            public UserVO getWorkflowUser() {
114:                if (backdoorUser != null) {
115:                    return backdoorWorkflowUser;
116:                } else {
117:                    return workflowUser;
118:                }
119:            }
120:
121:            /**
122:             * override the current user in the system by setting the backdoor networkId, which is useful when dealing with routing or other
123:             * reasons why you would need to assume an identity in the system
124:             * 
125:             * @param networkId
126:             * @throws UserNotFoundException
127:             * @throws ResourceUnavailableException
128:             * @throws EdenUserNotFoundException
129:             */
130:            public void setBackdoorUser(String networkId)
131:                    throws UserNotFoundException, WorkflowException {
132:                // only allow backdoor in non-production environments
133:                if (!KNSServiceLocator.getKualiConfigurationService()
134:                        .isProductionEnvironment()) {
135:                    this .backdoorUser = KNSServiceLocator
136:                            .getUniversalUserService().getUniversalUser(
137:                                    new AuthenticationUserId(networkId));
138:                    this .backdoorWorkflowUser = KNSServiceLocator
139:                            .getWorkflowInfoService().getWorkflowUser(
140:                                    new NetworkIdVO(networkId));
141:                    this .workflowDocMap = new HashMap();
142:                }
143:            }
144:
145:            /**
146:             * clear the backdoor user
147:             * 
148:             */
149:            public void clearBackdoorUser() {
150:                this .backdoorUser = null;
151:                this .backdoorWorkflowUser = null;
152:                this .workflowDocMap = new HashMap();
153:            }
154:
155:            /**
156:             * allows adding an arbitrary object to the session and returns a string key that can be used to later access this object from
157:             * the session using the retrieveObject method in this class
158:             * 
159:             * @param object
160:             * @return
161:             */
162:            public String addObject(Object object, String keyPrefix) {
163:                String objectKey = keyPrefix + nextObjectKey++;
164:                objectMap.put(objectKey, object);
165:                return objectKey;
166:            }
167:
168:            /**
169:             * allows adding an arbitrary object to the session with static a string key that can be used to later access this object from
170:             * the session using the retrieveObject method in this class
171:             * 
172:             * @param object
173:             * 
174:             */
175:            public void addObject(String key, Object object) {
176:
177:                objectMap.put(key, object);
178:
179:            }
180:
181:            /**
182:             * allows adding an arbitrary object to the session and returns a string key that can be used to later access this object from
183:             * the session using the retrieveObject method in this class
184:             * 
185:             * @param object
186:             * @return
187:             */
188:            public String addObject(Object object) {
189:                String objectKey = nextObjectKey++ + "";
190:                objectMap.put(objectKey, object);
191:                return objectKey;
192:            }
193:
194:            /**
195:             * allows for fetching an object that has been put into the userSession based on the key that would have been returned when
196:             * adding the object
197:             * 
198:             * @param objectKey
199:             * @return
200:             */
201:            public Object retrieveObject(String objectKey) {
202:                return this .objectMap.get(objectKey);
203:            }
204:
205:            /**
206:             * allows for removal of an object from session that has been put into the userSession based on the key that would have been
207:             * assigned
208:             * 
209:             * @param objectKey
210:             */
211:            public void removeObject(String objectKey) {
212:                this .objectMap.remove(objectKey);
213:            }
214:
215:            /**
216:             * allows for removal of an object from session that has been put into the userSession based on a key that starts with the given
217:             * prefix
218:             * 
219:             * @param objectKey
220:             */
221:            public void removeObjectsByPrefix(String objectKeyPrefix) {
222:                List removeKeys = new ArrayList();
223:                for (Iterator iter = objectMap.keySet().iterator(); iter
224:                        .hasNext();) {
225:                    String key = (String) iter.next();
226:                    if (key.startsWith(objectKeyPrefix)) {
227:                        removeKeys.add(key);
228:                    }
229:                }
230:
231:                for (Iterator iter = removeKeys.iterator(); iter.hasNext();) {
232:                    String key = (String) iter.next();
233:                    this .objectMap.remove(key);
234:                }
235:            }
236:
237:            /**
238:             * @return boolean indicating if the backdoor is in use
239:             */
240:            public boolean isBackdoorInUse() {
241:                return backdoorUser != null;
242:            }
243:
244:            /**
245:             * retrieve a flexdoc from the userSession based on the document id
246:             * 
247:             * @param docId
248:             * @return
249:             */
250:            public KualiWorkflowDocument getWorkflowDocument(String docId) {
251:                if (workflowDocMap == null) {
252:                    workflowDocMap = new HashMap();
253:                }
254:                if (workflowDocMap.containsKey(docId)) {
255:                    return (KualiWorkflowDocument) workflowDocMap.get(docId);
256:                } else {
257:                    return null;
258:                }
259:            }
260:
261:            /**
262:             * set a flexDoc into the userSession which will be stored under the document id
263:             * 
264:             * @param flexDoc
265:             */
266:            public void setWorkflowDocument(
267:                    KualiWorkflowDocument workflowDocument) {
268:                try {
269:                    if (workflowDocMap == null) {
270:                        workflowDocMap = new HashMap();
271:                    }
272:                    workflowDocMap.put(workflowDocument.getRouteHeaderId()
273:                            .toString(), workflowDocument);
274:                } catch (WorkflowException e) {
275:                    throw new IllegalStateException(
276:                            "could not save the document in the session msg: "
277:                                    + e.getMessage());
278:                }
279:            }
280:
281:            private void refreshUserGroups(UniversalUser universalUser) {
282:                universalUser.refreshUserGroups();
283:            }
284:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.