public final class SecureSharedPreferences extends java.lang.Object implements ArmadilloSharedPreferences
DefaultEncryptionProtocol before persisting
the data. It deviates from the expected behaviour in the following way:
| Modifier and Type | Class and Description |
|---|---|
class |
SecureSharedPreferences.Editor
Wrapper for Android's
SharedPreferences.Editor. |
| Constructor and Description |
|---|
SecureSharedPreferences(android.content.Context context,
java.lang.String preferenceName,
at.favre.lib.armadillo.EncryptionProtocol.Factory encryptionProtocol,
char[] password,
boolean supportVerifyPassword) |
SecureSharedPreferences(android.content.Context context,
java.lang.String preferenceName,
at.favre.lib.armadillo.EncryptionProtocol.Factory encryptionProtocol,
RecoveryPolicy recoveryPolicy,
char[] password,
boolean supportVerifyPassword) |
SecureSharedPreferences(android.content.SharedPreferences sharedPreferences,
at.favre.lib.armadillo.EncryptionProtocol.Factory encryptionProtocolFactory,
RecoveryPolicy recoveryPolicy,
char[] password,
boolean supportVerifyPassword) |
| Modifier and Type | Method and Description |
|---|---|
void |
changePassword(char[] newPassword)
Changes the user provided password to the new given password.
|
void |
changePassword(char[] newPassword,
KeyStretchingFunction newKsFunction)
Changes the user provided password to the new given password and sets a new stretching function.
|
void |
close()
Clears most of the internal state and makes the instance unusable.
|
boolean |
contains(java.lang.String key) |
android.content.SharedPreferences.Editor |
edit() |
java.util.Map<java.lang.String,java.lang.String> |
getAll()
This will get all handled keys from the store.
|
boolean |
getBoolean(java.lang.String key,
boolean defaultValue) |
float |
getFloat(java.lang.String key,
float defaultValue) |
int |
getInt(java.lang.String key,
int defaultValue) |
long |
getLong(java.lang.String key,
long defaultValue) |
java.lang.String |
getString(java.lang.String key,
java.lang.String defaultValue) |
java.util.Set<java.lang.String> |
getStringSet(java.lang.String key,
java.util.Set<java.lang.String> defaultValues) |
boolean |
isValidPassword()
Determines whether the user-provided password used to initialises Armadillo is the right one or not.
|
void |
registerOnSharedPreferenceChangeListener(android.content.SharedPreferences.OnSharedPreferenceChangeListener onSharedPreferenceChangeListener) |
void |
unregisterOnSharedPreferenceChangeListener(android.content.SharedPreferences.OnSharedPreferenceChangeListener onSharedPreferenceChangeListener) |
public SecureSharedPreferences(android.content.Context context,
java.lang.String preferenceName,
at.favre.lib.armadillo.EncryptionProtocol.Factory encryptionProtocol,
char[] password,
boolean supportVerifyPassword)
public SecureSharedPreferences(android.content.Context context,
java.lang.String preferenceName,
at.favre.lib.armadillo.EncryptionProtocol.Factory encryptionProtocol,
RecoveryPolicy recoveryPolicy,
char[] password,
boolean supportVerifyPassword)
public SecureSharedPreferences(android.content.SharedPreferences sharedPreferences,
at.favre.lib.armadillo.EncryptionProtocol.Factory encryptionProtocolFactory,
RecoveryPolicy recoveryPolicy,
char[] password,
boolean supportVerifyPassword)
public java.util.Map<java.lang.String,java.lang.String> getAll()
getAll in interface android.content.SharedPreferencespublic java.lang.String getString(java.lang.String key,
java.lang.String defaultValue)
getString in interface android.content.SharedPreferencespublic java.util.Set<java.lang.String> getStringSet(java.lang.String key,
java.util.Set<java.lang.String> defaultValues)
getStringSet in interface android.content.SharedPreferencespublic int getInt(java.lang.String key,
int defaultValue)
getInt in interface android.content.SharedPreferencespublic long getLong(java.lang.String key,
long defaultValue)
getLong in interface android.content.SharedPreferencespublic float getFloat(java.lang.String key,
float defaultValue)
getFloat in interface android.content.SharedPreferencespublic boolean getBoolean(java.lang.String key,
boolean defaultValue)
getBoolean in interface android.content.SharedPreferencespublic boolean contains(java.lang.String key)
contains in interface android.content.SharedPreferencespublic android.content.SharedPreferences.Editor edit()
edit in interface android.content.SharedPreferencespublic void registerOnSharedPreferenceChangeListener(android.content.SharedPreferences.OnSharedPreferenceChangeListener onSharedPreferenceChangeListener)
registerOnSharedPreferenceChangeListener in interface android.content.SharedPreferencespublic void unregisterOnSharedPreferenceChangeListener(android.content.SharedPreferences.OnSharedPreferenceChangeListener onSharedPreferenceChangeListener)
unregisterOnSharedPreferenceChangeListener in interface android.content.SharedPreferencespublic void changePassword(char[] newPassword)
ArmadilloSharedPreferencesThis method can be used to switch from a generated key to a key derived from user-provided password.
A null or zero length password will reset the password (as if no user-provided password is set).
Warning: Depending on the use key stretching function and count of saved data this is a very expensive call, do it in a background thread.
changePassword in interface ArmadilloSharedPreferencesnewPassword - which will be additionally used to create the key for the encryptionpublic boolean isValidPassword()
ArmadilloSharedPreferences
Armadillo.Builder.supportVerifyPassword(boolean) has to be enabled to be able to use
this method.
In order to verify the password, a known value is stored encrypted with the password the first time that Armadillo is initialised. When this method is called, it tries to decrypt this value and compares it to the original value. If the values match the validation succeeds, otherwise, it fails.
Warning: Depending on the use key stretching function this is a very expensive call, do it in a background thread.
isValidPassword in interface ArmadilloSharedPreferencespublic void changePassword(char[] newPassword,
KeyStretchingFunction newKsFunction)
ArmadilloSharedPreferencesThis method can be used to switch from a generated key to a key derived from user-provided password.
A null or zero length password will reset the password (as if no user-provided password is set).
Warning: Depending on the use key stretching function and count of saved data this is a very expensive call, do it in a background thread.
changePassword in interface ArmadilloSharedPreferencesnewPassword - which will be additionally used to create the key for the encryptionnewKsFunction - set a new function to be used the encrypt with new password. It will be
ignored if null is passed.public void close()
ArmadilloSharedPreferencesclose in interface ArmadilloSharedPreferences