All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.anotheria.anosite.guard.SessionFlagPresentGuard Maven / Gradle / Ivy

There is a newer version: 4.1.2
Show newest version
package net.anotheria.anosite.guard;

import jakarta.servlet.http.HttpServletRequest;

import net.anotheria.asg.data.DataObject;

/**
 * A guard which only returns true if the desired attribute is in session.
 * @author lrosenberg
 *
 */
public abstract class SessionFlagPresentGuard implements ConditionalGuard{

	@Override
	public boolean isConditionFullfilled(DataObject object, HttpServletRequest req) {
		return (req.getSession().getAttribute(getFlagName())!=null) == getDesiredResult();
	}
	
	/**
	 * If true the guard is fullfilled whenever the attribute with name = flagName is in session. If false the guard is fullfilled if the attribute with the name = flagName is NOT in session.
	 */
	protected boolean getDesiredResult(){
		return true;
	}
	/**
	 * Returns the name of the flag to look after.
	 * @return flag name.
	 */
	protected abstract String getFlagName();
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy