Revision 210
Added by bojilova over 24 years ago
src/edu/ucsb/nceas/metacat/MetaCatServlet.java | ||
---|---|---|
37 | 37 |
import javax.servlet.http.HttpServlet; |
38 | 38 |
import javax.servlet.http.HttpServletRequest; |
39 | 39 |
import javax.servlet.http.HttpServletResponse; |
40 |
import javax.servlet.http.HttpSession; |
|
40 | 41 |
import javax.servlet.http.HttpUtils; |
41 | 42 |
|
42 | 43 |
import oracle.xml.parser.v2.XSLStylesheet; |
... | ... | |
214 | 215 |
} catch (Exception npe) { |
215 | 216 |
//out.println("<P>Caught exception looking for Y value."); |
216 | 217 |
} |
217 |
|
|
218 |
// Jivka added |
|
219 |
// handle login action |
|
220 |
if (action.equals("Login")) { |
|
221 |
handleLoginAction(out, params, request, response); |
|
222 |
// handle logout action |
|
223 |
} else if (action.equals("Logout")) { |
|
224 |
HttpSession sess = request.getSession(false); |
|
225 |
if (sess != null) { |
|
226 |
sess.invalidate(); |
|
227 |
response.sendRedirect("/xmltodb/lib/login.html"); |
|
228 |
} |
|
229 |
// aware of session expiration on every request |
|
230 |
} else { |
|
231 |
HttpSession sess = request.getSession(false); |
|
232 |
if (sess == null) { |
|
233 |
out.println("Session expired. You will be redirected to Login page again."); |
|
234 |
response.sendRedirect("/xmltodb/lib/login.html"); |
|
235 |
} |
|
236 |
} |
|
237 |
// End of Jivka added |
|
218 | 238 |
if (action.equals("query") || action.equals("squery")) { |
219 | 239 |
handleQueryAction(out, params, response); |
220 | 240 |
} else if (action.equals("getdocument")) { |
... | ... | |
241 | 261 |
out.close(); |
242 | 262 |
} |
243 | 263 |
|
264 |
// Jivka added |
|
244 | 265 |
/** |
266 |
* Handle the Login request. Create a new session object. |
|
267 |
* Make a user authentication through SRB RMI Connection. |
|
268 |
*/ |
|
269 |
private void handleLoginAction(PrintWriter out, Hashtable params, |
|
270 |
HttpServletRequest request, HttpServletResponse response) { |
|
271 |
String un = (String)params.get("username"); |
|
272 |
String pw = (String)params.get("password"); |
|
273 |
|
|
274 |
MetaCatSession sess = new MetaCatSession(request, un, pw); |
|
275 |
try { |
|
276 |
if (sess.userAuth(pw)) { |
|
277 |
try { |
|
278 |
response.sendRedirect("/xmltodb/lib/index.html"); |
|
279 |
} catch ( java.io.IOException ioe) { |
|
280 |
sess.disconnect(); |
|
281 |
out.println("MetaCatServlet.handleLoginAction() - " + |
|
282 |
"Error on redirect of HttpServletResponse: " + |
|
283 |
ioe.getMessage()); |
|
284 |
} |
|
285 |
|
|
286 |
} else { |
|
287 |
sess.disconnect(); |
|
288 |
out.println("SRB Connection failed. " + |
|
289 |
"SRB RMI Server is not running now or " + |
|
290 |
"user " + un + |
|
291 |
" has not been authenticated to use the system"); |
|
292 |
} |
|
293 |
} catch ( java.rmi.RemoteException re) { |
|
294 |
sess.disconnect(); |
|
295 |
out.println("SRB Connection failed. " + re.getMessage()); |
|
296 |
} |
|
297 |
} |
|
298 |
/** |
|
245 | 299 |
* Handle the database query request and return a result set, possibly |
246 | 300 |
* transformed from XML into HTML |
247 | 301 |
*/ |
... | ... | |
580 | 634 |
|
581 | 635 |
/** |
582 | 636 |
* '$Log$ |
637 |
* 'Revision 1.33 2000/06/27 04:50:33 jones |
|
638 |
* 'Updated javadoc documentation. |
|
639 |
* ' |
|
583 | 640 |
* 'Revision 1.32 2000/06/27 04:31:07 jones |
584 | 641 |
* 'Fixed bugs associated with the new UPDATE and DELETE functions of |
585 | 642 |
* 'DBWriter. There were problematic interactions between some static |
Also available in: Unified diff
changes releted to login and session tracking