Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sclassen committed Aug 30, 2021
1 parent dd72603 commit 456a30e
Show file tree
Hide file tree
Showing 19 changed files with 309 additions and 873 deletions.
34 changes: 0 additions & 34 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,40 +49,6 @@
<artifactId>js</artifactId>
<version>1.7R1</version>
</dependency>
<!-- DeploymentRule set dependencies added begin -->
<!-- https://mvnrepository.com/artifact/org.glassfish.jaxb/jaxb-runtime -->
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.activation/activation -->
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.eclipse.persistence/eclipselink -->

<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.5.0</version>
</dependency>
<!-- DeploymentRule set dependencies added End -->


<dependency>
<groupId>${project.groupId}</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@
import static net.adoptopenjdk.icedteaweb.resources.Resource.Status.ERROR;
import static net.sourceforge.jnlp.util.UrlUtils.FILE_PROTOCOL;
import static net.sourceforge.jnlp.util.UrlUtils.decodeUrlQuietly;
/*
* Modified class to add DeploymentRuleSet
* DJ -03-02-2021
*/

class ResourceHandler {

private static final Logger LOG = LoggerFactory.getLogger(ResourceHandler.class);
Expand All @@ -46,7 +43,7 @@ Future<Resource> putIntoCache(final Executor downloadExecutor) {
// threads will return this future and ensure a resource is only processed by a single thread
synchronized (resource) {
final Future<Resource> future = resource.getFutureForDownloaded();
if(future == null) {
if (future == null) {
LOG.debug("Download for {} has not been started until now", resource.getSimpleName());
final Future<Resource> futureResource = getDownloadStateAndStartUnstartedDownload(downloadExecutor);
resource.startProcessing(futureResource);
Expand Down Expand Up @@ -121,54 +118,22 @@ private Resource downloadResource() {
return resource;
}

/** Original method
private void validateWithWhitelist() {
final URL url = resource.getLocation();
Assert.requireNonNull(url, "url");

// Validate with whitelist specified in deployment.properties. localhost is considered valid.
final boolean found = UrlWhiteListUtils.isUrlInApplicationUrlWhitelist(url);
if (!found) {
BasicExceptionDialog.show(new SecurityException(Translator.R("SWPInvalidURL") + ": " + url));
LOG.error("Resource URL not In Whitelist: {}", resource.getLocation());
JNLPRuntime.exit(-1);
}
}
*/
private void validateWithWhitelist() {
final URL url = resource.getLocation();
Assert.requireNonNull(url, "url");

// Validate with whitelist specified in deployment.properties. localhost is considered valid.
//commented out by DJ -final key word so that URL can be checked against whitelist as well as deploymentRuleset.
/*final*/ boolean found = UrlWhiteListUtils.isUrlInApplicationUrlWhitelist(url);
//If not found in the serverWhitelisting , check in DeploymentRuleSet.jar file.
LOG.debug("Resource URL not In Whitelist: {} found before calling Deployment rule set", found);
if (!found) {
LOG.debug("----------------------BEGIN DEPLOYMENT RULESET CALL------------------------------------------", found);
LOG.debug("Resource URL call inside (!found) before calling found=validateWithDeploymentRuleSet()", found);
found=validateWithDeploymentRuleSet() ;
LOG.debug("Resource URL call inside (!found) after calling found=validateWithDeploymentRuleSet()", found);
if (UrlWhiteListUtils.isUrlInApplicationUrlWhitelist(url)) {
return;
}
LOG.debug("Resource URL not In Whitelist: {} found after calling Deployment rule set", found);
if (!found) {
BasicExceptionDialog.show(new SecurityException(Translator.R("SWPInvalidURL") + ": " + url));
LOG.error("Resource URL not In Whitelist: {}", resource.getLocation());
JNLPRuntime.exit(-1);
}
}

/**
* @author DJ 03-02-2021
* Validates the resource URL with the deploymentRuleSet jar file
*/
private boolean validateWithDeploymentRuleSet() {
final URL url = resource.getLocation();
Assert.requireNonNull(url, "url");

// Validate with whitelist specified in DeploymentRuleSet.jar localhost is considered valid.
final boolean found = UrlDeploymentRulesSetUtils.isUrlInDeploymentRuleSetlist(url);
return found;
if (UrlDeploymentRulesSetUtils.isUrlInDeploymentRuleSet(url)) {
return;
}

BasicExceptionDialog.show(new SecurityException(Translator.R("SWPInvalidURL") + ": " + url));
LOG.error("Resource URL not In Whitelist: {}", resource.getLocation());
JNLPRuntime.exit(-1);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public interface ConfigurationConstants {
String KEY_HTTPCONNECTION_CONNECT_TIMEOUT = "deployment.connection.connectTimeout";
String KEY_HTTPCONNECTION_READ_TIMEOUT = "deployment.connection.readTimeout";

/*DJ -adding deloymentruleset properties*/
/* deployment ruleset properties*/
String KEY_DEPLOYMENT_RULE_SET = "deployment.deploymentruleset.jar";

}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 456a30e

Please sign in to comment.