private HttpURLConnection connect(URL url) throws IOException {
        LOGGER.debug("Searching Artifactory url {}", url);

        // Determine if we need to use a proxy. The rules:
        // 1) If the proxy is set, AND the setting is set to true, use the proxy
        // 2) Otherwise, don't use the proxy (either the proxy isn't configured,
        // or proxy is specifically set to false)
        final URLConnectionFactory factory = new URLConnectionFactory(settings);
        final HttpURLConnection conn = factory.createHttpURLConnection(url, useProxy);
        conn.setDoOutput(true);

        conn.addRequestProperty("X-Result-Detail", "info");

        final String username = settings.getString(Settings.KEYS.ANALYZER_ARTIFACTORY_API_USERNAME);
        final String apiToken = settings.getString(Settings.KEYS.ANALYZER_ARTIFACTORY_API_TOKEN);
        if (username != null && apiToken != null) {
            final String userpassword = username + ":" + apiToken;
            final String encodedAuthorization = Base64.getEncoder().encodeToString(userpassword.getBytes(StandardCharsets.UTF_8));
            conn.addRequestProperty("Authorization", "Basic " + encodedAuthorization);
        } else {
            final String bearerToken = settings.getString(Settings.KEYS.ANALYZER_ARTIFACTORY_BEARER_TOKEN);
            if (bearerToken != null) {
                conn.addRequestProperty("Authorization", "Bearer " + bearerToken);
            }
        }

        conn.connect();
        return conn;
    }
private HttpURLConnection connect ( URL url ) throws IOException { LOGGER . debug ( "Searching Artifactory url {}" , url ) ; final URLConnectionFactory factory = new URLConnectionFactory ( settings ) ; final HttpURLConnection conn = factory . createHttpURLConnection ( url , useProxy ) ; conn . setDoOutput ( true ) ; conn . addRequestProperty ( "X-Result-Detail" , "info" ) ; final String username = settings . getString ( Settings . KEYS . ANALYZER_ARTIFACTORY_API_USERNAME ) ; final String apiToken = settings . getString ( Settings . KEYS . ANALYZER_ARTIFACTORY_API_TOKEN ) ; if ( username != null && apiToken != null ) { final String userpassword = username + ":" + apiToken ; final String encodedAuthorization = Base64 . getEncoder ( ) . encodeToString ( userpassword . getBytes ( StandardCharsets . UTF_8 ) ) ; conn . addRequestProperty ( "Authorization" , "Basic " + encodedAuthorization ) ; } else { final String bearerToken = settings . getString ( Settings . KEYS . ANALYZER_ARTIFACTORY_BEARER_TOKEN ) ; if ( bearerToken != null ) { conn . addRequestProperty ( "Authorization" , "Bearer " + bearerToken ) ; } } conn . connect ( ) ; return conn ; }
Makes an connection to the given URL.

@param url the URL to connect to
@return the HTTP URL Connection
@throws IOException thrown if there is an error making the connection