Package com.oorian

Class OorianCookie

java.lang.Object
com.oorian.OorianCookie

public class OorianCookie extends Object
Framework-level cookie representation, decoupling from servlet API cookie classes.

This is a simple POJO that holds cookie attributes. Adapter implementations in the thin Jakarta/J2EE libraries convert between this class and the servlet API cookie.

Since:
2.1
Version:
1.0
Author:
Marvin P. Warble Jr.
  • Constructor Details

    • OorianCookie

      public OorianCookie(String name, String value)
      Constructs a new OorianCookie with the specified name and value.

      If secure cookie defaults have been configured via Application.setSecureCookieDefaults(CookieDefaults), the cookie is initialized with those defaults. Otherwise, HttpOnly and Secure default to false and SameSite defaults to null.

      Parameters:
      name - the cookie name
      value - the cookie value
  • Method Details

    • setName

      public void setName(String name)
      Sets the cookie name.
      Parameters:
      name - the cookie name
    • setValue

      public void setValue(String value)
      Sets the cookie value.
      Parameters:
      value - the cookie value
    • setPath

      public void setPath(String path)
      Sets the path for which the cookie is valid.
      Parameters:
      path - the cookie path
    • setDomain

      public void setDomain(String domain)
      Sets the domain for which the cookie is valid.
      Parameters:
      domain - the cookie domain
    • setMaxAge

      public void setMaxAge(int maxAge)
      Sets the maximum age of the cookie in seconds.
      Parameters:
      maxAge - the maximum age in seconds; -1 means session cookie
    • setSecure

      public void setSecure(boolean secure)
      Sets whether the cookie should only be sent over secure (HTTPS) connections.
      Parameters:
      secure - true for secure-only cookies
    • setHttpOnly

      public void setHttpOnly(boolean httpOnly)
      Sets whether the cookie should be inaccessible to client-side scripts.
      Parameters:
      httpOnly - true to prevent client-side script access
    • setSameSite

      public void setSameSite(String sameSite)
      Sets the SameSite attribute for the cookie.

      The SameSite attribute controls whether the cookie is sent with cross-site requests, providing protection against CSRF attacks.

      Parameters:
      sameSite - the SameSite value ("Strict", "Lax", or "None")
    • getName

      public String getName()
      Returns the cookie name.
      Returns:
      the cookie name
    • getValue

      public String getValue()
      Returns the cookie value.
      Returns:
      the cookie value
    • getPath

      public String getPath()
      Returns the path for which the cookie is valid.
      Returns:
      the cookie path
    • getDomain

      public String getDomain()
      Returns the domain for which the cookie is valid.
      Returns:
      the cookie domain
    • getMaxAge

      public int getMaxAge()
      Returns the maximum age of the cookie in seconds.
      Returns:
      the maximum age; -1 means session cookie
    • isSecure

      public boolean isSecure()
      Returns whether the cookie is secure-only.
      Returns:
      true if the cookie should only be sent over HTTPS
    • isHttpOnly

      public boolean isHttpOnly()
      Returns whether the cookie is HTTP-only.
      Returns:
      true if the cookie is inaccessible to client-side scripts
    • getSameSite

      public String getSameSite()
      Returns the SameSite attribute value.
      Returns:
      the SameSite value, or null if not set