Package org.owasp.dependencycheck.utils
Class URLConnectionFactory
- java.lang.Object
 - 
- org.owasp.dependencycheck.utils.URLConnectionFactory
 
 
- 
public final class URLConnectionFactory extends java.lang.ObjectA URLConnection Factory to create new connections. This encapsulates several configuration checks to ensure that the connection uses the correct proxy settings.- Author:
 - Jeremy Long
 
 
- 
- 
Constructor Summary
Constructors Constructor Description URLConnectionFactory(Settings settings)Private constructor for this factory. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddBasicAuthentication(java.net.HttpURLConnection conn, java.lang.String userKey, java.lang.String passwordKey)Adds a basic authentication header if the values in the settings are not null.java.net.HttpURLConnectioncreateHttpURLConnection(java.net.URL url)Utility method to create an HttpURLConnection.java.net.HttpURLConnectioncreateHttpURLConnection(java.net.URL url, boolean proxy)Utility method to create an HttpURLConnection. 
 - 
 
- 
- 
Constructor Detail
- 
URLConnectionFactory
public URLConnectionFactory(Settings settings)
Private constructor for this factory.- Parameters:
 settings- reference to the configured settings
 
 - 
 
- 
Method Detail
- 
createHttpURLConnection
public java.net.HttpURLConnection createHttpURLConnection(java.net.URL url) throws URLConnectionFailureExceptionUtility method to create an HttpURLConnection. If the application is configured to use a proxy this method will retrieve the proxy settings and use them when setting up the connection.- Parameters:
 url- the URL to connect to- Returns:
 - an HttpURLConnection
 - Throws:
 URLConnectionFailureException- thrown if there is an exception
 
- 
addBasicAuthentication
public void addBasicAuthentication(java.net.HttpURLConnection conn, java.lang.String userKey, java.lang.String passwordKey)Adds a basic authentication header if the values in the settings are not null.- Parameters:
 conn- the connection to add the basic auth headeruserKey- the settings key for the usernamepasswordKey- the settings key for the password
 
- 
createHttpURLConnection
public java.net.HttpURLConnection createHttpURLConnection(java.net.URL url, boolean proxy) throws URLConnectionFailureExceptionUtility method to create an HttpURLConnection. The use of a proxy here is optional as there may be cases where a proxy is configured but we don't want to use it (for example, if there's an internal repository configured)- Parameters:
 url- the URL to connect toproxy- whether to use the proxy (if configured)- Returns:
 - a newly constructed HttpURLConnection
 - Throws:
 URLConnectionFailureException- thrown if there is an exception
 
 - 
 
 -