Class TokenRefreshInterceptor
- java.lang.Object
-
- io.fabric8.kubernetes.client.utils.TokenRefreshInterceptor
-
- All Implemented Interfaces:
Interceptor
public class TokenRefreshInterceptor extends Object implements Interceptor
Interceptor for handling kube authentication. It will either be basic auth, or token based. This class takes responsibility for refreshing expired OIDC tokens.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.fabric8.kubernetes.client.http.Interceptor
Interceptor.RequestTags
-
-
Constructor Summary
Constructors Constructor Description TokenRefreshInterceptor(Config config, HttpClient.Factory factory, Instant latestRefreshTimestamp)
TokenRefreshInterceptor(Config config, Instant latestRefreshTimestamp, Function<Config,CompletableFuture<String>> remoteRefresh)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CompletableFuture<Boolean>
afterFailure(BasicBuilder headerBuilder, HttpResponse<?> response, Interceptor.RequestTags tags)
Called after a websocket failure or by default from a normal request.void
before(BasicBuilder headerBuilder, HttpRequest request, Interceptor.RequestTags tags)
Called before a request to allow for the manipulation of the requestprotected boolean
isBasicAuth()
protected boolean
shouldFail(HttpResponse<?> response)
protected boolean
useBasicAuth()
protected boolean
useRemoteRefresh(Config newestConfig)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.fabric8.kubernetes.client.http.Interceptor
after, afterConnectionFailure, afterFailure, consumer
-
-
-
-
Field Detail
-
AUTHORIZATION
public static final String AUTHORIZATION
- See Also:
- Constant Field Values
-
NAME
public static final String NAME
- See Also:
- Constant Field Values
-
config
protected final Config config
-
-
Constructor Detail
-
TokenRefreshInterceptor
public TokenRefreshInterceptor(Config config, HttpClient.Factory factory, Instant latestRefreshTimestamp)
-
-
Method Detail
-
before
public void before(BasicBuilder headerBuilder, HttpRequest request, Interceptor.RequestTags tags)
Description copied from interface:Interceptor
Called before a request to allow for the manipulation of the request- Specified by:
before
in interfaceInterceptor
- Parameters:
headerBuilder
- used to modify the requestrequest
- the current request
-
useBasicAuth
protected boolean useBasicAuth()
-
isBasicAuth
protected final boolean isBasicAuth()
-
afterFailure
public CompletableFuture<Boolean> afterFailure(BasicBuilder headerBuilder, HttpResponse<?> response, Interceptor.RequestTags tags)
Description copied from interface:Interceptor
Called after a websocket failure or by default from a normal request.Failure is determined by HTTP status code and will be invoked in addition to
Interceptor.after(HttpRequest, HttpResponse, AsyncBody.Consumer)
- Specified by:
afterFailure
in interfaceInterceptor
- Parameters:
headerBuilder
- used to modify the requestresponse
- the failed response- Returns:
- true if the builder should be used to execute a new request
-
shouldFail
protected boolean shouldFail(HttpResponse<?> response)
-
useRemoteRefresh
protected boolean useRemoteRefresh(Config newestConfig)
-
-