Class LocalCachingAuthenticator

java.lang.Object
org.pac4j.core.util.InitializableObject
org.pac4j.core.credentials.authenticator.LocalCachingAuthenticator
All Implemented Interfaces:
Authenticator

public class LocalCachingAuthenticator extends InitializableObject implements 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
  • Constructor Details

    • LocalCachingAuthenticator

      public LocalCachingAuthenticator()

      Constructor for LocalCachingAuthenticator.

    • LocalCachingAuthenticator

      public LocalCachingAuthenticator(Authenticator delegate, Store<Credentials,UserProfile> store)

      Constructor for LocalCachingAuthenticator.

      Parameters:
      delegate - a Authenticator object
      store - a Store object
    • LocalCachingAuthenticator

      public LocalCachingAuthenticator(Authenticator delegate, int cacheSize, int timeout, TimeUnit timeUnit)

      Constructor for LocalCachingAuthenticator.

      Parameters:
      delegate - a Authenticator object
      cacheSize - a int
      timeout - a int
      timeUnit - a TimeUnit object
  • Method Details

    • validate

      public Optional<Credentials> validate(CallContext ctx, Credentials credentials)
      Validate the credentials. It should throw a CredentialsException in case of failure.
      Specified by:
      validate in interface Authenticator
      Parameters:
      ctx - the context
      credentials - the given credentials
      Returns:
      the credentials
    • internalInit

      protected void internalInit(boolean forceReinit)
      Internal initialization of the object.
      Specified by:
      internalInit in class InitializableObject
      Parameters:
      forceReinit - a boolean
    • removeFromCache

      public void removeFromCache(Credentials credentials)

      removeFromCache.

      Parameters:
      credentials - a Credentials object
    • isCached

      public boolean isCached(Credentials credentials)

      isCached.

      Parameters:
      credentials - a Credentials object
      Returns:
      a boolean