Skip to content
This repository was archived by the owner on Feb 8, 2023. It is now read-only.

Commit dbae710

Browse files
committed
samesite attribute added
1 parent 5244f4a commit dbae710

File tree

5 files changed

+33
-17
lines changed

5 files changed

+33
-17
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.apt.aptEnabled=false
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
eclipse.preferences.version=1
22
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3-
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
4-
org.eclipse.jdt.core.compiler.compliance=1.7
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4+
org.eclipse.jdt.core.compiler.compliance=1.8
55
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6+
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
67
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
78
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
8-
org.eclipse.jdt.core.compiler.source=1.7
9+
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
10+
org.eclipse.jdt.core.compiler.processAnnotations=disabled
11+
org.eclipse.jdt.core.compiler.release=disabled
12+
org.eclipse.jdt.core.compiler.source=1.8

pom.xml

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<selenium.version>2.45.0</selenium.version>
1414
<wildfly.version>20.0.1.Final</wildfly.version>
1515
<project.scm.id>java-cookie-scm</project.scm.id>
16-
<java.home>C:\Program Files\Java\jdk1.8.0_181</java.home>
16+
<java.version>1.8</java.version>
1717
</properties>
1818
<licenses>
1919
<license>
@@ -48,8 +48,8 @@
4848
<artifactId>maven-compiler-plugin</artifactId>
4949
<version>3.8.1</version>
5050
<configuration>
51-
<source>1.8</source>
52-
<target>1.8</target>
51+
<source>${java.version}</source>
52+
<target>${java.version}</target>
5353
</configuration>
5454
</plugin>
5555
<plugin>
@@ -67,13 +67,6 @@
6767
</build>
6868
<dependencyManagement>
6969
<dependencies>
70-
<dependency>
71-
<groupId>sun.jdk</groupId>
72-
<artifactId>jconsole</artifactId>
73-
<version>1.8</version>
74-
<scope>system</scope>
75-
<systemPath>${java.home}\lib\jconsole.jar</systemPath>
76-
</dependency>
7770
<dependency>
7871
<groupId>org.jboss.arquillian</groupId>
7972
<artifactId>arquillian-bom</artifactId>
@@ -177,10 +170,6 @@
177170
<plugins>
178171
<plugin>
179172
<artifactId>maven-dependency-plugin</artifactId>
180-
<!--<configuration>
181-
<source>1.8</source>
182-
<target>1.8</target>
183-
</configuration>-->
184173
<executions>
185174
<execution>
186175
<id>unpack</id>

src/main/java/com/github/jscookie/javacookie/AttributesDefinition.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ public abstract class AttributesDefinition {
1111
abstract Boolean secure();
1212
public abstract AttributesDefinition httpOnly( Boolean httpOnly );
1313
abstract Boolean httpOnly();
14+
public abstract AttributesDefinition sameSite( String sameSite );
15+
abstract String sameSite();
1416
}

src/main/java/com/github/jscookie/javacookie/Cookies.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@ public synchronized void set( String name, String value, AttributesDefinition at
147147
header.append( "; HttpOnly" );
148148
}
149149

150+
String sameSite = attributes.sameSite();
151+
if ( sameSite != null ) {
152+
header.append( "; SameSite=" + sameSite );
153+
}
154+
150155
if ( response.isCommitted() ) {
151156
return;
152157
}
@@ -416,6 +421,7 @@ public static class Attributes extends AttributesDefinition {
416421
private String domain;
417422
private Boolean secure;
418423
private Boolean httpOnly;
424+
private String sameSite;
419425

420426
private Attributes() {}
421427

@@ -473,6 +479,16 @@ public Attributes httpOnly( Boolean httpOnly ) {
473479
return this;
474480
}
475481

482+
@Override
483+
String sameSite() {
484+
return sameSite;
485+
}
486+
@Override
487+
public Attributes sameSite( String sameSite ) {
488+
this.sameSite = sameSite;
489+
return this;
490+
}
491+
476492
private Attributes merge( AttributesDefinition reference ) {
477493
if ( reference.path() != null ) {
478494
path = reference.path();
@@ -489,6 +505,9 @@ private Attributes merge( AttributesDefinition reference ) {
489505
if ( reference.httpOnly() != null ) {
490506
httpOnly = reference.httpOnly();
491507
}
508+
if ( reference.sameSite() != null ) {
509+
domain = reference.sameSite();
510+
}
492511
return this;
493512
}
494513
}

0 commit comments

Comments
 (0)