Class RedisTokenBlacklistRepository

java.lang.Object
com.broadleafcommerce.auth.authorization.security.tokenblacklist.redis.RedisTokenBlacklistRepository

public class RedisTokenBlacklistRepository extends Object
Simple repository used for interacting with Redis to manage blacklisted tokens.
Since:
AuthenticationServices 3.0.0, Release Train 3.0.0
  • Field Details

  • Constructor Details

    • RedisTokenBlacklistRepository

      public RedisTokenBlacklistRepository(org.springframework.data.redis.core.StringRedisTemplate redisTemplate)
  • Method Details

    • blacklist

      public void blacklist(String tokenId, String tokenType, Duration ttl)
      Registers the token ID in Redis with a specified Time-to-Live (TTL).
      Parameters:
      tokenId - the token ID to blacklist
      tokenType - the token type of the blacklist record
      ttl - the Time-to-Live duration for the blacklist record
    • isBlacklisted

      public boolean isBlacklisted(String tokenId, String tokenType)
      Checks if the given token ID exists in Redis.
      Parameters:
      tokenId - the token ID to check
      tokenType - the token type of the blacklist record
      Returns:
      true if the token ID exists in the blacklist, false otherwise
    • getBlacklistedTokenKey

      protected String getBlacklistedTokenKey(String tokenId, String tokenType)
      Generates a key prefixed with the blacklist identifier and the lowercased token type, followed by the raw token ID.
      Parameters:
      tokenId - the raw token ID
      tokenType - the type of the token
      Returns:
      the key to use to store the token in the blacklist
    • getRedisTemplate

      protected org.springframework.data.redis.core.StringRedisTemplate getRedisTemplate()