Modifier and Type | Method and Description |
---|---|
static <T> T |
executeWithAuthToken(AuthToken authToken,
Callable<T> callable)
Execute the given
Callable with a given token. |
static void |
executeWithAuthToken(AuthToken authToken,
Executable executable)
Execute the given
Executable with a given token. |
static <T> T |
executeWithFallbackAuthToken(Supplier<AuthToken> fallbackAuthToken,
Callable<T> callable)
Execute the given
Callable , using the given token as fallback if there is no other token available. |
static void |
executeWithFallbackAuthToken(Supplier<AuthToken> fallbackAuthToken,
Executable executable)
Execute the given
Executable , using the given token as fallback if there is no other token available. |
static AuthTokenFacade |
getAuthTokenFacade()
The
AuthTokenFacade instance. |
static AuthToken |
getCurrentToken()
Returns the current
AuthToken . |
static Supplier<AuthToken> |
getFallbackToken()
Global fallback
AuthToken . |
static Future<String> |
getRefreshToken(com.auth0.jwt.interfaces.DecodedJWT jwt)
Returns a
Future that resolves to a refresh token. |
static AuthToken |
getXsuaaServiceToken()
Retrieves a validated authentication token from the bound XSUAA instance.
|
static void |
setAuthTokenFacade(AuthTokenFacade requestFacade)
Replaces the default
AuthTokenFacade instance. |
static void |
setFallbackToken(Supplier<AuthToken> fallbackToken)
Global fallback
AuthToken . |
static io.vavr.control.Try<AuthToken> |
tryGetCurrentToken()
|
static io.vavr.control.Try<AuthToken> |
tryGetXsuaaServiceToken()
Retrieves a validated authentication token from the bound XSUAA instance.
|
public static void setAuthTokenFacade(@Nullable AuthTokenFacade requestFacade)
AuthTokenFacade
instance.requestFacade
- An instance of AuthTokenFacade
. Use null
to reset the facade.@Nonnull public static AuthToken getCurrentToken() throws AuthTokenAccessException
AuthToken
.AuthToken
.AuthTokenAccessException
- If there is an issue while trying to access the AuthToken
. For instance, an AuthToken
is not available if no request is available or the request does not contain an "Authorization"
header.@Nonnull public static io.vavr.control.Try<AuthToken> tryGetCurrentToken()
Try
of the current AuthToken
, or, if the Try
is a failure, the global fallback.
An AuthToken
is not available if no request is available or the request does not contain an
"Authorization" header.Try
of the current AuthToken
@Nonnull public static AuthToken getXsuaaServiceToken() throws TokenRequestFailedException
Try
of the XSUAA authentication token.TokenRequestFailedException
- If no XSUAA instance was bound or the communication with the service failed.@Nonnull public static io.vavr.control.Try<AuthToken> tryGetXsuaaServiceToken()
Try
of the XSUAA authentication token.@Nonnull public static Future<String> getRefreshToken(@Nonnull com.auth0.jwt.interfaces.DecodedJWT jwt) throws TokenRequestFailedException, TokenRequestDeniedException
Future
that resolves to a refresh token.Future
that resolves to a refresh token.TokenRequestFailedException
TokenRequestDeniedException
@Nullable public static <T> T executeWithAuthToken(@Nonnull AuthToken authToken, @Nonnull Callable<T> callable) throws ThreadContextExecutionException
Callable
with a given token.T
- The type of the callable.authToken
- The token to execute with.callable
- The callable to execute.ThreadContextExecutionException
- If there is an issue while running the code with the token.public static void executeWithAuthToken(@Nonnull AuthToken authToken, @Nonnull Executable executable) throws ThreadContextExecutionException
Executable
with a given token.authToken
- The token to execute with.ThreadContextExecutionException
- If there is an issue while running the code with the token.@Nullable public static <T> T executeWithFallbackAuthToken(@Nonnull Supplier<AuthToken> fallbackAuthToken, @Nonnull Callable<T> callable) throws ThreadContextExecutionException
Callable
, using the given token as fallback if there is no other token available.T
- The type of the callable.fallbackAuthToken
- The token to fall back to.callable
- The callable to execute.ThreadContextExecutionException
- If there is an issue while running the code with the token.public static void executeWithFallbackAuthToken(@Nonnull Supplier<AuthToken> fallbackAuthToken, @Nonnull Executable executable) throws ThreadContextExecutionException
Executable
, using the given token as fallback if there is no other token available.fallbackAuthToken
- The token to fall back to.ThreadContextExecutionException
- If there is an issue while running the code with the token.@Nonnull public static AuthTokenFacade getAuthTokenFacade()
AuthTokenFacade
instance.@Nullable public static Supplier<AuthToken> getFallbackToken()
AuthToken
. By default, no fallback is used, i.e., the fallback is null
. A global
fallback can be useful to ensure a safe fallback or to ease testing with a mocked token.Copyright © 2019 SAP SE. All rights reserved.