Class UserStoreManager
-
- All Implemented Interfaces:
public final class UserStoreManager
Represents the local secure store which stores user related information and will be protected by user's passcode.
When using this manager, the most common use case would be: 1, initStore(user, forceReset) to pass the user context, if 'forceReset' is true, the existing store will be deleted and create a new one, this is usually for the 'forget passcode' case; 2, After initializing the user context, open the secure store with 'openStore' functions, either with/without passcode, or with the cipher if fingerprint is enabled on the secure store; 3, After opening, in most cases, the store should keep open until, for example, quit the app, or the app is put into background then re-open it will need the passcode; 4, Internally, 'initStore' with forceReset as true will call 'resetStore'. Be careful when calling 'resetStore' in client code. 5, 'getData' and 'saveData' are used for retrieving data from or saving data into the secure store. For supported data types, please see SecureKeyValueStore
-
-
Field Summary
Fields Modifier and Type Field Description private final SecureKeyValueStore
userStore
private final String
storeAlias
-
Constructor Summary
Constructors Constructor Description UserStoreManager(Context context)
-
Method Summary
Modifier and Type Method Description final SecureKeyValueStore
getUserStore()
final String
getStoreAlias()
final Unit
initStore(DeviceUser user, Boolean forceReset)
Initialize the secure store for a given user without trying to open it. final Unit
openStore()
Opens the user secure store when no passcode or biometric was enabled on the store. final Unit
openStore(CharArray code)
Opens the user secure store with pass code. final Unit
openStore(Cipher cipher)
Opens the user secure store with biometric cipher final Object
enablePasscode(CharArray code, CharArray oldCode)
Enables passcode on the user's secure store, or change passcode if oldCode provided final Unit
closeStore()
Closes the secure store for the given user. final Boolean
resetStore()
Deletes the secure store final Boolean
isStoreOpen()
Is the user store opened or not. final Boolean
verifyPasscode(CharArray code)
Verifies the code, if the code is correct, user store will be opened, otherwise closed. final <T extends Any> Unit
saveData(String key, T value, Boolean notify)
Saves data into user secure store. final <T extends Any> Unit
saveData(String key, T value)
Saves data into user secure store. final <T extends Any> T
getData(String key)
Retrieves data from user secure store. final Unit
clearData(String keys)
Clears the user secure store for the given keys. final Unit
disableBiometric(CharArray code)
Disables the biometric on the secure store. final Unit
enableBiometric(CharArray code, Cipher cipher)
Enables the biometric on the secure store. final Cipher
getCipher()
See 'getCipher' of EncryptionUtil final EncryptionState
getStoreState()
Retrieves the secure store state. final Boolean
upgradeIfNecessary(DeviceUser user, CharArray code)
Upgrades the secure store to version 2. -
-
Method Detail
-
getUserStore
final SecureKeyValueStore getUserStore()
-
getStoreAlias
final String getStoreAlias()
-
initStore
final Unit initStore(DeviceUser user, Boolean forceReset)
Initialize the secure store for a given user without trying to open it. When forceReset is 'true', the original store will be deleted first, it will used in case of user forgets the passcode.
-
openStore
final Unit openStore()
Opens the user secure store when no passcode or biometric was enabled on the store.
-
openStore
final Unit openStore(CharArray code)
Opens the user secure store with pass code.
-
openStore
final Unit openStore(Cipher cipher)
Opens the user secure store with biometric cipher
-
enablePasscode
final Object enablePasscode(CharArray code, CharArray oldCode)
Enables passcode on the user's secure store, or change passcode if oldCode provided
-
closeStore
final Unit closeStore()
Closes the secure store for the given user.
-
resetStore
final Boolean resetStore()
Deletes the secure store
-
isStoreOpen
final Boolean isStoreOpen()
Is the user store opened or not.
-
verifyPasscode
final Boolean verifyPasscode(CharArray code)
Verifies the code, if the code is correct, user store will be opened, otherwise closed.
-
saveData
@JvmOverloads() final <T extends Any> Unit saveData(String key, T value, Boolean notify)
Saves data into user secure store. notify to say when saving OAuth2Token, whether or not sending out the state change.
-
saveData
@JvmOverloads() final <T extends Any> Unit saveData(String key, T value)
Saves data into user secure store. notify to say when saving OAuth2Token, whether or not sending out the state change.
-
clearData
final Unit clearData(String keys)
Clears the user secure store for the given keys.
-
disableBiometric
final Unit disableBiometric(CharArray code)
Disables the biometric on the secure store.
-
enableBiometric
final Unit enableBiometric(CharArray code, Cipher cipher)
Enables the biometric on the secure store.
-
getCipher
final Cipher getCipher()
See 'getCipher' of EncryptionUtil
-
getStoreState
final EncryptionState getStoreState()
Retrieves the secure store state.
-
upgradeIfNecessary
final Boolean upgradeIfNecessary(DeviceUser user, CharArray code)
Upgrades the secure store to version 2.
-
-
-
-