1 package org.apache.turbine.modules.actions.sessionvalidator; 2 3 18 19 import org.apache.commons.configuration.Configuration; 20 21 import org.apache.commons.lang.StringUtils; 22 23 import org.apache.commons.logging.Log; 24 import org.apache.commons.logging.LogFactory; 25 26 import org.apache.turbine.Turbine; 27 import org.apache.turbine.TurbineConstants; 28 29 import org.apache.turbine.services.security.TurbineSecurity; 30 31 import org.apache.turbine.util.RunData; 32 import org.apache.turbine.util.TurbineException; 33 34 58 public class DefaultSessionValidator 59 extends SessionValidator 60 { 61 62 private static Log log = LogFactory.getLog(DefaultSessionValidator.class); 63 64 74 public void doPerform(RunData data) 75 throws TurbineException 76 { 77 Configuration conf = Turbine.getConfiguration(); 78 79 data.populate(); 81 82 if (data.getUser() == null) 84 { 85 log.debug("Fixing up empty User Object!"); 86 data.setUser(TurbineSecurity.getAnonymousUser()); 87 data.save(); 88 } 89 90 if (!data.getUser().hasLoggedIn()) 92 { 93 if (StringUtils.isEmpty(data.getMessage())) 96 { 97 data.setMessage(conf.getString(TurbineConstants.LOGIN_MESSAGE)); 98 } 99 100 data.setScreen(conf.getString(TurbineConstants.SCREEN_LOGIN)); 102 103 data.setAction(null); 106 } 107 108 if (!data.hasScreen()) 109 { 110 data.setMessage(conf.getString( 111 TurbineConstants.LOGIN_MESSAGE_NOSCREEN)); 112 data.setScreen(conf.getString(TurbineConstants.SCREEN_HOMEPAGE)); 113 } 114 115 if (data.getParameters().containsKey("_session_access_counter")) 116 { 117 if (data.getParameters().getInt("_session_access_counter") 119 < (((Integer ) data.getUser().getTemp( 120 "_session_access_counter")).intValue() - 1)) 121 { 122 data.getUser().setTemp("prev_screen", data.getScreen()); 123 data.getUser().setTemp("prev_parameters", data.getParameters()); 124 data.setScreen(conf.getString( 125 TurbineConstants.SCREEN_INVALID_STATE)); 126 data.setAction(""); 127 } 128 } 129 } 130 } 131 | Popular Tags |