Class LocalCachingAuthenticator
java.lang.Object
org.pac4j.core.util.InitializableObject
org.pac4j.core.credentials.authenticator.LocalCachingAuthenticator
- All Implemented Interfaces:
Authenticator
An authenticator that caches the result of an authentication based on the credentials.
Add the
guava
dependency to use this class.- Since:
- 1.8
- Author:
- Misagh Moayyed
-
Field Summary
Fields inherited from interface org.pac4j.core.credentials.authenticator.Authenticator
ALWAYS_VALIDATE, NEVER_VALIDATE
-
Constructor Summary
ConstructorDescriptionConstructor for LocalCachingAuthenticator.LocalCachingAuthenticator
(Authenticator delegate, int cacheSize, int timeout, TimeUnit timeUnit) Constructor for LocalCachingAuthenticator.LocalCachingAuthenticator
(Authenticator delegate, Store<Credentials, UserProfile> store) Constructor for LocalCachingAuthenticator. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
internalInit
(boolean forceReinit) Internal initialization of the object.boolean
isCached
(Credentials credentials) isCached.void
removeFromCache
(Credentials credentials) removeFromCache.validate
(CallContext ctx, Credentials credentials) Validate the credentials.Methods inherited from class org.pac4j.core.util.InitializableObject
afterInternalInit, beforeInternalInit, getNbAttempts, init, init, isInitialized, reinit, shouldInitialize
-
Constructor Details
-
LocalCachingAuthenticator
public LocalCachingAuthenticator()Constructor for LocalCachingAuthenticator.
-
LocalCachingAuthenticator
Constructor for LocalCachingAuthenticator.
- Parameters:
delegate
- aAuthenticator
objectstore
- aStore
object
-
LocalCachingAuthenticator
public LocalCachingAuthenticator(Authenticator delegate, int cacheSize, int timeout, TimeUnit timeUnit) Constructor for LocalCachingAuthenticator.
- Parameters:
delegate
- aAuthenticator
objectcacheSize
- a inttimeout
- a inttimeUnit
- aTimeUnit
object
-
-
Method Details
-
validate
Validate the credentials. It should throw aCredentialsException
in case of failure.- Specified by:
validate
in interfaceAuthenticator
- Parameters:
ctx
- the contextcredentials
- the given credentials- Returns:
- the credentials
-
internalInit
protected void internalInit(boolean forceReinit) Internal initialization of the object.- Specified by:
internalInit
in classInitializableObject
- Parameters:
forceReinit
- a boolean
-
removeFromCache
removeFromCache.
- Parameters:
credentials
- aCredentials
object
-
isCached
isCached.
- Parameters:
credentials
- aCredentials
object- Returns:
- a boolean
-