KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > policyframework > actions > AccessRightsListDispatchAction


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.policyframework.actions;
21
22 import java.util.List JavaDoc;
23
24 import javax.servlet.http.HttpServletRequest JavaDoc;
25 import javax.servlet.http.HttpServletResponse JavaDoc;
26
27 import org.apache.struts.action.ActionForm;
28 import org.apache.struts.action.ActionForward;
29 import org.apache.struts.action.ActionMapping;
30
31 import com.sslexplorer.core.forms.CoreForm;
32 import com.sslexplorer.navigation.MenuTree;
33 import com.sslexplorer.policyframework.AccessRights;
34 import com.sslexplorer.policyframework.AccessRightsItem;
35 import com.sslexplorer.policyframework.NoPermissionException;
36 import com.sslexplorer.policyframework.Permission;
37 import com.sslexplorer.policyframework.PolicyConstants;
38 import com.sslexplorer.policyframework.PolicyDatabaseFactory;
39 import com.sslexplorer.policyframework.Resource;
40 import com.sslexplorer.policyframework.ResourceUtil;
41 import com.sslexplorer.policyframework.forms.AbstractResourcesForm;
42 import com.sslexplorer.policyframework.forms.AccessRightsListForm;
43 import com.sslexplorer.security.LogonControllerFactory;
44 import com.sslexplorer.security.SessionInfo;
45 import com.sslexplorer.security.User;
46
47 /**
48  * Implementation of a
49  * {@link com.sslexplorer.policyframework.actions.AbstractResourcesDispatchAction}
50  * that allows listing and maintenance of <i>Resource Permissions</i>.
51  *
52  * @author Brett Smith <a HREF="mailto: brett@3sp.com">&lt;brett@3sp.com&gt;</a>
53  */

54 public class AccessRightsListDispatchAction extends AbstractResourcesDispatchAction {
55
56     /**
57      * Constructor
58      */

59     public AccessRightsListDispatchAction() {
60         super(PolicyConstants.ACCESS_RIGHTS_RESOURCE_TYPE, null, null, null, null, null);
61     }
62
63     /* (non-Javadoc)
64      * @see org.apache.struts.actions.DispatchAction#unspecified(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
65      */

66     public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest JavaDoc request,
67                     HttpServletResponse JavaDoc response) throws Exception JavaDoc {
68         AccessRightsListForm accessRightsListForm = (AccessRightsListForm) form;
69         User user = LogonControllerFactory.getInstance().getUser(request);
70         List JavaDoc resourcePermissions = PolicyDatabaseFactory.getInstance().getAccessRights(user.getRealm().getRealmID());
71         accessRightsListForm.initialize(resourcePermissions, AccessRightsItem.class, request.getSession());
72         return super.unspecified(mapping, form, request, response);
73     }
74
75     /* (non-Javadoc)
76      * @see com.sslexplorer.policyframework.actions.AbstractResourcesDispatchAction#checkValid(com.sslexplorer.policyframework.Resource, com.sslexplorer.policyframework.Permission, org.apache.struts.action.ActionMapping, com.sslexplorer.policyframework.forms.AbstractResourcesForm, javax.servlet.http.HttpServletRequest)
77      */

78     protected void checkValid(Resource r, Permission[] permission, ActionMapping mapping, AbstractResourcesForm form,
79                     HttpServletRequest JavaDoc request) throws NoPermissionException {
80         ResourceUtil.checkAccessRightsValid((AccessRights) r, getSessionInfo(request), ((CoreForm) form).getActionTarget());
81     }
82
83     /* (non-Javadoc)
84      * @see com.sslexplorer.core.actions.CoreAction#getNavigationContext(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
85      */

86     public int getNavigationContext(ActionMapping mapping, ActionForm form, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) {
87         return SessionInfo.MANAGEMENT_CONSOLE_CONTEXT;
88     }
89
90     @Override JavaDoc
91     protected void doRemove(ActionMapping mapping, ActionForm form, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) throws Exception JavaDoc {
92         super.doRemove(mapping, form, request, response);
93         // we now need to rebuild any menus, as more or less could be visable.
94
LogonControllerFactory.getInstance().applyMenuItemChanges(request);
95     }
96 }
Popular Tags