KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > setup > actions > SessionInformationAction


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.setup.actions;
21
22 import java.util.Arrays JavaDoc;
23
24 import javax.servlet.http.HttpServletRequest JavaDoc;
25 import javax.servlet.http.HttpServletResponse JavaDoc;
26
27 import org.apache.commons.logging.Log;
28 import org.apache.commons.logging.LogFactory;
29 import org.apache.struts.action.ActionForm;
30 import org.apache.struts.action.ActionForward;
31 import org.apache.struts.action.ActionMapping;
32
33 import com.sslexplorer.core.UserDatabaseManager;
34 import com.sslexplorer.core.actions.AuthenticatedDispatchAction;
35 import com.sslexplorer.policyframework.PolicyConstants;
36 import com.sslexplorer.policyframework.PolicyUtil;
37 import com.sslexplorer.policyframework.Principal;
38 import com.sslexplorer.policyframework.forms.PrincipalInformationForm;
39 import com.sslexplorer.security.Constants;
40 import com.sslexplorer.security.LogonControllerFactory;
41 import com.sslexplorer.security.Role;
42 import com.sslexplorer.security.SessionInfo;
43 import com.sslexplorer.setup.forms.SessionInformationForm;
44
45 /**
46  * Action that display details about a {@link SessionInfo}.
47  *
48  * @author Brett Smith <a HREF="mailto: brett@3sp.com">&lt;brett@3sp.com&gt;</a>
49  */

50 public class SessionInformationAction extends AuthenticatedDispatchAction {
51
52     final static Log log = LogFactory.getLog(SessionInformationAction.class);
53
54     /*
55      * (non-Javadoc)
56      *
57      * @see org.apache.struts.actions.DispatchAction#unspecified(org.apache.struts.action.ActionMapping,
58      * org.apache.struts.action.ActionForm,
59      * javax.servlet.http.HttpServletRequest,
60      * javax.servlet.http.HttpServletResponse)
61      */

62     public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest JavaDoc request,
63                                         HttpServletResponse JavaDoc response) throws Exception JavaDoc {
64         try {
65             PolicyUtil.checkPermission(PolicyConstants.STATUS_TYPE_RESOURCE_TYPE, PolicyConstants.PERM_VIEW, request);
66             String JavaDoc ticket = request.getParameter("ticket");
67             if(ticket == null) {
68                 throw new Exception JavaDoc("No ticket parameter supplied.");
69             }
70             SessionInfo info = LogonControllerFactory.getInstance().getSessionInfo(ticket);
71             request.setAttribute(Constants.REQ_ATTR_INFO_RESOURCE, info);
72             return sessionInformation(mapping, form, request, response);
73         } catch (Exception JavaDoc e) {
74             log.error("Failed to get session information. ", e);
75             response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
76         }
77         return null;
78     }
79
80     /**
81      * @param mapping
82      * @param form
83      * @param request
84      * @param response
85      * @return ActionForward
86      * @throws Exception
87      */

88     public ActionForward sessionInformation(ActionMapping mapping, ActionForm form, HttpServletRequest JavaDoc request,
89                                                 HttpServletResponse JavaDoc response) throws Exception JavaDoc {
90         SessionInformationForm informationForm = (SessionInformationForm) form;
91         SessionInfo session = (SessionInfo) request.getAttribute(Constants.REQ_ATTR_INFO_RESOURCE);
92         informationForm.initialise(session);
93         return mapping.findForward("display");
94     }
95
96     /*
97      * (non-Javadoc)
98      *
99      * @see com.sslexplorer.core.actions.CoreAction#getNavigationContext(org.apache.struts.action.ActionMapping,
100      * org.apache.struts.action.ActionForm,
101      * javax.servlet.http.HttpServletRequest,
102      * javax.servlet.http.HttpServletResponse)
103      */

104     public int getNavigationContext(ActionMapping mapping, ActionForm form, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) {
105         return SessionInfo.MANAGEMENT_CONSOLE_CONTEXT;
106     }
107 }
Popular Tags