public String readValue(HttpServletRequest request, HttpServletResponse ignored) { String name = getName(); String value = null; javax.servlet.http.Cookie cookie = getCookie(request, name); if (cookie != null) { // Validate that the cookie is used at the correct place. String path = StringUtils.clean(getPath()); if (path != null && !pathMatches(path, request.getRequestURI())) { log.warn("Found '{}' cookie at path '{}', but should be only used for '{}'", new Object[] { name, request.getRequestURI(), path}); } else { value = cookie.getValue(); log.debug("Found '{}' cookie value [{}]", name, value); } } else { log.trace("No '{}' cookie value", name); } return value; }
public void removeFrom(HttpServletRequest request, HttpServletResponse response) { String name = getName(); String value = DELETED_COOKIE_VALUE; String comment = null; //don't need to add extra size to the response - comments are irrelevant for deletions String domain = getDomain(); String path = calculatePath(request); int maxAge = 0; //always zero for deletion int version = getVersion(); boolean secure = isSecure(); boolean httpOnly = false; //no need to add the extra text, plus the value 'deleteMe' is not sensitive at all addCookieHeader(response, name, value, comment, domain, path, maxAge, version, secure, httpOnly); log.trace("Removed '{}' cookie by setting maxAge=0", name); }
public void saveTo(HttpServletRequest request, HttpServletResponse response) { String name = getName(); String value = getValue(); String comment = getComment(); String domain = getDomain(); String path = calculatePath(request); int maxAge = getMaxAge(); int version = getVersion(); boolean secure = isSecure(); boolean httpOnly = isHttpOnly(); addCookieHeader(response, name, value, comment, domain, path, maxAge, version, secure, httpOnly); }