diff --git a/src/fr/devinsy/kiss4web/CookieHelper.java b/src/fr/devinsy/kiss4web/CookieHelper.java index 33e0a6d..23559f2 100644 --- a/src/fr/devinsy/kiss4web/CookieHelper.java +++ b/src/fr/devinsy/kiss4web/CookieHelper.java @@ -12,6 +12,11 @@ import org.slf4j.LoggerFactory; */ public class CookieHelper { + public enum Scope + { + HTTP_AND_HTTPS, HTTPS_ONLY + } + static private final Logger logger = LoggerFactory.getLogger(CookieHelper.class); /** @@ -21,7 +26,7 @@ public class CookieHelper { Cookie result; - result = buildCookie(name, value, duration, false); + result = buildCookie(name, value, duration, Scope.HTTP_AND_HTTPS); // return (result); @@ -30,14 +35,26 @@ public class CookieHelper /** * */ - static public Cookie buildCookie(final String name, final String value, final int duration, final boolean isSecure) + static public Cookie buildCookie(final String name, final String value, final int duration, final Scope secure) { Cookie result; + // result = new Cookie(name, value); result.setMaxAge(duration); result.setPath("/"); - result.setSecure(isSecure); + + // + boolean secureValue; + if (secure == Scope.HTTPS_ONLY) + { + secureValue = true; + } + else + { + secureValue = false; + } + result.setSecure(secureValue); // return (result);