Skip to content

Commit

Permalink
Add generic attribute support to SessionCookieConfig
Browse files Browse the repository at this point in the history
Also adds an entry to the change log.
The schema also requires an update. A separate PR will be provided
shortly to the schema project for that change.
  • Loading branch information
markt-asf committed Oct 12, 2021
1 parent 92ae415 commit aeabf0d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
43 changes: 43 additions & 0 deletions api/src/main/java/jakarta/servlet/SessionCookieConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package jakarta.servlet;

import java.util.Map;

/**
* Class that may be used to configure various properties of cookies used for session tracking purposes.
*
Expand Down Expand Up @@ -231,4 +233,45 @@ public interface SessionCookieConfig {
* @see jakarta.servlet.http.Cookie#getMaxAge
*/
public int getMaxAge();

/**
* Sets the value for the given session cookie attribute. When a value is set via this method, the value returned by the
* attribute specific getter (if any) must be consistent with the value set via this method.
*
* @param name Name of attribute to set, case insensitive
* @param value Value of attribute
*
* @throws IllegalStateException if the associated ServletContext has already been initialised
*
* @throws IllegalArgumentException If the attribute name is null or contains any characters not permitted for use in
* Cookie names.
*
* @throws NumberFormatException If the attribute is known to be numerical but the provided value cannot be parsed to a
* number.
*
* @since Servlet 6.0
*/
public void setAttribute(String name, String value);

/**
* Obtain the value for a given session cookie attribute. Values returned from this method must be consistent with the
* values set and returned by the attribute specific getters and setters in this class.
*
* @param name Name of attribute to return, case insensitive
*
* @return Value of specified attribute
*
* @since Servlet 6.0
*/
public String getAttribute(String name);

/**
* Obtain the Map (keys are case insensitive) of all attributes and values, including those set via the attribute
* specific setters, (excluding version) for this <tt>SessionCookieConfig</tt>.
*
* @return A read-only Map of attributes to values, excluding version.
*
* @since Servlet 6.0
*/
public Map<String, String> getAttributes();
}
4 changes: 4 additions & 0 deletions spec/src/main/asciidoc/servlet-spec-body.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8381,6 +8381,10 @@ Jakarta Servlet {spec-version} specification developed under the Jakarta EE Work

=== Changes Since Jakarta Servlet 5.0

link:https://github.com/eclipse-ee4j/servlet-api/issues/175[Issue 175]::
Provide generic attribute support to cookies, including session cookies, to
provide support for additional attributes such as the `SameSite` attribute.

link:https://github.com/eclipse-ee4j/servlet-api/issues/225[Issue 225]::
Deprecated wrapped response handling in the `doHead` method in favour of container implementation of `HEAD` method behavior.

Expand Down

0 comments on commit aeabf0d

Please sign in to comment.