Class SessionCookieConfig


  • public class SessionCookieConfig
    extends java.lang.Object
    Basic configuration for cookies related to session management.

    Attributes are shared with ClientSideSessionConfig that is used by client side session (cookie based).

    See Also:
    ClientSideSessionConfig
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      SessionCookieConfig domain​(java.lang.String domain)
      Set the domain for session cookie.
      SessionCookieConfig expires​(java.time.Duration expiresDuration)
      Set max age of the cookies related to session management.
      java.lang.String getDomain()
      Use the session cookie only when requesting from the domain.
      java.time.Duration getExpires()
      Cookie's max age.
      java.lang.String getIdName()
      The name of the cookie for session id.
      java.lang.String getPath()
      Use the session cookie only when requesting from the path.
      SessionCookieConfig httpOnly​(boolean httpOnly)
      Set session cookies attribute HttpOnly.
      SessionCookieConfig idName​(java.lang.String idName)
      Set the name of the cookie for session id.
      boolean isHttpOnly()
      HttpOnly cookies can only be used when transmitted via HTTP/HTTPS.
      boolean isSecure()
      Secure cookies can only be transmitted over encrypted connection like HTTPS.
      SessionCookieConfig path​(java.lang.String path)
      Set the path for session cookie.
      SessionCookieConfig secure​(boolean secure)
      Set session cookies attribute Secure.
      void setDomain​(java.lang.String domain)
      Set the domain for session cookie.
      void setExpires​(java.time.Duration expires)
      Set cookie's max age.
      void setHttpOnly​(boolean httpOnly)
      Set session cookies attribute HttpOnly.
      void setIdName​(java.lang.String idName)
      Set the name of the cookie for session id.
      void setPath​(java.lang.String path)
      Set the path for session cookie.
      void setSecure​(boolean secure)
      Set session cookies attribute Secure.
      • Methods inherited from class java.lang.Object

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

      • SessionCookieConfig

        public SessionCookieConfig()
    • Method Detail

      • getExpires

        public java.time.Duration getExpires()
        Cookie's max age.
        Returns:
        the max age of the session related cookies
      • getDomain

        public java.lang.String getDomain()
        Use the session cookie only when requesting from the domain.

        Define the scope for the cookie.

        Returns:
        the URI domain to which session cookie will be attached to.
      • getPath

        public java.lang.String getPath()
        Use the session cookie only when requesting from the path.

        Define the scope of the cookie.

        Session should be send for every request. The path of value "/" does this.

        Returns:
        the URI path to which session cookie will be attached to.
      • getIdName

        public java.lang.String getIdName()
        The name of the cookie for session id.

        Defaults to: JSESSIONID

        Returns:
        the name of the cookie for session id
      • isHttpOnly

        public boolean isHttpOnly()
        HttpOnly cookies can only be used when transmitted via HTTP/HTTPS. They are not accessible for JavaScript.

        Http only cookies have to be supported by the browser.

        Returns:
        true if client side session cookies are HttpOnly
      • isSecure

        public boolean isSecure()
        Secure cookies can only be transmitted over encrypted connection like HTTPS.
        Returns:
        true if session cookies are Secure
      • setExpires

        public void setExpires​(java.time.Duration expires)
        Set cookie's max age.
        Parameters:
        expires - the duration after cookie expires
      • setDomain

        public void setDomain​(java.lang.String domain)
        Set the domain for session cookie.

        Define the scope of the cookie

        Parameters:
        domain - a domain to which session cokkie will be attached to
      • setPath

        public void setPath​(java.lang.String path)
        Set the path for session cookie.

        Define the scope of the cookie.

        Parameters:
        path - a path to which session cookie will be attached to
      • setIdName

        public void setIdName​(java.lang.String idName)
        Set the name of the cookie for session id.
        Parameters:
        idName - the name of the cookie for session id
      • setHttpOnly

        public void setHttpOnly​(boolean httpOnly)
        Set session cookies attribute HttpOnly.
        Parameters:
        httpOnly - if true client side session cookies are HttpOnly
      • setSecure

        public void setSecure​(boolean secure)
        Set session cookies attribute Secure.
        Parameters:
        secure - if true client side session cookies can be transmitted only over encrypted connection
      • expires

        public SessionCookieConfig expires​(java.time.Duration expiresDuration)
        Set max age of the cookies related to session management.
        Parameters:
        expiresDuration - the duration, max age, of the cookies related to session management
        Returns:
        the config
      • domain

        public SessionCookieConfig domain​(java.lang.String domain)
        Set the domain for session cookie.

        Define the scope of the cookie

        Parameters:
        domain - a domain to which session cokkie will be attached to
        Returns:
        the config
      • path

        public SessionCookieConfig path​(java.lang.String path)
        Set the path for session cookie.

        Define the scope of the cookie.

        Parameters:
        path - a path to which session cookie will be attached to
        Returns:
        the config
      • idName

        public SessionCookieConfig idName​(java.lang.String idName)
        Set the name of the cookie for session id.
        Parameters:
        idName - the name of the cookie for session id
        Returns:
        the config
      • httpOnly

        public SessionCookieConfig httpOnly​(boolean httpOnly)
        Set session cookies attribute HttpOnly.
        Parameters:
        httpOnly - if true client side session cookies are HttpOnly
        Returns:
        the config
      • secure

        public SessionCookieConfig secure​(boolean secure)
        Set session cookies attribute Secure.
        Parameters:
        secure - if true client side session cookies can be transmitted only over encrypted connection
        Returns:
        the config