(HttpURLConnection urlc)
| 1009 | } |
| 1010 | |
| 1011 | private void basicAuth(HttpURLConnection urlc) throws Exception { |
| 1012 | if (urlc.getURL().getUserInfo() != null) { |
| 1013 | String encoding = |
| 1014 | Base64.getEncoder().encodeToString(urlc.getURL().getUserInfo().getBytes(US_ASCII)); |
| 1015 | urlc.setRequestProperty("Authorization", "Basic " + encoding); |
| 1016 | } else if (credentials != null) { |
| 1017 | if (!credentials.contains(":")) { |
| 1018 | throw new Exception("credentials '" + credentials + "' must be of format user:pass"); |
| 1019 | } |
| 1020 | urlc.setRequestProperty( |
| 1021 | "Authorization", |
| 1022 | "Basic " + Base64.getEncoder().encodeToString(credentials.getBytes(UTF_8))); |
| 1023 | } |
| 1024 | } |
| 1025 | |
| 1026 | private static boolean checkResponseCode(HttpURLConnection urlc) |
| 1027 | throws IOException, GeneralSecurityException { |
no test coverage detected