Class CachingService

java.lang.Object
org.trustdeck.service.CachingService

@Service public class CachingService extends Object
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 Details

    • CachingService

      public CachingService()
  • Method Details

    • getGroupPaths

      public List<String> getGroupPaths(String userId)
      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

      public void flushAndReCacheMatchingGroups(String userId, String domain)
      Flushes and re-caches group paths for a user if the given domain occurs in the cached groups.
      Parameters:
      userId - the ID of the user
      domain - the domain to check for
    • flushAndReCacheMatchingGroups

      public void flushAndReCacheMatchingGroups(String userId, String domain, boolean force)
      Flushes and re-caches group paths for a user if the given domain occurs in the cached groups.
      Parameters:
      userId - the ID of the user
      domain - the domain to check for
      force - force deletion of groups from cache
    • cacheGroups

      protected List<String> cacheGroups(String userId)
      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

      public void flushGroupIfDomainOccurs(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.
      Parameters:
      userId - the ID of the user
      domain - the domain to check for in group paths
      force - force deletion of groups from cache