diff --git a/utils/src/main/java/org/owasp/dependencycheck/utils/Downloader.java b/utils/src/main/java/org/owasp/dependencycheck/utils/Downloader.java index 4b04459604..35dbac9d73 100644 --- a/utils/src/main/java/org/owasp/dependencycheck/utils/Downloader.java +++ b/utils/src/main/java/org/owasp/dependencycheck/utils/Downloader.java @@ -433,10 +433,10 @@ private static void wrapAndThrowHttpResponseException(String url, HttpResponseEx */ public void fetchFile(URL url, File outputPath, boolean useProxy, String userKey, String passwordKey, String tokenKey) throws DownloadFailedException, TooManyRequestsException, ResourceNotFoundException, URLConnectionFailureException { - if ("file".equals(url.getProtocol()) - || userKey == null || settings.getString(userKey) == null - || passwordKey == null || settings.getString(passwordKey) == null - ) { + final boolean basicConfigured = userKey != null && settings.getString(userKey) != null + && passwordKey != null && settings.getString(passwordKey) != null; + final boolean tokenConfigured = tokenKey != null && settings.getString(tokenKey) != null; + if ("file".equals(url.getProtocol()) || (!basicConfigured && !tokenConfigured)) { // no credentials configured, so use the default fetchFile fetchFile(url, outputPath, useProxy); return;