Through broker.localKeychain.*
services, users can have access to functions related to encryption and strings storage, locally.
PUBLIC METHODS
void broker.localKeychain.save(String key, String valueToSave)
It saves a valueToSave
string, encrypted in the local data storage, in the key key
, specified as argument.
Arguments |
|
key |
String: key where the string will be saved. |
valueToSave |
String: string to be saved. |
Exceptions |
|
LocalKeychainInternalException – Has been an exception in local keychain service, in method save for key key . |
|
LocalKeychainNullKey – Local keychain service error when trying to access a value with a null key in method save. |
|
String broker.localKeychain.get(String key)
It retrieves an encrypted string from the local data storage that has been previously saved.
Arguments |
|
key |
String: key of the string to be retrieved. |
Return |
|
String |
String corresponding to the specified key. |
Exceptions |
|
LocalKeychainKeyNotFound – Local keychain service has not found a value for key key . |
|
LocalKeychainInternalException – Has been an exception in local keychain service, in method save for key key . |
|
Bool broker.localKeychain.hasKey(String key)
It returns true if the key specified in key
exists.
Arguments |
|
key |
String: key to be consulted in the local data storage. |
Return |
|
Bool |
It returns true if the specified key exists. |
void broker.localKeychain.remove(String key)
It deletes the string corresponding to the key key
.
Arguments |
|
key |
String: key of the string to be deleted. |
Exceptionss |
|
LocalKeychainNullKey – Local keychain service error when trying to access a value with a null key in method remove. |
|
LocalKeychainKeyNotFound – Local keychain service has not found a value for key key . |
|
void broker.localKeychain.removeAll()
It deletes all the local encrypted data storage.
Example:
Experience Main {
Decision rule1 action("MainContext.checkIfLoggedUser") label("Check If Its Logged User")
Decision rule2 action("MainContext.deleteUserId") label("Delete User Id")
}
RuleContext MainContext {
Rule deleteUser {
broker.localKeychain.remove("userId")
}
Rule checkIfLoggedUser {
if (broker.localKeychain.hasKey("userId")) {
String idUsuarioLogueado = broker.localKeychain.get("userId")
if (idUsuarioLogueado != null) {
broker.ui.showAlert("Usur is logged in ", "User id: " + idUsuarioLogueado)
} else {
broker.ui.showAlert("Usur is not logged in ", "please, log in")
}
} else {
broker.ui.showAlert("Usur is not logged in ", "please, log in")
}
}
}