1 19 20 package com.sslexplorer.navigation.actions; 21 22 import java.util.List ; 23 24 import javax.servlet.http.HttpServletRequest ; 25 import javax.servlet.http.HttpServletResponse ; 26 27 import org.apache.struts.action.ActionForm; 28 import org.apache.struts.action.ActionForward; 29 import org.apache.struts.action.ActionMapping; 30 31 import com.sslexplorer.core.CoreUtil; 32 import com.sslexplorer.core.actions.AuthenticatedAction; 33 import com.sslexplorer.navigation.forms.ProfileSelectionForm; 34 import com.sslexplorer.properties.ProfilesListDataSource; 35 import com.sslexplorer.properties.Property; 36 import com.sslexplorer.properties.impl.userattributes.UserAttributeKey; 37 import com.sslexplorer.security.Constants; 38 import com.sslexplorer.security.LogonController; 39 import com.sslexplorer.security.LogonControllerFactory; 40 import com.sslexplorer.security.SessionInfo; 41 import com.sslexplorer.security.User; 42 43 48 49 public class ShowSelectPropertyProfileAction extends AuthenticatedAction { 50 51 54 public ActionForward onExecute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) 55 throws Exception { 56 ProfileSelectionForm profileSelectionForm = (ProfileSelectionForm) form; 57 if (LogonControllerFactory.getInstance().hasClientLoggedOn(request, response) != LogonController.LOGGED_ON) { 58 throw new Exception ("You must be logged on to select a property."); 59 } 60 List propertyProfiles = null; 61 int selectedPropertyProfile = 0; 62 User user = LogonControllerFactory.getInstance().getUser(request); 63 if (user != null) { 64 propertyProfiles = (List )request.getSession().getAttribute(Constants.PROFILES); 65 String selectedProfile = Property.getProperty(new UserAttributeKey(user, User.USER_STARTUP_PROFILE)); 66 if(selectedProfile.equals(ProfilesListDataSource.SELECT_ON_LOGIN)) { 67 selectedPropertyProfile = 0; 68 } 69 else { 70 try { 71 selectedPropertyProfile = Integer.parseInt(selectedProfile); 72 } 73 catch(NumberFormatException nfe) { 74 selectedPropertyProfile = 0; 75 } 76 } 77 } else { 78 throw new Exception ("Not logged on."); 79 } 80 profileSelectionForm.setReferer(CoreUtil.getReferer(request)); 81 profileSelectionForm.setPropertyProfiles(propertyProfiles); 82 profileSelectionForm.setSelectedPropertyProfile(selectedPropertyProfile); 83 return mapping.findForward("success"); 84 } 85 86 89 public boolean requiresProfile() { 90 return false; 92 } 93 94 95 @Override 96 public ActionForward checkIntercept(ActionMapping mapping, HttpServletRequest request, HttpServletResponse response) throws Exception { 97 return null; 98 } 99 100 103 public int getNavigationContext(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { 104 return SessionInfo.ALL_CONTEXTS; 105 } 106 } | Popular Tags |