Class AbstractNiceCookie

java.lang.Object
ch.tocco.nice2.web.core.api.servlet.AbstractNiceCookie
Direct Known Subclasses:
AuthCookie, JwtCookie

public abstract class AbstractNiceCookie extends Object
An abstract cookie class to build a cookie and add it to a HttpServletResponse.

The javax.servlet.http.Cookie misses the functionality to set an exact expiration date, or to add a number of seconds based on the CLIENT's time.

See Also:
  • Field Details

    • content

      @Nullable protected @Nullable String content
    • addedToResponse

      protected boolean addedToResponse
    • expires

      @Nullable protected @Nullable org.joda.time.DateTime expires
      Null means it's a session cookie. Otherwise the gmt date is passed on to the client.
  • Constructor Details

    • AbstractNiceCookie

      public AbstractNiceCookie()
  • Method Details

    • setExpires

      public void setExpires(int seconds, org.joda.time.DateTime relativeToThisGmtDate)
      Parameters:
      seconds - A number > 0.
    • addToResponse

      public void addToResponse(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
      Adds the cookie to the response.

      This method may only be called once. Also, no more modification may be made to the class afterwards.

    • getSpecificTokens

      protected abstract List<String> getSpecificTokens(jakarta.servlet.http.HttpServletRequest request)
    • getName

      protected abstract String getName()
    • shouldBeSecured

      protected abstract boolean shouldBeSecured(jakarta.servlet.http.HttpServletRequest request)