Skip to content

Commit d841424

Browse files
authored
Merge pull request #958 from airbus-forks/basic-http-cookie-support
Enable basic HTTP cookie support in Boot.java
2 parents 7707c38 + 0618576 commit d841424

File tree

1 file changed

+21
-0
lines changed
  • core/src/main/java/net/sourceforge/jnlp/runtime

1 file changed

+21
-0
lines changed

core/src/main/java/net/sourceforge/jnlp/runtime/Boot.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646
import javax.swing.UIManager;
4747
import java.io.File;
4848
import java.net.URL;
49+
import java.net.CookieManager;
50+
import java.net.CookiePolicy;
51+
import java.net.CookieHandler;
4952
import java.security.AccessController;
5053
import java.security.PrivilegedAction;
5154
import java.util.Arrays;
@@ -111,6 +114,24 @@ public static void main(String[] args) {
111114
int status = -42;
112115
try {
113116
EnvironmentPrinter.logEnvironment(args);
117+
118+
// Enabling java.net built-in support of HTTP cookies.
119+
// HTTP cookies will be stored in-memory until the java process dies.
120+
// CookiePolicy.ACCEPT_ALL is necessary to manage the cookies associated
121+
// to a parent domain of the requested url domain.
122+
//
123+
// Example:
124+
// if an HTTP response on "https://prefix.domain.extension/app/jws-store/some-package.jar" contains:
125+
// - 1 cookie set on "prefix.domain-name.extension" domain
126+
// - 1 cookie set on "*.domain-name.extension" domain
127+
// CookiePolicy.ACCEPT_ALL ensures that both cookie will be send back in the next HTTP queries
128+
// sent to the "prefix.domain-name.extension" domain, whereas CookiePolicy.ACCEPT_ORIGINAL_SERVER will filter
129+
// the cookie set on "*.domain-name.extension" domain.
130+
131+
CookieManager cookieManager = new CookieManager();
132+
cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
133+
CookieHandler.setDefault(cookieManager);
134+
114135
status = mainWithReturnCode(args);
115136
} finally {
116137
if (status != 0) {

0 commit comments

Comments
 (0)