Class Downloader

java.lang.Object
org.owasp.dependencycheck.utils.Downloader

public final class Downloader extends Object
A Utility class to centralize download logic like HTTP(S) proxy configuration and proxy- and server credential handling.
Author:
Jeremy Long, Hans Aikema
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    configure(Settings settings)
    Initialize the Downloader from the settings.
    <T> T
    fetchAndHandle(@NonNull URL url, @NonNull org.apache.hc.core5.http.io.HttpClientResponseHandler<T> handler)
    Download a resource from the given URL and have its content handled by the given ResponseHandler.
    <T> T
    fetchAndHandle(@NonNull URL url, @NonNull org.apache.hc.core5.http.io.HttpClientResponseHandler<T> handler, @NonNull List<org.apache.hc.core5.http.Header> hdr)
    Download a resource from the given URL and have its content handled by the given ResponseHandler.
    <T> T
    fetchAndHandle(@NonNull URL url, @NonNull org.apache.hc.core5.http.io.HttpClientResponseHandler<T> handler, @NonNull List<org.apache.hc.core5.http.Header> hdr, boolean useProxy)
    Download a resource from the given URL and have its content handled by the given ResponseHandler.
    <T> T
    fetchAndHandle(@NonNull org.apache.hc.client5.http.impl.classic.CloseableHttpClient client, @NonNull URL url, @NonNull org.apache.hc.core5.http.io.HttpClientResponseHandler<T> handler, @NonNull List<org.apache.hc.core5.http.Header> hdr)
    Download a resource from the given URL and have its content handled by the given ResponseHandler.
    fetchContent(URL url, boolean useProxy, Charset charset)
    Retrieves a file from a given URL and returns the contents.
    fetchContent(URL url, Charset charset)
    Retrieves a file from a given URL and returns the contents.
    void
    fetchFile(URL url, File outputPath)
    Retrieves a file from a given URL and saves it to the outputPath.
    void
    fetchFile(URL url, File outputPath, boolean useProxy)
    Retrieves a file from a given URL and saves it to the outputPath.
    void
    fetchFile(URL url, File outputPath, boolean useProxy, String userKey, String passwordKey, String tokenKey)
    Retrieves a file from a given URL using an ad-hoc created CredentialsProvider if needed and saves it to the outputPath.
    org.apache.hc.client5.http.impl.classic.CloseableHttpClient
    getHttpClient(boolean useProxy)
    Gets a pre-configured HttpClient.
    static Downloader
    The singleton instance for downloading file resources.
    org.apache.hc.client5.http.protocol.HttpClientContext
    Gets a HttpClientContext that supports pre-emptive authentication.
    postBasedFetchContent(URI url, String payload, org.apache.hc.core5.http.ContentType payloadType, List<org.apache.hc.core5.http.Header> hdr)
    Posts a payload to the URL and returns the response as a string.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait