Project

General

Profile

« Previous | Next » 

Revision 297

Added by bojilova over 24 years ago

Added "Login Client" action for login from the Desktop Client

View differences:

src/edu/ucsb/nceas/metacat/MetaCatServlet.java
216 216
      //out.println("<P>Caught exception looking for Y value.");
217 217
    }
218 218

  
219
// Jivka added 
219
// Jivka added  
220 220
    // handle login action
221
    if (action.equals("Login")) {
221
    if (action.equals("Login") || action.equals("Login Client")) {
222 222
      handleLoginAction(out, params, request, response);
223 223
    // handle logout action  
224 224
    } else if (action.equals("Logout")) {
......
227 227
      response.sendRedirect("/xmltodb/lib/login.html"); 
228 228
    // aware of session expiration on every request  
229 229
    } else {    
230
      HttpSession sess = request.getSession(false);
230
      //HttpSession sess = request.getSession(false);
231
      HttpSession sess = request.getSession(true);
231 232
      if (sess == null) { 
232 233
        // session expired or has not been stored b/w user requests
233 234
        // redirect to session expiration message page
......
254 255
      handleValidateAction(out, params, response);  
255 256
    } else if (action.equals("getdatadoc")) {
256 257
      handleGetDataDocumentAction(out, params, response);  
257
    } else if (action.equals("Login")) {
258
    } else if (action.equals("Login") || action.equals("Login Client")) {
258 259
    } else {
259 260
      out.println("Error: action not registered.  Please report this error.");
260 261
    }
......
272 273
  private void handleLoginAction(PrintWriter out, Hashtable params, 
273 274
               HttpServletRequest request, HttpServletResponse response) {
274 275

  
276
    MetaCatSession sess = null;
275 277
    String un = ((String[])params.get("username"))[0];
276 278
    String pw = ((String[])params.get("password"))[0];
279
    String action = ((String[])params.get("action"))[0];
277 280

  
278
    MetaCatSession sess = new MetaCatSession(request, un, pw);
279
 
280
    try {  
281
        if (sess.userAuth(pw)) {
281
    try {
282
        sess = new MetaCatSession(request, un, pw);
283
    } catch (Exception e) {
284
      out.println(e.getMessage());
285
    }
286

  
287
    try { 
288
        if (sess.userAuth(un, pw)) {
282 289
            try {
283
                response.sendRedirect(
290
                if (action.equals("Login Client")) {
291
                    out.println("<?xml version=\"1.0\"?>");
292
                    out.println("<success>");
293
                    out.println("User Authentication successful.");
294
                    out.println("</success>");
295
                } else {
296
                    response.sendRedirect(
284 297
                    response.encodeRedirectUrl("/xmltodb/lib/index.html"));
298
                }    
285 299
            } catch ( java.io.IOException ioe) {
286 300
                sess.disconnect();            
301
                out.println("<?xml version=\"1.0\"?>");
302
                out.println("<error>");
287 303
                out.println("MetaCatServlet.handleLoginAction() - " +
288 304
                            "Error on redirect of HttpServletResponse: " + 
289 305
                            ioe.getMessage());
306
                out.println("</error>");
290 307
            }                
291 308
                
292 309
        } else {
293 310
            sess.disconnect();            
311
            out.println("<?xml version=\"1.0\"?>");
312
            out.println("<error>");
294 313
            out.println("SRB Connection failed. " +
295 314
                        "SRB RMI Server is not running now or " +
296 315
                        "user " + un + 
297 316
                        " has not been authenticated to use the system.");
317
            out.println("</error>");
298 318
        }    
299 319
    } catch ( java.rmi.RemoteException re) {
300 320
            sess.disconnect();            
321
            out.println("<?xml version=\"1.0\"?>");
322
            out.println("<error>");
301 323
            out.println("SRB Connection failed. " + re.getMessage());
324
            out.println("</error>");
302 325
    }        
303 326
  }
304 327

  
......
632 655

  
633 656
/**
634 657
 * '$Log$
658
 * 'Revision 1.52  2000/07/26 20:38:40  higgins
659
 * 'no message
660
 * '
635 661
 * 'Revision 1.51  2000/07/01 01:09:44  jones
636 662
 * 'MetaCatServlet.java
637 663
 * '

Also available in: Unified diff