Interface CredentialPersistence


public interface CredentialPersistence
This interface provides a means of persisting credentials as they are added, changed, or removed from the AuthenticationManager.CredentialCache as well as loading persisted credentials into the credential cache.

Users can use the provided credential persistence implementation or implement a custom credential persistence object by implementing this interface. In either case, the credential persistence object should be set by calling AuthenticationManager.CredentialCache.setPersistence(CredentialPersistence) at application startup.

Implementations of this interface get notified when credentials are added, changed or removed from the credential cache via the corresponding methods add(CredentialCacheEntry), update(CredentialCacheEntry), remove(String), clear().

When a credential persistence object is set on the credential cache, getCredentials() will be called in order to populate the credential cache with persisted credentials.

Since:
100.9.0
See Also:
  • Method Details

    • add

      void add(CredentialCacheEntry entry)
      This method will be called whenever a new Credential is added to the AuthenticationManager.CredentialCache. This will typically occur during an authentication challenge. You must not block this method while persisting the credential to storage, in other words, any file I/O operations should be done asynchronously so that this method can return immediately.
      Parameters:
      entry - the entry to store
      Since:
      100.9.0
    • clear

      void clear()
      This method will be called whenever all credentials are removed at once, such as with a call to AuthenticationManager.CredentialCache.removeAndRevokeAllCredentialsAsync(). You must not block this method while clearing persisted credentials, in other words, any file I/O operations should be done asynchronously so that this method can return immediately.
      Since:
      100.9.0
    • getCredentials

      Iterable<CredentialCacheEntry> getCredentials()
      Returns all persisted credentials.

      This method will be called when the CredentialPersistence implementation is assigned to the Credential Cache with AuthenticationManager.CredentialCache.setPersistence(CredentialPersistence). This method is called on a background thread so any implementation can read credentials from storage on that same thread.

      Returns:
      a Future with an Iterable object of CredentialCacheEntries.
      Since:
      100.9.0
    • remove

      void remove(String serverContext)
      This method will be called whenever a credential is removed from the AuthenticationManager.CredentialCache. You must not block this method while removing the persisted credential, in other words, any file I/O operations should be done asynchronously so that this method can return immediately.
      Parameters:
      serverContext - the serverContext that matches the entry to remove.
      Since:
      100.9.0
    • update

      void update(CredentialCacheEntry entry)
      This method will be called whenever a credential in the credential cache is updated or completely replaced, for example when the access token of an OAuthTokenCredential in the credential cache is updated. You must not block this method while updating the persisted credential, in other words, any file I/O operations should be done asynchronously so that this method can return immediately.
      Parameters:
      entry - the entry to update
      Since:
      100.9.0