diff --git a/api/client/src/main/java/org/projectnessie/client/auth/BasicAuthenticationProvider.java b/api/client/src/main/java/org/projectnessie/client/auth/BasicAuthenticationProvider.java index e324d22f9ca..f335552c59a 100644 --- a/api/client/src/main/java/org/projectnessie/client/auth/BasicAuthenticationProvider.java +++ b/api/client/src/main/java/org/projectnessie/client/auth/BasicAuthenticationProvider.java @@ -69,25 +69,13 @@ public HttpAuthentication build(Function configSupplier) { private static class BasicAuthentication implements HttpAuthentication { private final Supplier headerSupplier; - private static String basicHeader(String username, String password) { - if (username == null || password == null) { - throw new NullPointerException( - "username and password parameters must be present for auth type " + AUTH_TYPE_VALUE); - } - - String userPass = username + ':' + password; - byte[] encoded = Base64.getEncoder().encode(userPass.getBytes(StandardCharsets.UTF_8)); - String encodedString = new String(encoded, StandardCharsets.UTF_8); - return "Basic " + encodedString; - } - private BasicAuthentication(String username, String password) { - String header = basicHeader(username, password); + String header = basicAuthorizationHeader(username, password); this.headerSupplier = () -> header; } private BasicAuthentication(String username, Supplier passwordSupplier) { - this.headerSupplier = () -> basicHeader(username, passwordSupplier.get()); + this.headerSupplier = () -> basicAuthorizationHeader(username, passwordSupplier.get()); } @Override @@ -100,4 +88,16 @@ public void applyToHttpRequest(RequestContext context) { context.putHeader("Authorization", headerSupplier.get()); } } + + public static String basicAuthorizationHeader(String username, String password) { + if (username == null || password == null) { + throw new NullPointerException( + "username and password parameters must be present for auth type " + AUTH_TYPE_VALUE); + } + + String userPass = username + ':' + password; + byte[] encoded = Base64.getEncoder().encode(userPass.getBytes(StandardCharsets.UTF_8)); + String encodedString = new String(encoded, StandardCharsets.UTF_8); + return "Basic " + encodedString; + } }