Skip to content

Commit 9a0b4a7

Browse files
committed
Add SpnegoAuthenticationException for better error handling in SPNEGO authentication
Signed-off-by: raccoonback <[email protected]>
1 parent ecc4095 commit 9a0b4a7

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

reactor-netty-http/src/main/java/reactor/netty/http/client/SpnegoAuthProvider.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public static SpnegoAuthProvider create(SpnegoAuthenticator authenticator, GSSMa
107107
* @param request the HTTP client request to authenticate
108108
* @param address the target server address (used for service principal)
109109
* @return a Mono that completes when the authentication is applied
110-
* @throws RuntimeException if login or token generation fails
110+
* @throws SpnegoAuthenticationException if login or token generation fails
111111
*/
112112
public Mono<Void> apply(HttpClientRequest request, InetSocketAddress address) {
113113
if (verifiedAuthHeader != null) {
@@ -129,13 +129,13 @@ public Mono<Void> apply(HttpClientRequest request, InetSocketAddress address) {
129129
return token;
130130
}
131131
catch (GSSException e) {
132-
throw new RuntimeException("Failed to generate SPNEGO token", e);
132+
throw new SpnegoAuthenticationException("Failed to generate SPNEGO token", e);
133133
}
134134
}
135135
);
136136
}
137137
catch (LoginException e) {
138-
throw new RuntimeException("Failed to login with SPNEGO", e);
138+
throw new SpnegoAuthenticationException("Failed to login with SPNEGO", e);
139139
}
140140
})
141141
.subscribeOn(boundedElastic())
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright (c) 2025 VMware, Inc. or its affiliates, All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package reactor.netty.http.client;
17+
18+
/**
19+
* Exception thrown when SPNEGO (Kerberos) authentication fails.
20+
*
21+
* @author raccoonback
22+
* @since 1.3.0
23+
*/
24+
public class SpnegoAuthenticationException extends RuntimeException {
25+
26+
public SpnegoAuthenticationException(String message, Throwable cause) {
27+
super(message, cause);
28+
}
29+
}

0 commit comments

Comments
 (0)