KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > cms > applications > managementtool > actions > UpdateSystemUserPasswordAction


1 /* ===============================================================================
2 *
3 * Part of the InfoGlue Content Management Platform (www.infoglue.org)
4 *
5 * ===============================================================================
6 *
7 * Copyright (C)
8 *
9 * This program is free software; you can redistribute it and/or modify it under
10 * the terms of the GNU General Public License version 2, as published by the
11 * Free Software Foundation. See the file LICENSE.html for more information.
12 *
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY, including the implied warranty of MERCHANTABILITY or FITNESS
15 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * this program; if not, write to the Free Software Foundation, Inc. / 59 Temple
19 * Place, Suite 330 / Boston, MA 02111-1307 / USA.
20 *
21 * ===============================================================================
22 */

23
24 package org.infoglue.cms.applications.managementtool.actions;
25
26 import org.infoglue.cms.applications.common.actions.InfoGlueAbstractAction;
27 import org.infoglue.cms.controllers.kernel.impl.simple.UserControllerProxy;
28 import org.infoglue.cms.exception.ConstraintException;
29 import org.infoglue.cms.exception.SystemException;
30 import org.infoglue.cms.util.CmsPropertyHandler;
31
32 import webwork.action.Action;
33 import webwork.action.ActionContext;
34
35 /**
36  * This action makes it possible to change a users password for him/her.
37  *
38  * @author Mattias Bogeblad
39  */

40
41 public class UpdateSystemUserPasswordAction extends InfoGlueAbstractAction
42 {
43     private String JavaDoc userName;
44     private String JavaDoc oldPassword;
45     private String JavaDoc newPassword;
46     private String JavaDoc verifiedNewPassword;
47     private String JavaDoc returnAddress;
48     
49     public String JavaDoc doInput() throws Exception JavaDoc
50     {
51         return Action.INPUT;
52     }
53     
54     public String JavaDoc doInputStandalone() throws Exception JavaDoc
55     {
56         return "inputStandalone";
57     }
58     
59     protected String JavaDoc doExecute() throws Exception JavaDoc
60     {
61         if(userName.equals(CmsPropertyHandler.getAnonymousUser()))
62             throw new SystemException("You must not change password on this user as it's needed by the system.");
63
64         if(!newPassword.equals(verifiedNewPassword))
65             throw new ConstraintException("SystemUser.newPassword", "309");
66         
67         UserControllerProxy.getController().updateUserPassword(this.userName, this.oldPassword, this.newPassword);
68         
69         if(this.returnAddress != null && !this.returnAddress.equalsIgnoreCase(""))
70         {
71             ActionContext.getResponse().sendRedirect(returnAddress);
72             return Action.NONE;
73         }
74         else
75             return Action.SUCCESS;
76     }
77     
78     public String JavaDoc getNewPassword()
79     {
80         return newPassword;
81     }
82     
83     public void setNewPassword(String JavaDoc newPassword)
84     {
85         this.newPassword = newPassword;
86     }
87     
88     public String JavaDoc getOldPassword()
89     {
90         return oldPassword;
91     }
92     
93     public void setOldPassword(String JavaDoc oldPassword)
94     {
95         this.oldPassword = oldPassword;
96     }
97     
98     public String JavaDoc getUserName()
99     {
100         return userName;
101     }
102     
103     public void setUserName(String JavaDoc userName)
104     {
105         this.userName = userName;
106     }
107     
108     public String JavaDoc getVerifiedNewPassword()
109     {
110         return verifiedNewPassword;
111     }
112     
113     public void setVerifiedNewPassword(String JavaDoc verifiedNewPassword)
114     {
115         this.verifiedNewPassword = verifiedNewPassword;
116     }
117     
118     public String JavaDoc getReturnAddress()
119     {
120         return returnAddress;
121     }
122     
123     public void setReturnAddress(String JavaDoc returnAddress)
124     {
125         this.returnAddress = returnAddress;
126     }
127 }
128
Popular Tags