Implement an in-memory key-value storage to track bad login attempts and integrate it with an Authenticator class. This is useful for locking out users after too many failed login attempts.
You will complete three private methods that rely on the BadLoginAttemptsStorage.
Implement the following methods:
increaseBadLoginAttemptsCounter(String email)isLockedOut(String email)resetCounter(String email)
This is a simple in-memory implementation using HashMap.
- Create a field
private final Map<String, Integer> storage = new HashMap<>();- Implement the following methods:
get(String key)put(String key, Integer value)increment(String key)remove(String key)
Implement a Redis-backed key-value storage to track bad login attempts with an automatic expiration (TTL). This implementation uses RedisTemplate and ValueOperations to interact with Redis.
You will complete methods to interact with Redis. Key operations should include get, put, increment, remove, and setting TTL.
Implement the following methods:
get(String key)put(String key, Integer value)increment(String key)remove(String key)setTtl(String key)
Implement a Redis-based task queue where tasks are associated with a user. The queue will support operations to push tasks, pop tasks, and clear tasks for a given user. Redis will be used to store tasks in a list.
You will implement three methods: push, pop, and clear. The key operations will use Redis lists to enqueue and dequeue tasks.
Implement the following methods:
push(String user, String task)pop(String user)clear(String user)