Skip to content

Commit c482c85

Browse files
committed
OWS-631: fix properties defined in jnlp
1 parent 5d1ddc8 commit c482c85

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

core/src/main/java/net/sourceforge/jnlp/JNLPFile.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ protected JNLPFile() {
261261

262262
final String httpAgent = getResources().getPropertiesMap().get(HTTP_AGENT);
263263
// Do not set http.agent in stage 2 as it can be set from the vmarg to the jvm
264-
if (! StringUtils.isBlank(httpAgent) && !"true".equalsIgnoreCase(System.getenv(ApplicationInstance.IGNORE_HTTP_AGENT_PROPERTY))) {
264+
if (!StringUtils.isBlank(httpAgent) && !ApplicationInstance.getBlackListedJnlpProperties().contains(HTTP_AGENT)) {
265265
System.setProperty(HTTP_AGENT, httpAgent);
266266
if (!HttpURLConnection.userAgent.contains(httpAgent)) {
267267
LOG.warn("Cannot set HTTP User-Agent as a connection has been opened before reading the JNLP file");

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package net.sourceforge.jnlp.runtime;
1818

1919
import net.adoptopenjdk.icedteaweb.JavaSystemPropertiesConstants;
20+
import net.adoptopenjdk.icedteaweb.StringUtils;
2021
import net.adoptopenjdk.icedteaweb.jnlp.element.resource.ExtensionDesc;
2122
import net.adoptopenjdk.icedteaweb.jnlp.element.resource.PropertyDesc;
2223
import net.adoptopenjdk.icedteaweb.jnlp.element.security.SecurityDesc;
@@ -39,7 +40,11 @@
3940
import java.security.ProtectionDomain;
4041
import java.util.ArrayList;
4142
import java.util.Arrays;
43+
import java.util.Collections;
44+
import java.util.HashSet;
4245
import java.util.List;
46+
import java.util.Set;
47+
4348
/**
4449
* Represents a running instance of an application described in a
4550
* JNLPFile. This class provides a way to track the application's
@@ -54,7 +59,16 @@ public class ApplicationInstance {
5459

5560
private static final String DEPLOYMENT_SYSPROP = "deployment.javaws";
5661
private static final String DEPLOYMENT_SYSPROP_VALUE = "IcedTea-Web";
57-
public static final String IGNORE_HTTP_AGENT_PROPERTY = "ignoreHttpAgentProperty";
62+
public static final String BLACKLIST_FOR_JNLP_PROPERTIES = "blacklistForJnlpProperties";
63+
public static final String BLACKLISTED_PROPERTIES_SEPARATOR = "=";
64+
65+
public static Set<String> getBlackListedJnlpProperties() {
66+
final String blackListedProprtiesString = System.getenv(BLACKLIST_FOR_JNLP_PROPERTIES);
67+
if (StringUtils.isBlank(blackListedProprtiesString)) {
68+
return Collections.emptySet();
69+
}
70+
return new HashSet<>(Arrays.asList(blackListedProprtiesString.split(BLACKLISTED_PROPERTIES_SEPARATOR)));
71+
}
5872

5973
// todo: should attempt to unload the environment variables
6074
// installed by the application.
@@ -155,10 +169,9 @@ private void setSystemPropertiesFromJnlp() {
155169
final AccessControlContext acc = new AccessControlContext(new ProtectionDomain[] { pd });
156170

157171
final PrivilegedAction<Object> setPropertiesAction = () -> {
172+
final Set<String> blackListedJnlpProperties = getBlackListedJnlpProperties();
158173
for (PropertyDesc propDesc : props) {
159-
if (!propDesc.getKey().equals(JavaSystemPropertiesConstants.HTTP_AGENT)) {
160-
setSystemProperty(propDesc);
161-
} else if (!"true".equalsIgnoreCase(System.getenv(ApplicationInstance.IGNORE_HTTP_AGENT_PROPERTY))) {
174+
if (!blackListedJnlpProperties.contains(propDesc.getKey())) {
162175
setSystemProperty(propDesc);
163176
}
164177
}

0 commit comments

Comments
 (0)