![JAR search and dependency download from the Maven repository](/logo.png)
org.zodiac.okhttp.BaseAuthenticator Maven / Gradle / Ivy
package org.zodiac.okhttp;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import okhttp3.Authenticator;
import okhttp3.Credentials;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.Route;
public class BaseAuthenticator implements Authenticator {
private final String userName;
private final String password;
public BaseAuthenticator(String userName, String password) {
super();
this.userName = userName;
this.password = password;
}
@Override
public Request authenticate(Route route, Response response) throws IOException {
String credential = Credentials.basic(userName, password, StandardCharsets.UTF_8);
return response.request().newBuilder().header("Authorization", credential).build();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy