Revision 7172
Added by Jing Tao over 12 years ago
src/edu/ucsb/nceas/metacat/service/SessionService.java | ||
---|---|---|
227 | 227 |
*/ |
228 | 228 |
public void validateSession(PrintWriter out, HttpServletResponse response, |
229 | 229 |
String sessionId) { |
230 |
|
|
230 |
boolean needSessionInfo = false; |
|
231 | 231 |
response.setContentType("text/xml"); |
232 | 232 |
out.println("<?xml version=\"1.0\"?>"); |
233 | 233 |
out.write("<validateSession><status>"); |
234 | 234 |
if (validateSession(sessionId)) { |
235 | 235 |
out.write("valid"); |
236 |
needSessionInfo = true; |
|
236 | 237 |
} else { |
237 | 238 |
out.write("invalid"); |
238 | 239 |
} |
239 | 240 |
out.write("</status>"); |
241 |
if(needSessionInfo) { |
|
242 |
SessionData sessionData = getRegisteredSession(sessionId); |
|
243 |
if(sessionData != null) { |
|
244 |
out.write("<userInformation>"); |
|
245 |
out.write("<name>"); |
|
246 |
out.write(sessionData.getUserName()); |
|
247 |
out.write("</name>"); |
|
248 |
appendGroupsInformation(sessionData, out); |
|
249 |
out.write("</userInformation>"); |
|
250 |
} |
|
251 |
} |
|
240 | 252 |
out.write("<sessionId>" + sessionId + "</sessionId></validateSession>"); |
241 | 253 |
} |
242 | 254 |
|
... | ... | |
307 | 319 |
} |
308 | 320 |
} |
309 | 321 |
} |
322 |
|
|
323 |
/* |
|
324 |
* Add user's groups information into the response |
|
325 |
*/ |
|
326 |
private void appendGroupsInformation(SessionData sessionData, PrintWriter out ) { |
|
327 |
if(sessionData != null && out != null){ |
|
328 |
String[] groups = sessionData.getGroupNames(); |
|
329 |
if(groups != null) { |
|
330 |
for(String groupName : groups) { |
|
331 |
out.write("<group>"); |
|
332 |
out.write(groupName); |
|
333 |
out.write("</group>"); |
|
334 |
} |
|
335 |
} |
|
336 |
} |
|
337 |
|
|
338 |
} |
|
310 | 339 |
|
311 | 340 |
} |
Also available in: Unified diff
Append more information such as user name and group to the validating session response.