34 import java.nio.charset.Charset;
35 import java.io.IOException;
36 import java.io.OutputStream;
37 import java.util.Arrays;
38 import java.util.Base64;
39 import java.util.Objects;
40 import sun.net.www.HeaderParser;
41 import static java.nio.charset.StandardCharsets.UTF_8;
42 import static java.nio.charset.StandardCharsets.ISO_8859_1;
43
44 /**
45 * BasicAuthentication: Encapsulate an http server authentication using
46 * the "basic" scheme.
47 *
48 * @author Bill Foote
49 */
50
51
52 class BasicAuthentication extends AuthenticationInfo {
53
54 private static final long serialVersionUID = 100L;
55
56 /** The authentication string for this host, port, and realm. This is
57 a simple BASE64 encoding of "login:password". */
58 final String auth;
59
60 /**
61 * Create a BasicAuthentication
62 */
63 public BasicAuthentication(boolean isProxy, String host, int port,
64 String realm, PasswordAuthentication pw,
65 boolean isUTF8, String authenticatorKey) {
66 super(isProxy ? PROXY_AUTHENTICATION : SERVER_AUTHENTICATION,
67 AuthScheme.BASIC, host, port, realm,
68 Objects.requireNonNull(authenticatorKey));
69 this.auth = authValueFrom(pw, isUTF8);
70 this.pw = pw;
71 }
72
73 /**
|
34 import java.nio.charset.Charset;
35 import java.io.IOException;
36 import java.io.OutputStream;
37 import java.util.Arrays;
38 import java.util.Base64;
39 import java.util.Objects;
40 import sun.net.www.HeaderParser;
41 import static java.nio.charset.StandardCharsets.UTF_8;
42 import static java.nio.charset.StandardCharsets.ISO_8859_1;
43
44 /**
45 * BasicAuthentication: Encapsulate an http server authentication using
46 * the "basic" scheme.
47 *
48 * @author Bill Foote
49 */
50
51
52 class BasicAuthentication extends AuthenticationInfo {
53
54 @java.io.Serial
55 private static final long serialVersionUID = 100L;
56
57 /** The authentication string for this host, port, and realm. This is
58 a simple BASE64 encoding of "login:password". */
59 final String auth;
60
61 /**
62 * Create a BasicAuthentication
63 */
64 public BasicAuthentication(boolean isProxy, String host, int port,
65 String realm, PasswordAuthentication pw,
66 boolean isUTF8, String authenticatorKey) {
67 super(isProxy ? PROXY_AUTHENTICATION : SERVER_AUTHENTICATION,
68 AuthScheme.BASIC, host, port, realm,
69 Objects.requireNonNull(authenticatorKey));
70 this.auth = authValueFrom(pw, isUTF8);
71 this.pw = pw;
72 }
73
74 /**
|