* from the security service
*/
public void doPerform(RunData data)
throws TurbineException
{
Configuration conf = Turbine.getConfiguration();
// Pull user from session.
data.populate();
// The user may have not logged in, so create a "guest/anonymous" user.
if (data.getUser() == null)
{
log.debug("Fixing up empty User Object!");
data.setUser(TurbineSecurity.getAnonymousUser());
data.save();
}
// Make sure the User has logged into the system.
if (!data.getUser().hasLoggedIn())
{
// only set the message if nothing else has already set it
// (e.g. the LogoutUser action).
if (StringUtils.isEmpty(data.getMessage()))
{
data.setMessage(conf.getString(TurbineConstants.LOGIN_MESSAGE));
}
// set the screen to be the login page
data.setScreen(conf.getString(TurbineConstants.SCREEN_LOGIN));
// We're not doing any actions buddy! (except action.login which
// will have been performed already)
data.setAction(null);
}
if (!data.hasScreen())
{
data.setMessage(conf.getString(
TurbineConstants.LOGIN_MESSAGE_NOSCREEN));
data.setScreen(conf.getString(TurbineConstants.SCREEN_HOMEPAGE));
}
if (data.getParameters().containsKey("_session_access_counter"))
{
// See comments in screens.error.InvalidState.
if (data.getParameters().getInt("_session_access_counter")
< (((Integer) data.getUser().getTemp(
"_session_access_counter")).intValue() - 1))
{
data.getUser().setTemp("prev_screen", data.getScreen());
data.getUser().setTemp("prev_parameters", data.getParameters());
data.setScreen(conf.getString(
TurbineConstants.SCREEN_INVALID_STATE));
data.setAction("");
}
}
}