yangys
2024-04-02 6bed83e92f67954cd2135071133329f2205efe4f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package com.qianwen.core.http;
 
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import okhttp3.Authenticator;
import okhttp3.Credentials;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.Route;
 
/* loaded from: blade-starter-http-9.3.0.0-SNAPSHOT.jar:org/springblade/core/http/BaseAuthenticator.class */
public class BaseAuthenticator implements Authenticator {
    private final String userName;
    private final String password;
 
    public BaseAuthenticator(final String userName, final String password) {
        this.userName = userName;
        this.password = password;
    }
 
    public Request authenticate(Route route, Response response) throws IOException {
        String credential = Credentials.basic(this.userName, this.password, StandardCharsets.UTF_8);
        return response.request().newBuilder().header("Authorization", credential).build();
    }
}