Interface CredentialPersistence
-
- All Known Implementing Classes:
SharedPreferencesCredentialPersistence
public interface CredentialPersistence
This interface provides a means of persisting credentials as they are added, changed, or removed from theAuthenticationManager.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.Android users can use the provided implementation
SharedPreferencesCredentialPersistence
.- Since:
- 100.9.0
- See Also:
AuthenticationManager.CredentialCache.setPersistence(CredentialPersistence)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
add(CredentialCacheEntry entry)
This method will be called whenever a new Credential is added to theAuthenticationManager.CredentialCache
.void
clear()
This method will be called whenever all credentials are removed at once, such as with a call toAuthenticationManager.CredentialCache.removeAndRevokeAllCredentialsAsync()
.java.lang.Iterable<CredentialCacheEntry>
getCredentials()
Returns all persisted credentials.void
remove(java.lang.String serverContext)
This method will be called whenever a credential is removed from theAuthenticationManager.CredentialCache
.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 anOAuthTokenCredential
in the credential cache is updated.
-
-
-
Method Detail
-
add
void add(CredentialCacheEntry entry)
This method will be called whenever a new Credential is added to theAuthenticationManager.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 toAuthenticationManager.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
java.lang.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(java.lang.String serverContext)
This method will be called whenever a credential is removed from theAuthenticationManager.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 anOAuthTokenCredential
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
-
-