1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package net.sf.ginp.commands;
20
21 import java.util.Vector;
22
23 import net.sf.ginp.CommandParameter;
24 import net.sf.ginp.GinpModel;
25
26 /**
27 * Class to perform user authentication command and set model state based on
28 * authentication result.
29 *
30 *@author Doug Culnane
31 *@version $Revision: 264 $
32 */
33 public class Logon implements Command {
34
35 /**
36 * Perform user authentication action.
37 *
38 *@param model Description of the Parameter
39 *@param params Description of the Parameter
40 */
41 public void action(GinpModel model, Vector params) {
42
43 String userName = "";
44 String userPass = "";
45 boolean logedOn = false;
46
47 for (int i = 0; i < params.size(); i++) {
48 CommandParameter param = (CommandParameter) params.get(i);
49 if (param.getName().equals("u")) {
50 userName = param.getValue();
51 } else if (param.getName().equals("p")) {
52 userPass = param.getValue();
53 }
54 }
55
56 if (userName.length() > 0) {
57 Boolean valid = model.accessCheck(userName,userPass);
58 if (valid.booleanValue()) {
59 model.setUserName(userName);
60 logedOn = true;
61 }
62 model.setCurrectCollection(0);
63 if (model.getCollections().length > 0) {
64 model.getCollection().setPath("/");
65 }
66 }
67 if (!logedOn) {
68 model.setUserName("");
69 model.setCurrectCollection(-1);
70 model.setCurrentPage("logon.jsp?username=" + userName);
71 }
72 }
73 }
74