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

tech.msop.core.http.BaseAuthenticator Maven / Gradle / Ivy

There is a newer version: 0.2.6.RELEASE
Show newest version
package tech.msop.core.http;

import lombok.RequiredArgsConstructor;
import okhttp3.*;

import java.io.IOException;
import java.nio.charset.StandardCharsets;

/**
 * BaseAuth
 *
 * @author ruozhuliufeng
 */
@RequiredArgsConstructor
public class BaseAuthenticator implements Authenticator {
	private final String userName;
	private final String 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