@@ -47,6 +47,8 @@ public final class ResponseCookie extends HttpCookie {
47
47
48
48
private final boolean httpOnly ;
49
49
50
+ private final boolean partitioned ;
51
+
50
52
@ Nullable
51
53
private final String sameSite ;
52
54
@@ -55,7 +57,7 @@ public final class ResponseCookie extends HttpCookie {
55
57
* Private constructor. See {@link #from(String, String)}.
56
58
*/
57
59
private ResponseCookie (String name , @ Nullable String value , Duration maxAge , @ Nullable String domain ,
58
- @ Nullable String path , boolean secure , boolean httpOnly , @ Nullable String sameSite ) {
60
+ @ Nullable String path , boolean secure , boolean httpOnly , boolean partitioned , @ Nullable String sameSite ) {
59
61
60
62
super (name , value );
61
63
Assert .notNull (maxAge , "Max age must not be null" );
@@ -65,6 +67,7 @@ private ResponseCookie(String name, @Nullable String value, Duration maxAge, @Nu
65
67
this .path = path ;
66
68
this .secure = secure ;
67
69
this .httpOnly = httpOnly ;
70
+ this .partitioned = partitioned ;
68
71
this .sameSite = sameSite ;
69
72
70
73
Rfc6265Utils .validateCookieName (name );
@@ -116,6 +119,15 @@ public boolean isHttpOnly() {
116
119
return this .httpOnly ;
117
120
}
118
121
122
+ /**
123
+ * Return {@code true} if the cookie has the "Partitioned" attribute.
124
+ * @since 6.2
125
+ * @see <a href="https://datatracker.ietf.org/doc/html/draft-cutler-httpbis-partitioned-cookies#section-2.1">The Partitioned attribute spec</a>
126
+ */
127
+ public boolean isPartitioned () {
128
+ return this .partitioned ;
129
+ }
130
+
119
131
/**
120
132
* Return the cookie "SameSite" attribute, or {@code null} if not set.
121
133
* <p>This limits the scope of the cookie such that it will only be attached to
@@ -139,6 +151,7 @@ public ResponseCookieBuilder mutate() {
139
151
.path (this .path )
140
152
.secure (this .secure )
141
153
.httpOnly (this .httpOnly )
154
+ .partitioned (this .partitioned )
142
155
.sameSite (this .sameSite );
143
156
}
144
157
@@ -180,6 +193,9 @@ public String toString() {
180
193
if (this .httpOnly ) {
181
194
sb .append ("; HttpOnly" );
182
195
}
196
+ if (this .partitioned ) {
197
+ sb .append ("; Partitioned" );
198
+ }
183
199
if (StringUtils .hasText (this .sameSite )) {
184
200
sb .append ("; SameSite=" ).append (this .sameSite );
185
201
}
@@ -272,6 +288,13 @@ public interface ResponseCookieBuilder {
272
288
*/
273
289
ResponseCookieBuilder httpOnly (boolean httpOnly );
274
290
291
+ /**
292
+ * Add the "Partitioned" attribute to the cookie.
293
+ * @since 6.2
294
+ * @see <a href="https://datatracker.ietf.org/doc/html/draft-cutler-httpbis-partitioned-cookies#section-2.1">The Partitioned attribute spec</a>
295
+ */
296
+ ResponseCookieBuilder partitioned (boolean partitioned );
297
+
275
298
/**
276
299
* Add the "SameSite" attribute to the cookie.
277
300
* <p>This limits the scope of the cookie such that it will only be
@@ -397,6 +420,8 @@ private static class DefaultResponseCookieBuilder implements ResponseCookieBuild
397
420
398
421
private boolean httpOnly ;
399
422
423
+ private boolean partitioned ;
424
+
400
425
@ Nullable
401
426
private String sameSite ;
402
427
@@ -461,6 +486,12 @@ public ResponseCookieBuilder httpOnly(boolean httpOnly) {
461
486
return this ;
462
487
}
463
488
489
+ @ Override
490
+ public ResponseCookieBuilder partitioned (boolean partitioned ) {
491
+ this .partitioned = partitioned ;
492
+ return this ;
493
+ }
494
+
464
495
@ Override
465
496
public ResponseCookieBuilder sameSite (@ Nullable String sameSite ) {
466
497
this .sameSite = sameSite ;
@@ -470,7 +501,7 @@ public ResponseCookieBuilder sameSite(@Nullable String sameSite) {
470
501
@ Override
471
502
public ResponseCookie build () {
472
503
return new ResponseCookie (this .name , this .value , this .maxAge ,
473
- this .domain , this .path , this .secure , this .httpOnly , this .sameSite );
504
+ this .domain , this .path , this .secure , this .httpOnly , this .partitioned , this . sameSite );
474
505
}
475
506
}
476
507
0 commit comments