diff options
Diffstat (limited to 'id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/util')
-rw-r--r-- | id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/util/HTTPSessionUtils.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/util/HTTPSessionUtils.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/util/HTTPSessionUtils.java new file mode 100644 index 000000000..a8eef06a7 --- /dev/null +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/util/HTTPSessionUtils.java @@ -0,0 +1,41 @@ +package at.gv.egovernment.moa.id.util; + +import javax.servlet.http.HttpSession; + +public class HTTPSessionUtils { + + public static boolean getHTTPSessionBoolean(HttpSession session, String name, boolean fallback) { + Object obj = session.getAttribute(name); + if(obj == null) { + return fallback; + } + + if(obj instanceof Boolean) { + Boolean b = (Boolean)obj; + if(b != null) { + return b.booleanValue(); + } + } + return fallback; + } + + public static void setHTTPSessionBoolean(HttpSession session, String name, boolean value) { + session.setAttribute(name, new Boolean(value)); + } + + public static String getHTTPSessionString(HttpSession session, String name, String fallback) { + Object obj = session.getAttribute(name); + if(obj == null) { + return fallback; + } + + if(obj instanceof String) { + return (String)obj; + } + return fallback; + } + + public static void setHTTPSessionString(HttpSession session, String name, String value) { + session.setAttribute(name, value); + } +} |