2424import static net .adoptopenjdk .icedteaweb .resources .Resource .Status .ERROR ;
2525import static net .sourceforge .jnlp .util .UrlUtils .FILE_PROTOCOL ;
2626import static net .sourceforge .jnlp .util .UrlUtils .decodeUrlQuietly ;
27- /*
28- * Modified class to add DeploymentRuleSet
29- * DJ -03-02-2021
30- */
27+
3128class ResourceHandler {
3229
3330 private static final Logger LOG = LoggerFactory .getLogger (ResourceHandler .class );
@@ -46,7 +43,7 @@ Future<Resource> putIntoCache(final Executor downloadExecutor) {
4643 // threads will return this future and ensure a resource is only processed by a single thread
4744 synchronized (resource ) {
4845 final Future <Resource > future = resource .getFutureForDownloaded ();
49- if (future == null ) {
46+ if (future == null ) {
5047 LOG .debug ("Download for {} has not been started until now" , resource .getSimpleName ());
5148 final Future <Resource > futureResource = getDownloadStateAndStartUnstartedDownload (downloadExecutor );
5249 resource .startProcessing (futureResource );
@@ -121,54 +118,23 @@ private Resource downloadResource() {
121118 return resource ;
122119 }
123120
124- /** Original method
125121 private void validateWithWhitelist () {
126122 final URL url = resource .getLocation ();
127123 Assert .requireNonNull (url , "url" );
128124
129125 // Validate with whitelist specified in deployment.properties. localhost is considered valid.
130- final boolean found = UrlWhiteListUtils.isUrlInApplicationUrlWhitelist(url);
131- if (!found) {
132- BasicExceptionDialog.show(new SecurityException(Translator.R("SWPInvalidURL") + ": " + url));
133- LOG.error("Resource URL not In Whitelist: {}", resource.getLocation());
134- JNLPRuntime.exit(-1);
135- }
136- }
137- */
138- private void validateWithWhitelist () {
139- final URL url = resource .getLocation ();
140- Assert .requireNonNull (url , "url" );
141-
142- // Validate with whitelist specified in deployment.properties. localhost is considered valid.
143- //commented out by DJ -final key word so that URL can be checked against whitelist as well as deploymentRuleset.
144- /*final*/ boolean found = UrlWhiteListUtils .isUrlInApplicationUrlWhitelist (url );
145- //If not found in the serverWhitelisting , check in DeploymentRuleSet.jar file.
146- LOG .debug ("Resource URL not In Whitelist: {} found before calling Deployment rule set" , found );
147- if (!found ) {
148- LOG .debug ("----------------------BEGIN DEPLOYMENT RULESET CALL------------------------------------------" , found );
149- LOG .debug ("Resource URL call inside (!found) before calling found=validateWithDeploymentRuleSet()" , found );
150- found =validateWithDeploymentRuleSet () ;
151- LOG .debug ("Resource URL call inside (!found) after calling found=validateWithDeploymentRuleSet()" , found );
126+ if (UrlWhiteListUtils .isUrlInApplicationUrlWhitelist (url )) {
127+ return ;
152128 }
153- LOG .debug ("Resource URL not In Whitelist: {} found after calling Deployment rule set" , found );
154- if (!found ) {
155- BasicExceptionDialog .show (new SecurityException (Translator .R ("SWPInvalidURL" ) + ": " + url ));
156- LOG .error ("Resource URL not In Whitelist: {}" , resource .getLocation ());
157- JNLPRuntime .exit (-1 );
158- }
159- }
160-
161- /**
162- * @author DJ 03-02-2021
163- * Validates the resource URL with the deploymentRuleSet jar file
164- */
165- private boolean validateWithDeploymentRuleSet () {
166- final URL url = resource .getLocation ();
167- Assert .requireNonNull (url , "url" );
168129
169130 // Validate with whitelist specified in DeploymentRuleSet.jar localhost is considered valid.
170- final boolean found = UrlDeploymentRulesSetUtils .isUrlInDeploymentRuleSetlist (url );
171- return found ;
131+ if (UrlDeploymentRulesSetUtils .isUrlInDeploymentRuleSet (url )) {
132+ return ;
133+ }
134+
135+ BasicExceptionDialog .show (new SecurityException (Translator .R ("SWPInvalidURL" ) + ": " + url ));
136+ LOG .error ("Resource URL not In Whitelist: {}" , resource .getLocation ());
137+ JNLPRuntime .exit (-1 );
172138 }
173139
174140}
0 commit comments