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
26
27
28 package org.apache.hc.client5.http.auth;
29
30 import org.apache.hc.core5.annotation.Contract;
31 import org.apache.hc.core5.annotation.ThreadingBehavior;
32
33
34
35
36
37
38
39
40
41
42 @Deprecated
43 @Contract(threading = ThreadingBehavior.IMMUTABLE)
44 public class KerberosConfig implements Cloneable {
45
46 public enum Option {
47
48 DEFAULT,
49 ENABLE,
50 DISABLE
51
52 }
53
54 public static final KerberosConfig DEFAULT = new Builder().build();
55
56 private final Option stripPort;
57 private final Option useCanonicalHostname;
58 private final Option requestDelegCreds;
59
60
61
62
63 protected KerberosConfig() {
64 this(Option.DEFAULT, Option.DEFAULT, Option.DEFAULT);
65 }
66
67 KerberosConfig(
68 final Option stripPort,
69 final Option useCanonicalHostname,
70 final Option requestDelegCreds) {
71 super();
72 this.stripPort = stripPort;
73 this.useCanonicalHostname = useCanonicalHostname;
74 this.requestDelegCreds = requestDelegCreds;
75 }
76
77 public Option getStripPort() {
78 return stripPort;
79 }
80
81 public Option getUseCanonicalHostname() {
82 return useCanonicalHostname;
83 }
84
85 public Option getRequestDelegCreds() {
86 return requestDelegCreds;
87 }
88
89 @Override
90 protected KerberosConfig clone() throws CloneNotSupportedException {
91 return (KerberosConfig) super.clone();
92 }
93
94 @Override
95 public String toString() {
96 final StringBuilder builder = new StringBuilder();
97 builder.append("[");
98 builder.append("stripPort=").append(stripPort);
99 builder.append(", useCanonicalHostname=").append(useCanonicalHostname);
100 builder.append(", requestDelegCreds=").append(requestDelegCreds);
101 builder.append("]");
102 return builder.toString();
103 }
104
105 public static KerberosConfig.Builder custom() {
106 return new Builder();
107 }
108
109 public static KerberosConfig.Builder copy(final KerberosConfig config) {
110 return new Builder()
111 .setStripPort(config.getStripPort())
112 .setUseCanonicalHostname(config.getUseCanonicalHostname())
113 .setRequestDelegCreds(config.getRequestDelegCreds());
114 }
115
116 public static class Builder {
117
118 private Option stripPort;
119 private Option useCanonicalHostname;
120 private Option requestDelegCreds;
121
122 Builder() {
123 super();
124 this.stripPort = Option.DEFAULT;
125 this.useCanonicalHostname = Option.DEFAULT;
126 this.requestDelegCreds = Option.DEFAULT;
127 }
128
129 public Builder setStripPort(final Option stripPort) {
130 this.stripPort = stripPort;
131 return this;
132 }
133
134 public Builder setStripPort(final boolean stripPort) {
135 this.stripPort = stripPort ? Option.ENABLE : Option.DISABLE;
136 return this;
137 }
138
139 public Builder setUseCanonicalHostname(final Option useCanonicalHostname) {
140 this.useCanonicalHostname = useCanonicalHostname;
141 return this;
142 }
143
144 public Builder setUseCanonicalHostname(final boolean useCanonicalHostname) {
145 this.useCanonicalHostname = useCanonicalHostname ? Option.ENABLE : Option.DISABLE;
146 return this;
147 }
148
149 public Builder setRequestDelegCreds(final Option requestDelegCreds) {
150 this.requestDelegCreds = requestDelegCreds;
151 return this;
152 }
153
154 public KerberosConfig build() {
155 return new KerberosConfig(
156 stripPort,
157 useCanonicalHostname,
158 requestDelegCreds);
159 }
160
161 }
162
163 }