Revision 5070
Added by daigle over 14 years ago
SessionService.java | ||
---|---|---|
64 | 64 |
|
65 | 65 |
logMetacat.debug("SessionService() - Registering public session id: " + |
66 | 66 |
PUBLIC_SESSION_ID); |
67 |
registerSession(PUBLIC_SESSION_ID, "public", null, null); |
|
67 |
registerSession(PUBLIC_SESSION_ID, "public", null, null, "Public User");
|
|
68 | 68 |
} catch (PropertyNotFoundException pnfe) { |
69 | 69 |
throw new ServiceException("SessionService() - Error getting property: " + |
70 | 70 |
pnfe.getMessage()); |
... | ... | |
112 | 112 |
* the password for the session |
113 | 113 |
*/ |
114 | 114 |
public static void registerSession(String sessionId, String userName, |
115 |
String[] groupNames, String password) throws ServiceException { |
|
115 |
String[] groupNames, String password, String name) throws ServiceException {
|
|
116 | 116 |
if (sessionId == null) { |
117 | 117 |
throw new ServiceException("SessionService.registerSession - " + |
118 | 118 |
"Cannot register a null session id"); |
119 | 119 |
} |
120 | 120 |
logMetacat.debug("SessionService.registerSession - Registering session id: " + sessionId); |
121 | 121 |
SessionData sessionData = new SessionData(sessionId, userName, groupNames, |
122 |
password); |
|
122 |
password, name);
|
|
123 | 123 |
sessionHash.put(sessionId, sessionData); |
124 | 124 |
} |
125 | 125 |
|
... | ... | |
146 | 146 |
* the id of the session to remove. |
147 | 147 |
*/ |
148 | 148 |
public static void unRegisterSession(String sessionId) { |
149 |
if (sessionId != null) {
|
|
149 |
if (sessionId == null) {
|
|
150 | 150 |
logMetacat.error("SessionService.unRegisterSession - trying to " + |
151 | 151 |
"unregister a session with null id"); |
152 |
sessionHash.remove(sessionId); |
|
153 | 152 |
} |
153 |
|
|
154 |
logMetacat.error("SessionService.unRegisterSession - unRegistering session: " + sessionId); |
|
155 |
sessionHash.remove(sessionId); |
|
154 | 156 |
} |
155 | 157 |
|
156 | 158 |
/** |
... | ... | |
186 | 188 |
response.setContentType("text/xml"); |
187 | 189 |
out.println("<?xml version=\"1.0\"?>"); |
188 | 190 |
out.write("<validateSession><status>"); |
189 |
if (sessionId != null && !sessionId.equals(PUBLIC_SESSION_ID) && isSessionRegistered(sessionId)) {
|
|
191 |
if (validateSession(sessionId)) {
|
|
190 | 192 |
out.write("valid"); |
191 | 193 |
} else { |
192 | 194 |
out.write("invalid"); |
... | ... | |
196 | 198 |
} |
197 | 199 |
|
198 | 200 |
/** |
201 |
* Check if a session is registered in the session hash table. Return |
|
202 |
* true if the session is valid and false otherwise. |
|
203 |
* |
|
204 |
* @param sessionId |
|
205 |
* the id of the session to look for. |
|
206 |
*/ |
|
207 |
public static boolean validateSession(String sessionId) { |
|
208 |
if (sessionId != null && !sessionId.equals(PUBLIC_SESSION_ID) && isSessionRegistered(sessionId)) { |
|
209 |
return true; |
|
210 |
} else { |
|
211 |
return false; |
|
212 |
} |
|
213 |
} |
|
214 |
|
|
215 |
/** |
|
199 | 216 |
* Get a registered session from the session hash table. |
200 | 217 |
* TODO MCD need to time sessions out |
201 | 218 |
* |
Also available in: Unified diff
Add user name to SessionData object