Skip to content

Commit a34a560

Browse files
committed
renames KerberosCredentials
1 parent 8167ccd commit a34a560

File tree

7 files changed

+102
-47
lines changed

7 files changed

+102
-47
lines changed

httpclient5-testing/src/test/java/org/apache/hc/client5/testing/compatibility/async/HttpAsyncClientCompatibilityTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
import org.apache.hc.client5.http.async.methods.SimpleRequestBuilder;
3838
import org.apache.hc.client5.http.auth.AuthScope;
3939
import org.apache.hc.client5.http.auth.Credentials;
40-
import org.apache.hc.client5.http.auth.KerberosCredentials;
4140
import org.apache.hc.client5.http.auth.UsernamePasswordCredentials;
41+
import org.apache.hc.client5.http.auth.gss.GssCredentials;
4242
import org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient;
4343
import org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider;
4444
import org.apache.hc.client5.http.protocol.HttpClientContext;
@@ -83,7 +83,7 @@ public HttpAsyncClientCompatibilityTest(
8383
this.clientResource = new HttpAsyncClientResource(versionPolicy);
8484
if (targetCreds != null) {
8585
//this.setCredentials(new AuthScope(target), targetCreds);
86-
if (targetCreds instanceof KerberosCredentials) {
86+
if (targetCreds instanceof GssCredentials) {
8787
secretPath = "/private_spnego/big-secret.txt";
8888
this.clientResource.configure(builder -> builder
8989
.setTargetAuthenticationStrategy(new SpnegoAuthenticationStrategy())
@@ -94,7 +94,7 @@ public HttpAsyncClientCompatibilityTest(
9494
this.clientResource.configure(builder -> builder.setProxy(proxy));
9595
if (proxyCreds != null) {
9696
this.setCredentials(new AuthScope(proxy), proxyCreds);
97-
if (proxyCreds instanceof KerberosCredentials) {
97+
if (proxyCreds instanceof GssCredentials) {
9898
// We disable Mutual Auth, because Squid does not support it.
9999
// There is no way to set separate scheme registry for target/proxy,
100100
// but that's not a problem as SPNEGO cannot be proxied anyway.

httpclient5-testing/src/test/java/org/apache/hc/client5/testing/compatibility/spnego/SpnegoTestUtil.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@
4848

4949
import org.apache.hc.client5.http.SystemDefaultDnsResolver;
5050
import org.apache.hc.client5.http.auth.AuthSchemeFactory;
51-
import org.apache.hc.client5.http.auth.KerberosCredentials;
5251
import org.apache.hc.client5.http.auth.StandardAuthScheme;
5352
import org.apache.hc.client5.http.auth.gss.GssConfig;
53+
import org.apache.hc.client5.http.auth.gss.GssCredentials;
5454
import org.apache.hc.client5.http.impl.auth.BasicSchemeFactory;
5555
import org.apache.hc.client5.http.impl.auth.BearerSchemeFactory;
5656
import org.apache.hc.client5.http.impl.auth.DigestSchemeFactory;
@@ -70,11 +70,11 @@ public class SpnegoTestUtil {
7070
static private final SpnegoSchemeFactory NO_MUTUAL_SCHEME_FACTORY =
7171
new SpnegoSchemeFactory(NO_MUTUAL_KERBEROS_CONFIG, SystemDefaultDnsResolver.INSTANCE);
7272

73-
public static KerberosCredentials createCredentials(final Subject subject) {
74-
return SecurityUtils.callAs(subject, new Callable<KerberosCredentials>() {
73+
public static GssCredentials createCredentials(final Subject subject) {
74+
return SecurityUtils.callAs(subject, new Callable<GssCredentials>() {
7575
@Override
76-
public KerberosCredentials call() throws Exception {
77-
return new KerberosCredentials(
76+
public GssCredentials call() throws Exception {
77+
return new GssCredentials(
7878
GSSManager.getInstance().createCredential(GSSCredential.INITIATE_ONLY));
7979
}
8080
});

httpclient5-testing/src/test/java/org/apache/hc/client5/testing/compatibility/sync/HttpClientCompatibilityTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
import org.apache.hc.client5.http.auth.AuthScope;
3232
import org.apache.hc.client5.http.auth.Credentials;
3333
import org.apache.hc.client5.http.auth.CredentialsStore;
34-
import org.apache.hc.client5.http.auth.KerberosCredentials;
3534
import org.apache.hc.client5.http.auth.UsernamePasswordCredentials;
35+
import org.apache.hc.client5.http.auth.gss.GssCredentials;
3636
import org.apache.hc.client5.http.classic.methods.HttpGet;
3737
import org.apache.hc.client5.http.classic.methods.HttpOptions;
3838
import org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider;
@@ -68,7 +68,7 @@ public HttpClientCompatibilityTest(final HttpHost target, final Credentials targ
6868
this.clientResource = new HttpClientResource();
6969
if (targetCreds != null) {
7070
//this.setCredentials(new AuthScope(target), targetCreds);
71-
if (targetCreds instanceof KerberosCredentials) {
71+
if (targetCreds instanceof GssCredentials) {
7272
secretPath = "/private_spnego/big-secret.txt";
7373
this.clientResource.configure(builder -> builder
7474
.setTargetAuthenticationStrategy(new SpnegoAuthenticationStrategy())
@@ -79,7 +79,7 @@ public HttpClientCompatibilityTest(final HttpHost target, final Credentials targ
7979
this.clientResource.configure(builder -> builder.setProxy(proxy));
8080
if (proxyCreds != null) {
8181
this.setCredentials(new AuthScope(proxy), proxyCreds);
82-
if (proxyCreds instanceof KerberosCredentials) {
82+
if (proxyCreds instanceof GssCredentials) {
8383
// We disable Mutual Auth, because Squid does not support it.
8484
// There is no way to set separate scheme registry for target/proxy,
8585
// but that's not a problem as SPNEGO cannot be proxied anyway.

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

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@
2626
*/
2727
package org.apache.hc.client5.http.auth;
2828

29-
import java.io.Serializable;
30-
import java.security.Principal;
31-
29+
import org.apache.hc.client5.http.auth.gss.GssCredentials;
3230
import org.apache.hc.core5.annotation.Contract;
3331
import org.apache.hc.core5.annotation.ThreadingBehavior;
3432
import org.ietf.jgss.GSSCredential;
@@ -38,41 +36,24 @@
3836
*
3937
* @since 4.4
4038
*
39+
* The original KerberosCredentials class has been renamed to
40+
* org.apache.hc.client5.http.auth.gss.GssCredentials for the new Mutual capable SPNEGO Scheme.
41+
* This is an identical child class with the original name to maintain backwards compatibility.
4142
*
42-
* Optionally used both by {@link org.apache.hc.client5.http.impl.auth.gss.SpnegoScheme}
43-
* and the old deprecated GGS based experimental authentication schemes.
44-
*
43+
* @deprecated Do not use. The old GGS based experimental authentication schemes are no longer
44+
* supported.
45+
* Use org.apache.hc.client5.http.impl.auth.gss.SpnegoScheme, or consider using Basic or Bearer
46+
* authentication with TLS instead.
4547
* @see org.apache.hc.client5.http.impl.auth.gss.SpnegoScheme
48+
* @see org.apache.hc.client5.http.auth.gss.GssConfig
49+
* @see org.apache.hc.client5.http.auth.gss.GssCredentials
4650
*/
51+
@Deprecated
4752
@Contract(threading = ThreadingBehavior.IMMUTABLE)
48-
public class KerberosCredentials implements Credentials, Serializable {
49-
50-
private static final long serialVersionUID = 487421613855550713L;
53+
public class KerberosCredentials extends GssCredentials {
5154

52-
/** GSSCredential */
53-
private final GSSCredential gssCredential;
54-
55-
/**
56-
* Constructor with GSSCredential argument
57-
*
58-
* @param gssCredential
59-
*/
6055
public KerberosCredentials(final GSSCredential gssCredential) {
61-
this.gssCredential = gssCredential;
62-
}
63-
64-
public GSSCredential getGSSCredential() {
65-
return gssCredential;
66-
}
67-
68-
@Override
69-
public Principal getUserPrincipal() {
70-
return null;
71-
}
72-
73-
@Override
74-
public char[] getPassword() {
75-
return null;
56+
super(gssCredential);
7657
}
7758

7859
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* ====================================================================
3+
* Licensed to the Apache Software Foundation (ASF) under one
4+
* or more contributor license agreements. See the NOTICE file
5+
* distributed with this work for additional information
6+
* regarding copyright ownership. The ASF licenses this file
7+
* to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance
9+
* with the License. You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing,
14+
* software distributed under the License is distributed on an
15+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
* KIND, either express or implied. See the License for the
17+
* specific language governing permissions and limitations
18+
* under the License.
19+
* ====================================================================
20+
*
21+
* This software consists of voluntary contributions made by many
22+
* individuals on behalf of the Apache Software Foundation. For more
23+
* information on the Apache Software Foundation, please see
24+
* <http://www.apache.org/>.
25+
*
26+
*/
27+
package org.apache.hc.client5.http.auth.gss;
28+
29+
import java.io.Serializable;
30+
import java.security.Principal;
31+
32+
import org.apache.hc.client5.http.auth.Credentials;
33+
import org.apache.hc.core5.annotation.Contract;
34+
import org.apache.hc.core5.annotation.ThreadingBehavior;
35+
import org.ietf.jgss.GSSCredential;
36+
37+
/**
38+
* Kerberos specific {@link Credentials} representation based on {@link GSSCredential}.
39+
*
40+
* @since 5.5
41+
*
42+
*/
43+
@Contract(threading = ThreadingBehavior.IMMUTABLE)
44+
public class GssCredentials implements Credentials, Serializable {
45+
46+
private static final long serialVersionUID = 487421613855550713L;
47+
48+
/** GSSCredential */
49+
private final GSSCredential gssCredential;
50+
51+
/**
52+
* Constructor with GSSCredential argument
53+
*
54+
* @param gssCredential
55+
*/
56+
public GssCredentials(final GSSCredential gssCredential) {
57+
this.gssCredential = gssCredential;
58+
}
59+
60+
public GSSCredential getGSSCredential() {
61+
return gssCredential;
62+
}
63+
64+
@Override
65+
public Principal getUserPrincipal() {
66+
return null;
67+
}
68+
69+
@Override
70+
public char[] getPassword() {
71+
return null;
72+
}
73+
74+
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ public boolean isResponseReady(
186186

187187
final Credentials credentials = credentialsProvider.getCredentials(
188188
new AuthScope(host, null, getName()), context);
189-
if (credentials instanceof org.apache.hc.client5.http.auth.KerberosCredentials) {
190-
this.gssCredential = ((org.apache.hc.client5.http.auth.KerberosCredentials) credentials).getGSSCredential();
189+
if (credentials instanceof org.apache.hc.client5.http.auth.gss.GssCredentials) {
190+
this.gssCredential = ((org.apache.hc.client5.http.auth.gss.GssCredentials) credentials).getGSSCredential();
191191
} else {
192192
this.gssCredential = null;
193193
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,9 @@ protected void setGssCredential(final CredentialsProvider credentialsProvider,
313313
}
314314
final Credentials credentials =
315315
credentialsProvider.getCredentials(new AuthScope(host, null, getName()), context);
316-
if (credentials instanceof org.apache.hc.client5.http.auth.KerberosCredentials) {
316+
if (credentials instanceof org.apache.hc.client5.http.auth.gss.GssCredentials) {
317317
this.gssCredential =
318-
((org.apache.hc.client5.http.auth.KerberosCredentials) credentials)
318+
((org.apache.hc.client5.http.auth.gss.GssCredentials) credentials)
319319
.getGSSCredential();
320320
} else {
321321
this.gssCredential = null;

0 commit comments

Comments
 (0)