📄 showselectauthenticationschemeaction.java
字号:
/*
* SSL-Explorer
*
* Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package com.sslexplorer.security.actions;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.Globals;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import org.apache.struts.util.LabelValueBean;
import com.sslexplorer.core.CoreServlet;
import com.sslexplorer.core.CoreUtil;
import com.sslexplorer.core.actions.DefaultAction;
import com.sslexplorer.policyframework.PolicyConstants;
import com.sslexplorer.policyframework.PolicyDatabase;
import com.sslexplorer.policyframework.ResourceUtil;
import com.sslexplorer.security.AuthenticationSchemeSequence;
import com.sslexplorer.security.Constants;
import com.sslexplorer.security.SessionInfo;
import com.sslexplorer.security.forms.SchemeSelectionForm;
/**
* Action to allow a new visitor to select the <i>Authentication Scheme</i>
* they wish to use.
*
* @author Brett Smith <a href="mailto: brett@3sp.com"><brett@3sp.com></a>
* @version $Revision: 1.11 $
*/
public class ShowSelectAuthenticationSchemeAction extends DefaultAction {
final static Log log = LogFactory.getLog(ShowSelectAuthenticationSchemeAction.class);
/*
* (non-Javadoc)
*
* @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping,
* org.apache.struts.action.ActionForm,
* javax.servlet.http.HttpServletRequest,
* javax.servlet.http.HttpServletResponse)
*/
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws Exception {
ActionForward fwd = super.execute(mapping, form, request, response);
if (fwd != null) {
return fwd;
}
if (request.getSession().getAttribute(Constants.SESSION_LOCKED) != null) {
ActionMessages messages = new ActionMessages();
messages.add(Globals.MESSAGE_KEY, new ActionMessage("login.sessionLocked"));
saveMessages(request, messages);
}
String selectedScheme = CoreServlet.getServlet().getPropertyDatabase().getProperty(0, null, "authenticationScheme.default");
List l = new ArrayList();
List schemes = CoreServlet.getServlet().getSystemDatabase().getAuthenticationSchemeSequences();
String user = request.getParameter("username");
List resourceIds = new ArrayList();
if (user != null || !user.equals("")) {
resourceIds = CoreServlet.getServlet().getPolicyDatabase().getGrantedResourcesOfType(
CoreServlet.getServlet().getUserDatabase().getAccount(user),
PolicyConstants.AUTHENTICATION_SCHEMES_RESOURCE_TYPE);
}
for (Iterator i = schemes.iterator(); i.hasNext();) {
AuthenticationSchemeSequence seq = (AuthenticationSchemeSequence) i.next();
if (!seq.isSystemScheme() && seq.getEnabled() && resourceIds.contains(new Integer(seq.getResourceId()))) {
LabelValueBean lvb = new LabelValueBean(seq.getResourceName(), String.valueOf(seq.getResourceId()));
l.add(lvb);
}
}
((SchemeSelectionForm) form).setAuthenticationSchemes(l);
((SchemeSelectionForm) form).setSelectedAuthenticationScheme(selectedScheme);
return mapping.findForward("success");
}
/*
* (non-Javadoc)
*
* @see com.sslexplorer.core.actions.CoreAction#getNavigationContext(org.apache.struts.action.ActionMapping,
* org.apache.struts.action.ActionForm,
* javax.servlet.http.HttpServletRequest,
* javax.servlet.http.HttpServletResponse)
*/
public int getNavigationContext(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
return SessionInfo.ALL_CONTEXTS;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -