org.springframework.web.util

Class CookieGenerator

  • java.lang.Object
    • org.springframework.web.util.CookieGenerator
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static java.lang.String DEFAULT_COOKIE_PATH
      Default path that cookies will be visible to: "/", i.e.
      protected Log logger 
    • Constructor Summary

      Constructors 
      Constructor and Description
      CookieGenerator() 
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void addCookie(HttpServletResponse response, java.lang.String cookieValue)
      Add a cookie with the given value to the response, using the cookie descriptor settings of this generator.
      protected Cookie createCookie(java.lang.String cookieValue)
      Create a cookie with the given value, using the cookie descriptor settings of this generator (except for "cookieMaxAge").
      java.lang.String getCookieDomain()
      Return the domain for cookies created by this generator, if any.
      java.lang.Integer getCookieMaxAge()
      Return the maximum age for cookies created by this generator.
      java.lang.String getCookieName()
      Return the given name for cookies created by this generator.
      java.lang.String getCookiePath()
      Return the path for cookies created by this generator.
      boolean isCookieHttpOnly()
      Return whether the cookie is supposed to be marked with the "HttpOnly" attribute.
      boolean isCookieSecure()
      Return whether the cookie should only be sent using a secure protocol, such as HTTPS (SSL).
      void removeCookie(HttpServletResponse response)
      Remove the cookie that this generator describes from the response.
      void setCookieDomain(java.lang.String cookieDomain)
      Use the given domain for cookies created by this generator.
      void setCookieHttpOnly(boolean cookieHttpOnly)
      Set whether the cookie is supposed to be marked with the "HttpOnly" attribute.
      void setCookieMaxAge(java.lang.Integer cookieMaxAge)
      Use the given maximum age (in seconds) for cookies created by this generator.
      void setCookieName(java.lang.String cookieName)
      Use the given name for cookies created by this generator.
      void setCookiePath(java.lang.String cookiePath)
      Use the given path for cookies created by this generator.
      void setCookieSecure(boolean cookieSecure)
      Set whether the cookie should only be sent using a secure protocol, such as HTTPS (SSL).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_COOKIE_PATH

        public static final java.lang.String DEFAULT_COOKIE_PATH
        Default path that cookies will be visible to: "/", i.e. the entire server.
        See Also:
        Constant Field Values
      • logger

        protected final Log logger
    • Constructor Detail

      • CookieGenerator

        public CookieGenerator()
    • Method Detail

      • setCookieName

        public void setCookieName(@Nullable
                                  java.lang.String cookieName)
        Use the given name for cookies created by this generator.
        See Also:
        Cookie.getName()
      • getCookieName

        @Nullable
        public java.lang.String getCookieName()
        Return the given name for cookies created by this generator.
      • setCookieDomain

        public void setCookieDomain(@Nullable
                                    java.lang.String cookieDomain)
        Use the given domain for cookies created by this generator. The cookie is only visible to servers in this domain.
        See Also:
        Cookie.setDomain(java.lang.String)
      • getCookieDomain

        @Nullable
        public java.lang.String getCookieDomain()
        Return the domain for cookies created by this generator, if any.
      • setCookiePath

        public void setCookiePath(java.lang.String cookiePath)
        Use the given path for cookies created by this generator. The cookie is only visible to URLs in this path and below.
        See Also:
        Cookie.setPath(java.lang.String)
      • getCookiePath

        public java.lang.String getCookiePath()
        Return the path for cookies created by this generator.
      • setCookieMaxAge

        public void setCookieMaxAge(@Nullable
                                    java.lang.Integer cookieMaxAge)
        Use the given maximum age (in seconds) for cookies created by this generator. Useful special value: -1 ... not persistent, deleted when client shuts down.

        Default is no specific maximum age at all, using the Servlet container's default.

        See Also:
        Cookie.setMaxAge(int)
      • getCookieMaxAge

        @Nullable
        public java.lang.Integer getCookieMaxAge()
        Return the maximum age for cookies created by this generator.
      • setCookieSecure

        public void setCookieSecure(boolean cookieSecure)
        Set whether the cookie should only be sent using a secure protocol, such as HTTPS (SSL). This is an indication to the receiving browser, not processed by the HTTP server itself.

        Default is "false".

        See Also:
        Cookie.setSecure(boolean)
      • isCookieSecure

        public boolean isCookieSecure()
        Return whether the cookie should only be sent using a secure protocol, such as HTTPS (SSL).
      • setCookieHttpOnly

        public void setCookieHttpOnly(boolean cookieHttpOnly)
        Set whether the cookie is supposed to be marked with the "HttpOnly" attribute.

        Default is "false".

        See Also:
        Cookie.setHttpOnly(boolean)
      • isCookieHttpOnly

        public boolean isCookieHttpOnly()
        Return whether the cookie is supposed to be marked with the "HttpOnly" attribute.