Package com.esri.arcgisruntime.security
Class SharedPreferencesCredentialPersistence
- java.lang.Object
-
- com.esri.arcgisruntime.security.SharedPreferencesCredentialPersistence
-
- All Implemented Interfaces:
CredentialPersistence
public final class SharedPreferencesCredentialPersistence extends java.lang.Object implements CredentialPersistence
An implementation ofCredentialPersistencethat can be used to persist credentials to internal storage for re-use between application sessions. Credentials are stored in theSharedPreferencesfile and encrypted usingAES256_GCMencryption scheme. In order to use this object for credential persistence you need to set an instance of this class on theAuthenticationManager.CredentialCache.- Since:
- 100.9.0
- See Also:
CredentialPersistence,AuthenticationManager.CredentialCache.setPersistence(CredentialPersistence)
-
-
Constructor Summary
Constructors Constructor Description SharedPreferencesCredentialPersistence(android.content.Context context)Creates an instance of aSharedPreferencesCredentialPersistencebased on SharedPreferences.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(CredentialCacheEntry entry)This method will be called whenever a new Credential is added to theAuthenticationManager.CredentialCache.voidclear()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.voidremove(java.lang.String serverContext)This method will be called whenever a credential is removed from theAuthenticationManager.CredentialCache.voidupdate(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 anOAuthTokenCredentialin the credential cache is updated.
-
-
-
Constructor Detail
-
SharedPreferencesCredentialPersistence
public SharedPreferencesCredentialPersistence(android.content.Context context)
Creates an instance of aSharedPreferencesCredentialPersistencebased on SharedPreferences.- Parameters:
context- the application's context- Throws:
java.lang.IllegalArgumentException- if context is null- Since:
- 100.9.0
-
-
Method Detail
-
add
public void add(CredentialCacheEntry entry)
Description copied from interface:CredentialPersistenceThis 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.- Specified by:
addin interfaceCredentialPersistence- Parameters:
entry- the entry to store
-
clear
public void clear()
Description copied from interface:CredentialPersistenceThis 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.- Specified by:
clearin interfaceCredentialPersistence
-
getCredentials
public java.lang.Iterable<CredentialCacheEntry> getCredentials()
Description copied from interface:CredentialPersistenceReturns 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.- Specified by:
getCredentialsin interfaceCredentialPersistence- Returns:
- a Future with an Iterable object of CredentialCacheEntries.
-
remove
public void remove(java.lang.String serverContext)
Description copied from interface:CredentialPersistenceThis 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.- Specified by:
removein interfaceCredentialPersistence- Parameters:
serverContext- the serverContext that matches the entry to remove.
-
update
public void update(CredentialCacheEntry entry)
Description copied from interface:CredentialPersistenceThis method will be called whenever a credential in the credential cache is updated or completely replaced, for example when the access token of anOAuthTokenCredentialin 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.- Specified by:
updatein interfaceCredentialPersistence- Parameters:
entry- the entry to update
-
-