MCPcopy Create free account
hub / github.com/apache/solr / basicAuth

Method basicAuth

solr/core/src/java/org/apache/solr/cli/PostTool.java:1011–1024  ·  view source on GitHub ↗
(HttpURLConnection urlc)

Source from the content-addressed store, hash-verified

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 {

Callers 1

postDataMethod · 0.95

Calls 4

getEncoderMethod · 0.65
getBytesMethod · 0.65
getURLMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected