1 19 20 package com.sslexplorer.properties.actions; 21 22 import java.util.Iterator ; 23 import java.util.List ; 24 25 import javax.servlet.http.HttpServletRequest ; 26 import javax.servlet.http.HttpServletResponse ; 27 28 import org.apache.commons.logging.Log; 29 import org.apache.commons.logging.LogFactory; 30 import org.apache.struts.action.ActionForm; 31 import org.apache.struts.action.ActionForward; 32 import org.apache.struts.action.ActionMapping; 33 34 import com.sslexplorer.core.UserDatabaseManager; 35 import com.sslexplorer.policyframework.ResourceStack; 36 import com.sslexplorer.properties.ProfilesFactory; 37 import com.sslexplorer.properties.PropertyProfile; 38 import com.sslexplorer.properties.forms.ProfilePropertiesForm; 39 import com.sslexplorer.security.Constants; 40 41 46 public abstract class AbstractProfilePropertiesAction extends AbstractPropertiesAction { 47 static Log log = LogFactory.getLog(AbstractProfilePropertiesAction.class); 48 49 52 public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, 53 HttpServletResponse response) throws Exception { 54 super.unspecified(mapping, form, request, response); 55 ProfilePropertiesForm pf = (ProfilePropertiesForm)form; 56 57 if (pf.getSelectedPropertyProfile() == -1) { 58 if (request.getSession().getAttribute(Constants.SELECTED_PROFILE) != null) { 59 pf.setSelectedPropertyProfile(((PropertyProfile) request.getSession().getAttribute(Constants.SELECTED_PROFILE)).getResourceId()); 60 } else { 61 pf.setSelectedPropertyProfile(0); 62 } 63 } 64 PropertyProfile selectedPropertyProfile = ProfilesFactory.getInstance().getPropertyProfile(pf.getSelectedPropertyProfile()); 65 if (selectedPropertyProfile == null) { 66 selectedPropertyProfile = ProfilesFactory.getInstance().getPropertyProfile(getSessionInfo(request).getUser().getPrincipalName(), 67 "Default", getSessionInfo(request).getUser().getRealm().getResourceId()); 68 if (selectedPropertyProfile == null) { 69 selectedPropertyProfile = ProfilesFactory.getInstance().getPropertyProfile(null, "Default", 70 UserDatabaseManager.getInstance().getDefaultUserDatabase().getRealm().getResourceId()); 71 } 72 } 73 ResourceStack.pushToEditingStack(request.getSession(), selectedPropertyProfile); 74 75 List propertyProfiles = (List )request.getSession().getAttribute(Constants.PROFILES); 77 if (selectedPropertyProfile == null) { 78 for (Iterator i = propertyProfiles.iterator(); i.hasNext();) { 79 selectedPropertyProfile = (PropertyProfile) i.next(); 80 if (selectedPropertyProfile.getResourceName().equals("Default")) { 81 break; 82 } 83 } 84 } 85 pf.setPropertyProfiles(propertyProfiles); 86 pf.setSelectedPropertyProfile(selectedPropertyProfile.getResourceId()); 87 88 return rebuildItems(mapping, pf.getParentCategory(), pf, request, getSessionInfo(request).getUser()); 90 } 91 92 100 public ActionForward configureProfiles(ActionMapping mapping, ActionForm form, HttpServletRequest request, 101 HttpServletResponse response) throws Exception { 102 ResourceStack.popFromEditingStack(request.getSession()); 103 return mapping.findForward("configureProfiles"); 104 } 105 } | Popular Tags |