Interface OAuth2TokenServiceCache
- All Known Implementing Classes:
OAuth2TokenServiceCache.Default
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
The cache to store instances of
OAuth2TokenService according to ClientIdentity.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classDefault implementation of the interface. -
Method Summary
Modifier and TypeMethodDescriptionstatic OAuth2TokenServiceCachecreate()Create an empty cache.static OAuth2TokenServiceCachecreate(Map<com.sap.cloud.security.config.ClientIdentity, com.sap.cloud.security.xsuaa.client.OAuth2TokenService> cache) Create a new cache based on an existingMapinstance.com.sap.cloud.security.xsuaa.client.OAuth2TokenServicegetTokenService(com.sap.cloud.security.config.ClientIdentity identity) Get the token service.default voidInvalidate the cache.static OAuth2TokenServiceCachesingle(com.sap.cloud.security.xsuaa.client.OAuth2TokenService tokenService) Create ab immutable cache instance, with a single entry that is being returned for any provided client identity.
-
Method Details
-
getTokenService
@Nonnull com.sap.cloud.security.xsuaa.client.OAuth2TokenService getTokenService(@Nullable com.sap.cloud.security.config.ClientIdentity identity) Get the token service. Optionally apply client identity secrets to the internalHttpClient.- Parameters:
identity- The client identity of a service binding.- Returns:
- A new or cached instance of
OAuth2TokenService.
-
invalidateCache
default void invalidateCache()Invalidate the cache. -
create
Create an empty cache.- Returns:
- A new instance of
OAuth2TokenServiceCache.
-
create
@Nonnull static OAuth2TokenServiceCache create(@Nonnull Map<com.sap.cloud.security.config.ClientIdentity, com.sap.cloud.security.xsuaa.client.OAuth2TokenService> cache) Create a new cache based on an existingMapinstance. Use this method for testing or customization.- Parameters:
cache- Custom data store for the cache.- Returns:
- A new instance of
OAuth2TokenServiceCache.
-
single
@Nonnull static OAuth2TokenServiceCache single(@Nonnull com.sap.cloud.security.xsuaa.client.OAuth2TokenService tokenService) Create ab immutable cache instance, with a single entry that is being returned for any provided client identity. Use this method for testing or for disabling the cache.- Parameters:
tokenService- AOAuth2TokenServicethat will always be returned.- Returns:
- An immutable instance of
OAuth2TokenServiceCache.
-