KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > agent > actions > ShutdownAgentAction


1 /*
2  * SSL-Explorer
3  *
4  * Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */

19             
20 package com.sslexplorer.agent.actions;
21
22 import javax.servlet.http.HttpServletRequest JavaDoc;
23 import javax.servlet.http.HttpServletResponse JavaDoc;
24
25 import org.apache.commons.logging.Log;
26 import org.apache.commons.logging.LogFactory;
27 import org.apache.struts.action.ActionForm;
28 import org.apache.struts.action.ActionForward;
29 import org.apache.struts.action.ActionMapping;
30 import org.apache.struts.action.ActionMessage;
31 import org.apache.struts.action.ActionMessages;
32
33 import com.sslexplorer.agent.DefaultAgentManager;
34 import com.sslexplorer.core.CoreUtil;
35 import com.sslexplorer.core.actions.AuthenticatedAction;
36 import com.sslexplorer.security.LogonControllerFactory;
37 import com.sslexplorer.security.SessionInfo;
38
39 /**
40  * Shuts down the VPN client.
41  *
42  * @author Brett Smith <a HREF="mailto: brett@3sp.com">&lt;brett@3sp.com&gt;</a>
43  */

44 public class ShutdownAgentAction extends AuthenticatedAction {
45
46     static Log log = LogFactory.getLog(ShutdownAgentAction.class);
47
48     /**
49      * Constructor
50      */

51     public ShutdownAgentAction() {
52         super();
53     }
54
55     /*
56      * (non-Javadoc)
57      *
58      * @see com.sslexplorer.core.actions.AuthenticatedAction#onExecute(org.apache.struts.action.ActionMapping,
59      * org.apache.struts.action.ActionForm,
60      * javax.servlet.http.HttpServletRequest,
61      * javax.servlet.http.HttpServletResponse)
62      */

63     public ActionForward onExecute(ActionMapping mapping, ActionForm form, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
64                     throws Exception JavaDoc {
65
66
67         SessionInfo session = LogonControllerFactory.getInstance().getSessionInfo(request);
68         
69         ActionMessages errs = new ActionMessages();
70         
71         if(session==null) {
72             errs.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("agent.notStarted"));
73             saveMessages(request, errs);
74         } else {
75             DefaultAgentManager.getInstance().unregisterAgent(session);
76         }
77         
78         String JavaDoc path = request.getParameter("path");
79         ActionForward fwd = new ActionForward(path==null ? CoreUtil.getReferer(request) : path, true);
80         return fwd;
81     }
82
83     /*
84      * (non-Javadoc)
85      *
86      * @see com.sslexplorer.core.actions.CoreAction#getNavigationContext(org.apache.struts.action.ActionMapping,
87      * org.apache.struts.action.ActionForm,
88      * javax.servlet.http.HttpServletRequest,
89      * javax.servlet.http.HttpServletResponse)
90      */

91     public int getNavigationContext(ActionMapping mapping, ActionForm form, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) {
92         return SessionInfo.MANAGEMENT_CONSOLE_CONTEXT | SessionInfo.USER_CONSOLE_CONTEXT;
93     }
94
95     /*
96      * (non-Javadoc)
97      *
98      * @see com.sslexplorer.core.actions.AuthenticatedAction#requiresProfile()
99      */

100     protected boolean requiresProfile() {
101         return false;
102     }
103
104     /*
105      * Ignore session lock as we want to be able logoff from the
106      * session lock page.
107      *
108      * @return ignore session locks
109      */

110     protected boolean isIgnoreSessionLock() {
111         return true;
112     }
113
114 }
Popular Tags