KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jresearch > gossip > actions > admin > SetMailPasswordAction


1 /*
2  * $$Id: SetMailPasswordAction.java,v 1.3 2005/06/07 12:32:27 bel70 Exp $$
3  *
4  * ***** BEGIN LICENSE BLOCK ***** The contents of this file are subject to the
5  * Mozilla Public License Version 1.1 (the "License"); you may not use this file
6  * except in compliance with the License. You may obtain a copy of the License
7  * at http://www.mozilla.org/MPL/
8  *
9  * Software distributed under the License is distributed on an "AS IS" basis,
10  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
11  * the specific language governing rights and limitations under the License.
12  *
13  * The Original Code is JGossip forum code.
14  *
15  * The Initial Developer of the Original Code is the JResearch, Org. Portions
16  * created by the Initial Developer are Copyright (C) 2004 the Initial
17  * Developer. All Rights Reserved.
18  *
19  * Contributor(s): Dmitry Belov <bel@jresearch.org>
20  *
21  * ***** END LICENSE BLOCK *****
22  */

23 /*
24  * Created on Oct 30, 2003
25  *
26  */

27 package org.jresearch.gossip.actions.admin;
28
29 import java.sql.SQLException JavaDoc;
30 import java.util.HashMap JavaDoc;
31
32 import javax.servlet.http.HttpServletRequest JavaDoc;
33 import javax.servlet.http.HttpServletResponse JavaDoc;
34
35 import org.apache.struts.action.ActionForm;
36 import org.apache.struts.action.ActionForward;
37 import org.apache.struts.action.ActionMapping;
38 import org.jresearch.gossip.IConst;
39 import org.jresearch.gossip.actions.BaseAction;
40 import org.jresearch.gossip.configuration.Configurator;
41 import org.jresearch.gossip.dao.ForumDAO;
42 import org.jresearch.gossip.exception.SystemException;
43 import org.jresearch.gossip.forms.MailPasswordForm;
44 import org.jresearch.gossip.mail.MailProcessor;
45 import org.jresearch.gossip.util.DesEncrypter;
46
47 /**
48  * DOCUMENT ME!
49  *
50  * @author dbelov
51  */

52 public class SetMailPasswordAction extends BaseAction {
53     /*
54      * (non-Javadoc)
55      *
56      * @see org.jresearch.gossip.actions.BaseAction#process(org.apache.struts.action.ActionMapping,
57      * org.apache.struts.action.ActionForm,
58      * javax.servlet.http.HttpServletRequest,
59      * javax.servlet.http.HttpServletResponse)
60      */

61     public ActionForward process(ActionMapping mapping, ActionForm form,
62             HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
63             throws SystemException {
64         ForumDAO dao = ForumDAO.getInstance();
65         try {
66
67             HashMap JavaDoc map = new HashMap JavaDoc();
68             DesEncrypter encrypter = new DesEncrypter(
69                     IConst.VALUES.ENCRYPTER_KEY);
70             map.put(IConst.CONFIG.MAILPASSWORD, encrypter
71                     .encrypt(((MailPasswordForm) form).getPassword()));
72             dao.updateConstants(map);
73             Configurator.getInstance().reload(getServlet().getServletContext());
74             MailProcessor._mailSession = null;
75             log(request, "status.UPDATE_MAILPASSWORD");
76             setStatusMessage(request, "status.UPDATE_MAILPASSWORD");
77         } catch (SQLException JavaDoc sqle) {
78             getServlet().log("Connection.process", sqle);
79             throw new SystemException(sqle);
80         } catch (Exception JavaDoc e) {
81             throw new SystemException(e);
82         }
83         return (mapping.findForward(IConst.TOKEN.PAGE));
84     }
85 }
Popular Tags