Skip to content

Commit bf02f42

Browse files
authored
Merge pull request #4991 from eclipse-ee4j/faces-api-issue-1570_add-support-for-SameSite
Faces 4.0: add support for custom attributes in ExternalContext#addResponseCookie()
2 parents 594c90f + 3f510fb commit bf02f42

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

impl/src/main/java/com/sun/faces/context/ExternalContextImpl.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public class ExternalContextImpl extends ExternalContext {
102102
private Flash flash;
103103
private boolean distributable;
104104

105-
private enum ALLOWABLE_COOKIE_PROPERTIES {
105+
private enum PREDEFINED_COOKIE_PROPERTIES {
106106
domain, maxAge, path, secure, httpOnly
107107
}
108108

@@ -776,7 +776,7 @@ public void addResponseCookie(String name, String value, Map<String, Object> pro
776776
if (properties != null && properties.size() != 0) {
777777
for (Map.Entry<String, Object> entry : properties.entrySet()) {
778778
String key = entry.getKey();
779-
ALLOWABLE_COOKIE_PROPERTIES p = ALLOWABLE_COOKIE_PROPERTIES.valueOf(key);
779+
PREDEFINED_COOKIE_PROPERTIES p = PREDEFINED_COOKIE_PROPERTIES.valueOf(key);
780780
Object v = entry.getValue();
781781
switch (p) {
782782
case domain:
@@ -795,7 +795,8 @@ public void addResponseCookie(String name, String value, Map<String, Object> pro
795795
cookie.setHttpOnly((Boolean) v);
796796
break;
797797
default:
798-
throw new IllegalStateException(); // shouldn't happen
798+
cookie.setAttribute(key, (String) v);
799+
break;
799800
}
800801
}
801802
}

impl/src/main/java/jakarta/faces/context/ExternalContext.java

+11-4
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public abstract class ExternalContext {
118118
*
119119
* <tr>
120120
*
121-
* <th>Key in "values" <code>Map</code></th>
121+
* <th>Key in "values" <code>Map</code> <span class="changed_added_4_0">(case sensitive)</span></th>
122122
*
123123
* <th>Expected type of value.</th>
124124
*
@@ -186,6 +186,16 @@ public abstract class ExternalContext {
186186
*
187187
* </tr>
188188
*
189+
* <tr class="changed_added_4_0">
190+
*
191+
* <td><i>any other attribute</i> (e.g. SameSite)</td>
192+
*
193+
* <td>String</td>
194+
*
195+
* <td>setAttribute</td>
196+
*
197+
* </tr>
198+
*
189199
* </table>
190200
*
191201
* <p>
@@ -202,9 +212,6 @@ public abstract class ExternalContext {
202212
* @param properties A <code>Map</code> containg key/value pairs to be passed as arguments to the setter methods as
203213
* described above.
204214
*
205-
* @throws IllegalArgumentException if the <code>properties
206-
* Map</code> is not-<code>null</code> and not empty and contains any keys that are not one of the keys listed above.
207-
*
208215
* @since 2.0
209216
*/
210217

0 commit comments

Comments
 (0)