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 ofCredentialPersistence
that can be used to persist credentials to internal storage for re-use between application sessions. Credentials are stored in theSharedPreferences
file and encrypted usingAES256_GCM
encryption 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 aSharedPreferencesCredentialPersistence
based on SharedPreferences.
-
Method Summary
All Methods Instance Methods Concrete 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.
-
-
-
Constructor Detail
-
SharedPreferencesCredentialPersistence
public SharedPreferencesCredentialPersistence(android.content.Context context)
Creates an instance of aSharedPreferencesCredentialPersistence
based 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:CredentialPersistence
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.- Specified by:
add
in interfaceCredentialPersistence
- Parameters:
entry
- the entry to store
-
clear
public void clear()
Description copied from interface:CredentialPersistence
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.- Specified by:
clear
in interfaceCredentialPersistence
-
getCredentials
public java.lang.Iterable<CredentialCacheEntry> getCredentials()
Description copied from interface:CredentialPersistence
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.- Specified by:
getCredentials
in interfaceCredentialPersistence
- Returns:
- a Future with an Iterable object of CredentialCacheEntries.
-
remove
public void remove(java.lang.String serverContext)
Description copied from interface:CredentialPersistence
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.- Specified by:
remove
in interfaceCredentialPersistence
- Parameters:
serverContext
- the serverContext that matches the entry to remove.
-
update
public void update(CredentialCacheEntry entry)
Description copied from interface:CredentialPersistence
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.- Specified by:
update
in interfaceCredentialPersistence
- Parameters:
entry
- the entry to update
-
-