1 19 20 package com.sslexplorer.security.actions; 21 22 import javax.servlet.http.HttpServletRequest ; 23 import javax.servlet.http.HttpServletResponse ; 24 25 import org.apache.commons.logging.Log; 26 import org.apache.commons.logging.LogFactory; 27 import org.apache.struts.Globals; 28 import org.apache.struts.action.ActionForm; 29 import org.apache.struts.action.ActionForward; 30 import org.apache.struts.action.ActionMapping; 31 import org.apache.struts.action.ActionMessage; 32 import org.apache.struts.action.ActionMessages; 33 34 import com.sslexplorer.boot.PropertyList; 35 import com.sslexplorer.input.MultiSelectDataSource; 36 import com.sslexplorer.input.MultiSelectSelectionModel; 37 import com.sslexplorer.policyframework.PolicyConstants; 38 import com.sslexplorer.policyframework.Resource; 39 import com.sslexplorer.policyframework.actions.AbstractResourceDispatchAction; 40 import com.sslexplorer.policyframework.forms.AbstractResourceForm; 41 import com.sslexplorer.security.AuthenticationScheme; 42 import com.sslexplorer.security.DefaultAuthenticationScheme; 43 import com.sslexplorer.security.LogonControllerFactory; 44 import com.sslexplorer.security.ModulesDataSource; 45 import com.sslexplorer.security.SessionInfo; 46 import com.sslexplorer.security.forms.AuthenticationSchemeForm; 47 48 58 public class EditAuthenticationSchemeDispatchAction extends AbstractResourceDispatchAction { 59 60 static Log log = LogFactory.getLog(EditAuthenticationSchemeDispatchAction.class); 61 62 65 public EditAuthenticationSchemeDispatchAction() { 66 super(PolicyConstants.AUTHENTICATION_SCHEMES_RESOURCE_TYPE); 67 } 68 69 77 public int getNavigationContext(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { 78 return SessionInfo.MANAGEMENT_CONSOLE_CONTEXT; 79 } 80 81 89 public Resource createResource(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) 90 throws Exception { 91 return null; } 93 94 102 public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) 103 throws Exception { 104 ActionForward fwd = super.edit(mapping, form, request, response); 105 PropertyList selectedModules = new PropertyList(); 106 SessionInfo session = LogonControllerFactory.getInstance().getSessionInfo(request); 107 MultiSelectDataSource modules = new ModulesDataSource("security"); 108 AuthenticationScheme seq = ((DefaultAuthenticationScheme) ((AbstractResourceForm) form).getResource()); 109 for (int i = 0; i < seq.getModuleCount(); i++) { 110 String module = seq.getModule(i); 111 selectedModules.add(module); 112 } 113 MultiSelectSelectionModel moduleModel = new MultiSelectSelectionModel(session, modules, selectedModules); 114 ((AuthenticationSchemeForm) form).setModuleModel(moduleModel); 115 ((AuthenticationSchemeForm) form).setSelectedModulesList(selectedModules); 116 return fwd; 117 } 118 119 122 public ActionForward commit(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) 123 throws Exception { 124 ActionMessages msgs = new ActionMessages(); 125 msgs.add(Globals.MESSAGE_KEY, new ActionMessage("editAuthenticationScheme.message.saved")); 126 this.addMessages(request, msgs); 127 return super.commit(mapping, form, request, response); 128 } 129 130 } | Popular Tags |