Package org.trustdeck.service
Class CachingService
java.lang.Object
org.trustdeck.service.CachingService
CachingService is a service class responsible for caching group paths for faster authentication.
It uses Hazelcast as the underlying caching mechanism.
This service includes methods to retrieve group paths for a user, cache the group paths if not present,
flush and re-cache groups when a domain match is found, and handle concurrent access using write locks.
- Author:
- Eric Wündisch and Armin Müller
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncacheGroups(String userId) Retrieves group paths for the given user ID from the OIDC service, caches them, and returns the group paths.voidflushAndReCacheMatchingGroups(String userId, String domain) Flushes and re-caches group paths for a user if the given domain occurs in the cached groups.voidflushAndReCacheMatchingGroups(String userId, String domain, boolean force) Flushes and re-caches group paths for a user if the given domain occurs in the cached groups.voidflushGroupIfDomainOccurs(String userId, String domain, boolean force) Flushes the group paths from the cache if the specified domain is found in any of the group paths.getGroupPaths(String userId) Retrieves the group paths for the given user ID from the cache.
-
Constructor Details
-
CachingService
public CachingService()
-
-
Method Details
-
getGroupPaths
Retrieves the group paths for the given user ID from the cache. If the resource is currently locked, it waits for the lock to be released before trying to retrieve. If the group paths are not present in the cache, it retrieves them from the OIDC service and caches them.- Parameters:
userId- the ID of the user- Returns:
- a list of group paths for the user
-
flushAndReCacheMatchingGroups
Flushes and re-caches group paths for a user if the given domain occurs in the cached groups.- Parameters:
userId- the ID of the userdomain- the domain to check for
-
flushAndReCacheMatchingGroups
Flushes and re-caches group paths for a user if the given domain occurs in the cached groups.- Parameters:
userId- the ID of the userdomain- the domain to check forforce- force deletion of groups from cache
-
cacheGroups
Retrieves group paths for the given user ID from the OIDC service, caches them, and returns the group paths.- Parameters:
userId- the ID of the user- Returns:
- a list of group paths for the user
-
flushGroupIfDomainOccurs
Flushes the group paths from the cache if the specified domain is found in any of the group paths.- Parameters:
userId- the ID of the userdomain- the domain to check for in group pathsforce- force deletion of groups from cache
-