KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > security > actions > EditAuthenticationSchemeDispatchAction


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.security.actions;
21
22 import javax.servlet.http.HttpServletRequest JavaDoc;
23 import javax.servlet.http.HttpServletResponse JavaDoc;
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 /**
49  * Extension of
50  * {@link com.sslexplorer.policyframework.actions.AbstractResourceDispatchAction}
51  * that allows an administrator to edit the details of an application shortcut.
52  * <p>
53  * The type of application cannot be changed, only the usual resources details
54  * and the short specific values of the application extensions parameters.
55  *
56  * @author Brett Smith <a HREF="mailto: brett@3sp.com">&lt;brett@3sp.com&gt;</a>
57  */

58 public class EditAuthenticationSchemeDispatchAction extends AbstractResourceDispatchAction {
59
60     static Log log = LogFactory.getLog(EditAuthenticationSchemeDispatchAction.class);
61
62     /**
63      * Constructor.
64      */

65     public EditAuthenticationSchemeDispatchAction() {
66         super(PolicyConstants.AUTHENTICATION_SCHEMES_RESOURCE_TYPE);
67     }
68
69     /*
70      * (non-Javadoc)
71      *
72      * @see com.sslexplorer.core.actions.CoreAction#getNavigationContext(org.apache.struts.action.ActionMapping,
73      * org.apache.struts.action.ActionForm,
74      * javax.servlet.http.HttpServletRequest,
75      * javax.servlet.http.HttpServletResponse)
76      */

77     public int getNavigationContext(ActionMapping mapping, ActionForm form, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) {
78         return SessionInfo.MANAGEMENT_CONSOLE_CONTEXT;
79     }
80
81     /*
82      * (non-Javadoc)
83      *
84      * @see com.sslexplorer.policyframework.actions.AbstractResourceDispatchAction#createResource(org.apache.struts.action.ActionMapping,
85      * org.apache.struts.action.ActionForm,
86      * javax.servlet.http.HttpServletRequest,
87      * javax.servlet.http.HttpServletResponse)
88      */

89     public Resource createResource(ActionMapping mapping, ActionForm form, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
90                     throws Exception JavaDoc {
91         return null;//the wizard creates.
92
}
93
94     /*
95      * (non-Javadoc)
96      *
97      * @see com.sslexplorer.policyframework.actions.AbstractResourceDispatchAction#edit(org.apache.struts.action.ActionMapping,
98      * org.apache.struts.action.ActionForm,
99      * javax.servlet.http.HttpServletRequest,
100      * javax.servlet.http.HttpServletResponse)
101      */

102     public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
103                     throws Exception JavaDoc {
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 JavaDoc 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     /* (non-Javadoc)
120      * @see com.sslexplorer.policyframework.actions.AbstractResourceDispatchAction#commit(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
121      */

122     public ActionForward commit(ActionMapping mapping, ActionForm form, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
123                     throws Exception JavaDoc {
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