All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.davidmoten.oa3.codegen.http.BasicAuthenticator Maven / Gradle / Ivy

The newest version!
package org.davidmoten.oa3.codegen.http;

import java.nio.charset.StandardCharsets;
import java.util.Base64;

public interface BasicAuthenticator extends Interceptor {

    String username();

    String password();

    default RequestBase intercept(RequestBase r) {
        Headers h = new Headers(r.headers());
        String encoded = Base64.getEncoder()
                .encodeToString((username() + ":" + password()).getBytes(StandardCharsets.UTF_8));
        h.put("Authorization", "Basic " + encoded);
        return new RequestBase(r.method(), r.url(), h);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy