1 19 20 package com.sslexplorer.security.actions; 21 22 import java.util.ArrayList ; 23 import java.util.Iterator ; 24 import java.util.List ; 25 26 import javax.servlet.http.HttpServletRequest ; 27 import javax.servlet.http.HttpServletResponse ; 28 29 import org.apache.commons.logging.Log; 30 import org.apache.commons.logging.LogFactory; 31 import org.apache.struts.Globals; 32 import org.apache.struts.action.ActionForm; 33 import org.apache.struts.action.ActionForward; 34 import org.apache.struts.action.ActionMapping; 35 import org.apache.struts.action.ActionMessage; 36 import org.apache.struts.action.ActionMessages; 37 import org.apache.struts.util.LabelValueBean; 38 39 import com.sslexplorer.core.actions.DefaultAction; 40 import com.sslexplorer.security.AuthenticationScheme; 41 import com.sslexplorer.security.Constants; 42 import com.sslexplorer.security.DefaultAuthenticationScheme; 43 import com.sslexplorer.security.LogonStateAndCache; 44 import com.sslexplorer.security.SessionInfo; 45 import com.sslexplorer.security.forms.SchemeSelectionForm; 46 47 53 public class ShowSelectAuthenticationSchemeAction extends DefaultAction { 54 55 final static Log log = LogFactory.getLog(ShowSelectAuthenticationSchemeAction.class); 56 57 65 public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) 66 throws Exception { 67 ActionForward fwd = super.execute(mapping, form, request, response); 68 if (fwd != null) { 69 return fwd; 70 } 71 if (request.getSession().getAttribute(Constants.SESSION_LOCKED) != null) { 72 ActionMessages messages = new ActionMessages(); 73 messages.add(Globals.MESSAGE_KEY, new ActionMessage("login.sessionLocked")); 74 saveMessages(request, messages); 75 } 76 77 LogonStateAndCache logonStateMachine = (LogonStateAndCache) request.getSession().getAttribute( 78 LogonStateAndCache.LOGON_STATE_MACHINE); 79 if (logonStateMachine == null) { 80 return new ActionForward("/showLogon.do"); 82 } else { 83 List <LabelValueBean> l = new ArrayList <LabelValueBean>(); 84 for (Iterator i = logonStateMachine.getAuthSchemes().iterator(); i.hasNext();) { 85 AuthenticationScheme seq = (DefaultAuthenticationScheme) i.next(); 86 LabelValueBean lvb = new LabelValueBean(seq.getResourceName(), String.valueOf(seq.getResourceId())); 87 l.add(lvb); 88 } 89 logonStateMachine.setState(LogonStateAndCache.STATE_KNOWN_USERNAME_MULTIPLE_SCHEMES_SELECT); 90 ((SchemeSelectionForm) form).setAuthenticationSchemes(l); 91 return mapping.findForward("success"); 92 } 93 } 94 95 103 public int getNavigationContext(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { 104 return SessionInfo.ALL_CONTEXTS; 105 } 106 } | Popular Tags |