mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-01-14 15:53:36 +01:00
removed nexus auth test code
Former-commit-id: 9b5f8cbceb5a6a273dfd7ba85bf16510dab3ddb5
This commit is contained in:
@@ -74,23 +74,9 @@ public class NexusSearch {
|
||||
&& Settings.getBoolean(Settings.KEYS.ANALYZER_NEXUS_PROXY)) {
|
||||
useProxy = true;
|
||||
LOGGER.fine("Using proxy");
|
||||
if (Settings.getString(Settings.KEYS.ANALYZER_NEXUS_USER) != null) {
|
||||
LOGGER.fine("Unable to use nexus authentication while using a proxy. Consider disabling the use of a proxy with Nexus.");
|
||||
}
|
||||
} else {
|
||||
useProxy = false;
|
||||
LOGGER.fine("Not using proxy");
|
||||
userName = Settings.getString(Settings.KEYS.ANALYZER_NEXUS_USER);
|
||||
String tmp = Settings.getString(Settings.KEYS.ANALYZER_NEXUS_PASSWORD);
|
||||
if (tmp != null) {
|
||||
password = tmp.toCharArray();
|
||||
} else {
|
||||
if (userName != null) {
|
||||
userName = null;
|
||||
LOGGER.fine("Nexus password is not set yet user name was configured. Disabling the use of authentication for Nexus.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} catch (InvalidSettingException ise) {
|
||||
useProxy = false;
|
||||
@@ -120,12 +106,7 @@ public class NexusSearch {
|
||||
// 2) Otherwise, don't use the proxy (either the proxy isn't configured,
|
||||
// or proxy is specifically set to false
|
||||
HttpURLConnection conn;
|
||||
if (useProxy && userName == null) {
|
||||
conn = URLConnectionFactory.createHttpURLConnection(url, useProxy);
|
||||
} else {
|
||||
conn = URLConnectionFactory.createHttpURLConnection(url, userName, password);
|
||||
}
|
||||
|
||||
conn = URLConnectionFactory.createHttpURLConnection(url, useProxy);
|
||||
conn.setDoOutput(true);
|
||||
|
||||
// JSON would be more elegant, but there's not currently a dependency
|
||||
@@ -190,11 +171,7 @@ public class NexusSearch {
|
||||
HttpURLConnection conn;
|
||||
try {
|
||||
URL url = new URL(rootURL, "status");
|
||||
if (useProxy && userName == null) {
|
||||
conn = URLConnectionFactory.createHttpURLConnection(url, useProxy);
|
||||
} else {
|
||||
conn = URLConnectionFactory.createHttpURLConnection(url, userName, password);
|
||||
}
|
||||
conn = URLConnectionFactory.createHttpURLConnection(url, useProxy);
|
||||
conn.addRequestProperty("Accept", "application/xml");
|
||||
conn.connect();
|
||||
if (conn.getResponseCode() != 200) {
|
||||
|
||||
@@ -200,14 +200,6 @@ public final class Settings {
|
||||
* The properties key for using the proxy to reach Nexus.
|
||||
*/
|
||||
public static final String ANALYZER_NEXUS_PROXY = "analyzer.nexus.proxy";
|
||||
/**
|
||||
* The properties key for the Nexus user name.
|
||||
*/
|
||||
public static final String ANALYZER_NEXUS_USER = "analyzer.nexus.user";
|
||||
/**
|
||||
* The properties key for the Nexus user's password.
|
||||
*/
|
||||
public static final String ANALYZER_NEXUS_PASSWORD = "analyzer.nexus.password";
|
||||
/**
|
||||
* The properties key for whether the Central analyzer is enabled.
|
||||
*/
|
||||
|
||||
@@ -117,33 +117,4 @@ public final class URLConnectionFactory {
|
||||
}
|
||||
return conn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method to create an HttpURLConnection. This version of createHttpURLConnection does not utilize any proxy
|
||||
* configuration; but does provide the ability to authenticate to the site.
|
||||
*
|
||||
* @param url the URL to connect to
|
||||
* @param username the user name for authentication to the given site
|
||||
* @param password the password for authentication to the given site
|
||||
* @return a newly constructed HttpURLConnection
|
||||
* @throws URLConnectionFailureException thrown if there is an exception
|
||||
*/
|
||||
public static HttpURLConnection createHttpURLConnection(URL url, final String username, final char[] password)
|
||||
throws URLConnectionFailureException {
|
||||
HttpURLConnection conn = null;
|
||||
try {
|
||||
Authenticator.setDefault(new Authenticator() {
|
||||
protected PasswordAuthentication getPasswordAuthentication() {
|
||||
return new PasswordAuthentication(username, password);
|
||||
}
|
||||
});
|
||||
conn = (HttpURLConnection) url.openConnection();
|
||||
final int timeout = Settings.getInt(Settings.KEYS.CONNECTION_TIMEOUT, 60000);
|
||||
conn.setConnectTimeout(timeout);
|
||||
conn.setInstanceFollowRedirects(true);
|
||||
} catch (IOException ioe) {
|
||||
throw new URLConnectionFailureException("Error getting connection.", ioe);
|
||||
}
|
||||
return conn;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user