Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OWS-631: Fix properties defined in Jnlp not passed to application #945

Merged
merged 2 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/src/main/java/net/sourceforge/jnlp/JNLPFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ protected JNLPFile() {

final String httpAgent = getResources().getPropertiesMap().get(HTTP_AGENT);
// Do not set http.agent in stage 2 as it can be set from the vmarg to the jvm
if (! StringUtils.isBlank(httpAgent) && !"true".equalsIgnoreCase(System.getenv(ApplicationInstance.IGNORE_JNLP_RESOURCE_PROPERTIES))) {
if (! StringUtils.isBlank(httpAgent) && !"true".equalsIgnoreCase(System.getenv(ApplicationInstance.IGNORE_HTTP_AGENT_PROPERTY))) {
System.setProperty(HTTP_AGENT, httpAgent);
if (!HttpURLConnection.userAgent.contains(httpAgent)) {
LOG.warn("Cannot set HTTP User-Agent as a connection has been opened before reading the JNLP file");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package net.sourceforge.jnlp.runtime;

import net.adoptopenjdk.icedteaweb.JavaSystemPropertiesConstants;
import net.adoptopenjdk.icedteaweb.jnlp.element.resource.ExtensionDesc;
import net.adoptopenjdk.icedteaweb.jnlp.element.resource.PropertyDesc;
import net.adoptopenjdk.icedteaweb.jnlp.element.security.SecurityDesc;
Expand Down Expand Up @@ -53,7 +54,7 @@ public class ApplicationInstance {

private static final String DEPLOYMENT_SYSPROP = "deployment.javaws";
private static final String DEPLOYMENT_SYSPROP_VALUE = "IcedTea-Web";
public static final String IGNORE_JNLP_RESOURCE_PROPERTIES = "ignoreJnlpResourceProperties";
public static final String IGNORE_HTTP_AGENT_PROPERTY = "ignoreHttpAgentProperty";

// todo: should attempt to unload the environment variables
// installed by the application.
Expand Down Expand Up @@ -143,9 +144,6 @@ private void installEnvironment() {
}

private void setSystemPropertiesFromJnlp() {
if ("true".equalsIgnoreCase(System.getenv(IGNORE_JNLP_RESOURCE_PROPERTIES))) {
return;
}
final List<PropertyDesc> props = collectPropertiesFromJnlpHierarchy(new ArrayList<>(), file);

if (!(props.size() == 0)) {
Expand All @@ -158,8 +156,11 @@ private void setSystemPropertiesFromJnlp() {

final PrivilegedAction<Object> setPropertiesAction = () -> {
for (PropertyDesc propDesc : props) {
LOG.debug("Setting System Property {} with value {}", propDesc.getKey(), propDesc.getValue());
System.setProperty(propDesc.getKey(), propDesc.getValue());
if (!propDesc.getKey().equals(JavaSystemPropertiesConstants.HTTP_AGENT)) {
setSystemProperty(propDesc);
} else if (!"true".equalsIgnoreCase(System.getenv(ApplicationInstance.IGNORE_HTTP_AGENT_PROPERTY))) {
setSystemProperty(propDesc);
}
}
return null;
};
Expand All @@ -169,6 +170,11 @@ private void setSystemPropertiesFromJnlp() {
}
}

private void setSystemProperty(PropertyDesc propDesc) {
LOG.debug("Setting System Property {} with value {}", propDesc.getKey(), propDesc.getValue());
System.setProperty(propDesc.getKey(), propDesc.getValue());
}

/**
* Returns the jnlpfile on which is this application based
* @return JNLP file for this task.
Expand Down
Loading