public static HttpHeaders createHeaders(String username, String password) {
        if (username == null || username.isEmpty()) {
            return new HttpHeaders();
        }
        String auth = username + ":" + password;
        byte[] encodedAuth = Base64.getEncoder().encode(auth.getBytes(StandardCharsets.UTF_8));
        String authHeader = "Basic " + new String(encodedAuth);

        HttpHeaders result =  new HttpHeaders();
        result.add(HttpHeaders.AUTHORIZATION, authHeader);
        return result;
    }
public static HttpHeaders createHeaders ( String username , String password ) { if ( username == null || username . isEmpty ( ) ) { return new HttpHeaders ( ) ; } String auth = username + ":" + password ; byte [ ] encodedAuth = Base64 . getEncoder ( ) . encode ( auth . getBytes ( StandardCharsets . UTF_8 ) ) ; String authHeader = "Basic " + new String ( encodedAuth ) ; HttpHeaders result = new HttpHeaders ( ) ; result . add ( HttpHeaders . AUTHORIZATION , authHeader ) ; return result ; }
With the given {@code username} and {@code password} create a Base64 encoded valid
http BASIC schema authorization header, and return it within a {@link HttpHeaders}
object.

@param username The BASIC auth username
@param password The BASIC auth password
@return The HttpHeaders object containing the Authorization Header