1 19 20 package com.sslexplorer.policyframework.actions; 21 22 import java.util.Collection ; 23 24 import javax.servlet.http.HttpServletRequest ; 25 import javax.servlet.http.HttpServletResponse ; 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.actions.AuthenticatedDispatchAction; 34 import com.sslexplorer.policyframework.Policy; 35 import com.sslexplorer.policyframework.PolicyDatabaseFactory; 36 import com.sslexplorer.policyframework.Resource; 37 import com.sslexplorer.policyframework.ResourceType; 38 import com.sslexplorer.policyframework.forms.ResourceInformationForm; 39 import com.sslexplorer.security.Constants; 40 import com.sslexplorer.security.SessionInfo; 41 42 47 public class ResourceInformationAction extends AuthenticatedDispatchAction { 48 49 final static Log log = LogFactory.getLog(ResourceInformationAction.class); 50 51 54 public ResourceInformationAction() { 55 super(); 56 } 57 58 public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) 59 throws Exception { 60 int resourceId = Integer.parseInt(request.getParameter("resourceId")); 61 int resourceTypeId = Integer.parseInt(request.getParameter("resourceType")); 62 ResourceType resourceType = PolicyDatabaseFactory.getInstance().getResourceType(resourceTypeId); 63 request.setAttribute(Constants.REQ_ATTR_INFO_RESOURCE, resourceType.getResourceById(resourceId)); 64 return information(mapping, form, request, response); 65 } 66 67 public ActionForward information(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) 68 throws Exception { 69 Resource r = (Resource)request.getAttribute(Constants.REQ_ATTR_INFO_RESOURCE); 70 Collection <Policy> policies = null; 71 if(r.getResourceType().isPolicyRequired()) { 72 policies = PolicyDatabaseFactory.getInstance().getPoliciesAttachedToResource(r, getSessionInfo(request).getRealm()); 73 } 74 ((ResourceInformationForm)form).initialise(r, policies); 75 return mapping.findForward("display"); 76 } 77 78 public ActionForward close(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) 79 throws Exception { 80 return new ActionForward(((ResourceInformationForm)form).getReferer(), true); 81 } 82 83 91 public int getNavigationContext(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { 92 return SessionInfo.ALL_CONTEXTS; 93 } 94 } | Popular Tags |