Class CacheAttemptStore
java.lang.Object
io.leandev.appfuse.security.lockout.store.CacheAttemptStore
- All Implemented Interfaces:
AttemptStore
快取儲存實作
使用 AppFuse Cache 儲存失敗次數與鎖定狀態。
適用場景:
- 需要自動過期清理的環境
- 需要統一快取監控的環境
- 未來需要擴充 Redis 支援分散式的環境
優點:
- 支援 TTL/TTI 自動過期,避免記憶體持續增長
- 與其他快取(如 token 黑名單)使用相同技術棧
- 支援統計與監控功能
- 未來可透過 Redis 實作支援分散式部署
執行緒安全性:依賴底層 Cache 實作的執行緒安全性。
- Since:
- 1.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid清除使用者的所有記錄(失敗次數與鎖定狀態)intgetFailureCount(String principal) 取得使用者的失敗次數getLockoutTime(String principal) 取得使用者的鎖定到期時間intincrementFailureCount(String principal) 遞增使用者的失敗次數voidsetLockoutTime(String principal, LocalDateTime unlockTime) 設定使用者的鎖定到期時間
-
Constructor Details
-
CacheAttemptStore
-
-
Method Details
-
getFailureCount
Description copied from interface:AttemptStore取得使用者的失敗次數- Specified by:
getFailureCountin interfaceAttemptStore- Parameters:
principal- 使用者帳號- Returns:
- 失敗次數,若無記錄則回傳 0
-
incrementFailureCount
Description copied from interface:AttemptStore遞增使用者的失敗次數- Specified by:
incrementFailureCountin interfaceAttemptStore- Parameters:
principal- 使用者帳號- Returns:
- 遞增後的失敗次數
-
setLockoutTime
Description copied from interface:AttemptStore設定使用者的鎖定到期時間- Specified by:
setLockoutTimein interfaceAttemptStore- Parameters:
principal- 使用者帳號unlockTime- 鎖定到期時間
-
getLockoutTime
Description copied from interface:AttemptStore取得使用者的鎖定到期時間- Specified by:
getLockoutTimein interfaceAttemptStore- Parameters:
principal- 使用者帳號- Returns:
- 鎖定到期時間,若無記錄則回傳 empty
-
clear
Description copied from interface:AttemptStore清除使用者的所有記錄(失敗次數與鎖定狀態)- Specified by:
clearin interfaceAttemptStore- Parameters:
principal- 使用者帳號
-