01: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
02: * This code is licensed under the GPL 2.0 license, availible at the root
03: * application directory.
04: */
05:
06: /*
07: * Created on Feb 3, 2004
08: *
09: * To change the template for this generated file go to
10: * Window - Preferences - Java - Code Generation - Code and Comments
11: */
12: package org.vfny.geoserver.action;
13:
14: import org.apache.struts.action.ActionForm;
15: import org.apache.struts.action.ActionForward;
16: import org.apache.struts.action.ActionMapping;
17: import org.vfny.geoserver.config.GlobalConfig;
18: import org.vfny.geoserver.form.LoginForm;
19: import org.vfny.geoserver.global.UserContainer;
20: import javax.servlet.http.HttpServletRequest;
21: import javax.servlet.http.HttpServletResponse;
22:
23: /**
24: * <p>
25: * Allows for the changing of username and password
26: * </p>
27: *
28: * @author rgould, Refractions Research, Inc.
29: */
30: public class LoginEditAction extends ConfigAction {
31: public ActionForward execute(ActionMapping mapping,
32: ActionForm form, UserContainer user,
33: HttpServletRequest request, HttpServletResponse response) {
34: LoginForm loginForm = (LoginForm) form;
35: String username = loginForm.getUsername();
36: String password = loginForm.getPassword();
37: String confirm = loginForm.getConfirm();
38:
39: GlobalConfig global = (GlobalConfig) getServlet()
40: .getServletContext().getAttribute(
41: GlobalConfig.CONFIG_KEY);
42: //Failed experiment, this stuff should really go in a validate method,
43: //I think this is showing the weakness of both edit and non using Login
44: //Form, instead of a LoginEditForm.
45: /*if (confirm == null || !confirm.equals(password)){
46: ActionErrors errors = new ActionErrors();
47: errors.add(ActionErrors.GLOBAL_ERROR,
48: new ActionError("error.password.mismatch"));
49: saveErrors(request, errors);
50: return mapping.getInputForward();//findForward("config.loginEditSubmit");
51: }*/
52: global.setAdminUserName(username);
53: global.setAdminPassword(password);
54: getApplicationState().notifyConfigChanged();
55: getServlet().getServletContext().setAttribute(
56: GlobalConfig.CONFIG_KEY, global);
57:
58: String forward = (String) request.getAttribute("forward");
59:
60: if (forward == null) {
61: forward = "config";
62: }
63:
64: return mapping.findForward(forward);
65: }
66: }
|