1 19 20 package com.sslexplorer.policyframework.actions; 21 22 import java.util.List ; 23 24 import javax.servlet.http.HttpServletRequest ; 25 import javax.servlet.http.HttpServletResponse ; 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 54 public class AccessRightsListDispatchAction extends AbstractResourcesDispatchAction { 55 56 59 public AccessRightsListDispatchAction() { 60 super(PolicyConstants.ACCESS_RIGHTS_RESOURCE_TYPE, null, null, null, null, null); 61 } 62 63 66 public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, 67 HttpServletResponse response) throws Exception { 68 AccessRightsListForm accessRightsListForm = (AccessRightsListForm) form; 69 User user = LogonControllerFactory.getInstance().getUser(request); 70 List 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 78 protected void checkValid(Resource r, Permission[] permission, ActionMapping mapping, AbstractResourcesForm form, 79 HttpServletRequest request) throws NoPermissionException { 80 ResourceUtil.checkAccessRightsValid((AccessRights) r, getSessionInfo(request), ((CoreForm) form).getActionTarget()); 81 } 82 83 86 public int getNavigationContext(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { 87 return SessionInfo.MANAGEMENT_CONSOLE_CONTEXT; 88 } 89 90 @Override 91 protected void doRemove(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { 92 super.doRemove(mapping, form, request, response); 93 LogonControllerFactory.getInstance().applyMenuItemChanges(request); 95 } 96 } | Popular Tags |