01: /*
02: ====================================================================
03: Project Name: bugtracker
04: File Name: /src/com/espada/bugtracker/servlets/Login.java
05: Author: Kishan Peiris <kishan@espadanet.com>
06: Description: Athenticate user accounts
07: CVS Repository: goliath:/projects/repository/cvsroot/
08: CVS Module: bugtracker
09: Version: CVS $Id: $
10: =================================================================== */
11:
12: package com.espada.bugtracker.servlets;
13:
14: import com.sr.espada.se.util.config.*;
15: import com.sr.espada.se.util.logwriter.*;
16: import java.util.*;
17:
18: // webmacro resources
19: import org.webmacro.*;
20: import org.webmacro.broker.*;
21: import org.webmacro.resource.*;
22: import org.webmacro.servlet.WebContext;
23:
24: // servlet libraries
25: import javax.servlet.http.*;
26: import javax.servlet.*;
27:
28: // bugtracker java apps
29: import com.espada.bugtracker.app.*;
30:
31: public class Login extends BTServlet {
32:
33: /**
34: * This is the core WebMacro interface which we use to create Contexts,
35: * load Templates, and begin other WebMacro operations.
36: */
37:
38: protected void doAction(HttpServletRequest request,
39: HttpServletResponse response, WebContext c) {
40:
41: HttpSession session = request.getSession();
42: String passwd = new String();
43: String name = new String();
44:
45: if (request.getParameter("username") != null) {
46: passwd = request.getParameter("pwd");
47: name = request.getParameter("username");
48:
49: }
50:
51: User me = new User(name);
52:
53: Vector ProjRoles = new Vector();
54: boolean loggedIn = false;
55: if ((me.found) && (me.checkPassword(passwd))) {
56:
57: defaultTemplate = "index.wm";
58: session.setAttribute("UID", new Integer(me.uid));
59: session.setAttribute("USER", new String(me.username));
60: session.setAttribute("PW", new String(me.password));
61: session.setAttribute("EMAIL", new String(me.email));
62:
63: /***************** List all Projects according to user roles *************
64: User Manager task's
65:
66: */
67:
68: int mostProminentRole = (me.isAdmin()) ? 1 : me
69: .getMostProminentRole();
70:
71: session.setAttribute("USERROLE", Integer
72: .toString(mostProminentRole));
73:
74: session.setAttribute("PROJROLES", Project
75: .getProjectsByUserRole(me.uid, mostProminentRole));
76:
77: loggedIn = true;
78: } // ends if (me.found)...
79: else {
80: defaultTemplate = "errorMesg.wm";
81: c.put("errorId", "7");
82: }
83:
84: session.setAttribute("loggedIn", String.valueOf(loggedIn));
85: c.put("loggedIn", String.valueOf(loggedIn));
86: c.put("proId", "0");
87: c.put("me", me);
88: c.put("USER", session.getAttribute("USER"));
89: c.put("myRoleId", session.getAttribute("USERROLE"));
90:
91: } //end of method
92:
93: /**************************** End Of Method checkAuthentication ********************************************/
94:
95: } //end of class
|