Source:
public String execute(String url, String urlParameters, String clientId, String secret, String method) throws Exception { logger.executingAuthServerRequest(url, urlParameters, clientId, secret, method); HttpURLConnection connection; String credentials = clientId + ":" + secret; String authorizationHeader = "Basic " + Base64.getEncoder().encodeToString(credentials.getBytes()); logger.authHeaderConvertedTo(clientId, secret, authorizationHeader); if ("POST".equalsIgnoreCase(method)) { connection = (HttpURLConnection) new URL(url).openConnection(); connection.setRequestMethod(method); connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); connection.setRequestProperty("Authorization", authorizationHeader); connection.setDoInput(true); connection.setDoOutput(true); if (null != urlParameters) { try (PrintWriter out = new PrintWriter(connection.getOutputStream())) { out.print(urlParameters); } } } else { connection = (HttpURLConnection) new URL(url + "?" + urlParameters).openConnection(); connection.setRequestMethod(method); connection.setRequestProperty("Authorization", authorizationHeader); } int timeout = Integer.parseInt(System.getProperty("org.hawkular.accounts.http.timeout", "5000")); connection.setConnectTimeout(timeout); connection.setReadTimeout(timeout); StringBuilder response = new StringBuilder(); int statusCode; try { statusCode = connection.getResponseCode(); logger.requestExecuted(statusCode); } catch (SocketTimeoutException timeoutException) { throw new UsernamePasswordConversionException("Timed out when trying to contact the Keycloak server."); } InputStream inputStream; if (statusCode < 300) { logger.statusCodeSuccess(); inputStream = connection.getInputStream(); } else { logger.statusCodeNotSuccess(); inputStream = connection.getErrorStream(); } try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"))) { for (String line; (line = reader.readLine()) != null;) { response.append(line); } } String responseAsString = response.toString(); logger.responseBody(responseAsString); return responseAsString; }

Target:
public String execute(String url, String urlParameters, String clientId, String secret, String method) throws Exception { logger.executingAuthServerRequest(url, clientId, method); HttpURLConnection connection; String credentials = clientId + ":" + secret; String authorizationHeader = "Basic " + Base64.getEncoder().encodeToString(credentials.getBytes()); if ("POST".equalsIgnoreCase(method)) { connection = (HttpURLConnection) new URL(url).openConnection(); connection.setRequestMethod(method); connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); connection.setRequestProperty("Authorization", authorizationHeader); connection.setDoInput(true); connection.setDoOutput(true); if (null != urlParameters) { try (PrintWriter out = new PrintWriter(connection.getOutputStream())) { out.print(urlParameters); } } } else { connection = (HttpURLConnection) new URL(url + "?" + urlParameters).openConnection(); connection.setRequestMethod(method); connection.setRequestProperty("Authorization", authorizationHeader); } int timeout = Integer.parseInt(System.getProperty("org.hawkular.accounts.http.timeout", "5000")); connection.setConnectTimeout(timeout); connection.setReadTimeout(timeout); StringBuilder response = new StringBuilder(); int statusCode; try { statusCode = connection.getResponseCode(); logger.requestExecuted(statusCode); } catch (SocketTimeoutException timeoutException) { throw new UsernamePasswordConversionException("Timed out when trying to contact the Keycloak server."); } InputStream inputStream; if (statusCode < 300) { logger.statusCodeSuccess(); inputStream = connection.getInputStream(); } else { logger.statusCodeNotSuccess(); inputStream = connection.getErrorStream(); } try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"))) { for (String line; (line = reader.readLine()) != null;) { response.append(line); } } String responseAsString = response.toString(); logger.responseBody(responseAsString); return responseAsString; }