Skip to content

Commit 1b28a5a

Browse files
committed
MutualKerberosConfig changes
1 parent 51de855 commit 1b28a5a

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

httpclient5/src/main/java/org/apache/hc/client5/http/auth/MutualKerberosConfig.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
* Unlike the deprecated {@link KerberosConfig}, this class uses explicit defaults, and
3737
* primitive booleans.
3838
*
39+
* Compared to {@link KerberosConfig} stripPort has been changed toAddPort, and the default is now
40+
* false (same effect). The default for useCanonicalHostname has been changed to false from true.
41+
*
3942
* @since 5.5
4043
*
4144
*/
@@ -45,7 +48,7 @@ public class MutualKerberosConfig implements Cloneable {
4548

4649
public static final MutualKerberosConfig DEFAULT = new Builder().build();
4750

48-
private final boolean stripPort;
51+
private final boolean addPort;
4952
private final boolean useCanonicalHostname;
5053
private final boolean requestMutualAuth;
5154
private final boolean requestDelegCreds;
@@ -54,7 +57,7 @@ public class MutualKerberosConfig implements Cloneable {
5457
* Intended for CDI compatibility
5558
*/
5659
protected MutualKerberosConfig() {
57-
this(true, true, true, false);
60+
this(false, false, true, false);
5861
}
5962

6063
MutualKerberosConfig(
@@ -63,14 +66,14 @@ protected MutualKerberosConfig() {
6366
final boolean requestMutualAuth,
6467
final boolean requestDelegCreds) {
6568
super();
66-
this.stripPort = stripPort;
69+
this.addPort = stripPort;
6770
this.useCanonicalHostname = useCanonicalHostname;
6871
this.requestMutualAuth = requestMutualAuth;
6972
this.requestDelegCreds = requestDelegCreds;
7073
}
7174

72-
public boolean isStripPort() {
73-
return stripPort;
75+
public boolean isAddPort() {
76+
return addPort;
7477
}
7578

7679
public boolean isUseCanonicalHostname() {
@@ -94,7 +97,7 @@ protected MutualKerberosConfig clone() throws CloneNotSupportedException {
9497
public String toString() {
9598
final StringBuilder builder = new StringBuilder();
9699
builder.append("[");
97-
builder.append("stripPort=").append(stripPort);
100+
builder.append("addPort=").append(addPort);
98101
builder.append(", useCanonicalHostname=").append(useCanonicalHostname);
99102
builder.append(", requestDelegCreds=").append(requestDelegCreds);
100103
builder.append(", requestMutualAuth=").append(requestMutualAuth);
@@ -108,25 +111,25 @@ public static MutualKerberosConfig.Builder custom() {
108111

109112
public static MutualKerberosConfig.Builder copy(final MutualKerberosConfig config) {
110113
return new Builder()
111-
.setStripPort(config.isStripPort())
114+
.setAddPort(config.isAddPort())
112115
.setUseCanonicalHostname(config.isUseCanonicalHostname())
113116
.setRequestDelegCreds(config.isRequestDelegCreds())
114117
.setRequestMutualAuth(config.isRequestMutualAuth());
115118
}
116119

117120
public static class Builder {
118121

119-
private boolean stripPort = true;
120-
private boolean useCanonicalHostname = true ;
122+
private boolean addPort = false;
123+
private boolean useCanonicalHostname = false;
121124
private boolean requestMutualAuth = true;
122125
private boolean requestDelegCreds = false;
123126

124127
Builder() {
125128
super();
126129
}
127130

128-
public Builder setStripPort(final boolean stripPort) {
129-
this.stripPort = stripPort;
131+
public Builder setAddPort(final boolean addPort) {
132+
this.addPort = addPort;
130133
return this;
131134
}
132135

@@ -147,7 +150,7 @@ public Builder setRequestDelegCreds(final boolean requuestDelegCreds) {
147150

148151
public MutualKerberosConfig build() {
149152
return new MutualKerberosConfig(
150-
stripPort,
153+
addPort,
151154
useCanonicalHostname,
152155
requestMutualAuth,
153156
requestDelegCreds

httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/MutualGssSchemeBase.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,10 @@ public void processChallenge(
153153
} catch (final UnknownHostException ignore) {
154154
}
155155
}
156-
if (config.isStripPort()) {
157-
gssHostname = hostname;
158-
} else {
156+
if (config.isAddPort()) {
159157
gssHostname = hostname + ":" + host.getPort();
158+
} else {
159+
gssHostname = hostname;
160160
}
161161

162162
if (LOG.isDebugEnabled()) {

httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/MutualSpnegoSchemeFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public class MutualSpnegoSchemeFactory implements AuthSchemeFactory {
6060
private final DnsResolver dnsResolver;
6161

6262
/**
63-
* @since 5.0
63+
* @since 5.5
6464
*/
6565
public MutualSpnegoSchemeFactory(final org.apache.hc.client5.http.auth.MutualKerberosConfig config, final DnsResolver dnsResolver) {
6666
super();

0 commit comments

Comments
 (0)