Adobe DPS - Library and Store SDK 2.32

Class adobeDPS-EncryptedStorageService

Extends:
adobeDPS-EncryptedStorageService -> adobeDPS-Service -> adobeDPS-Class
Platforms:
iOS

This class defines a service providing encrypted local storage.
Accessible from adobeDPS.encryptedStorageService

Constructor

adobeDPS-EncryptedStorageService()
[inner] Create an instance of the EncryptedStorageService.

Static Fields

Field Defined By
adobeDPS-EncryptedStorageService.instance
The singleton of the EncryptedStorageService.
EncryptedStorageService

Fields

Field Defined By
isOpen : Boolean
This field is true if the encrypted store is open and false if closed.
EncryptedStorageService
This field is true if secure password storage is supported by the device and false otherwise.
EncryptedStorageService
retainPassword : Boolean
This field is true if the password supplied to the service is to be retained in the device secure password store.
EncryptedStorageService
If there is a password retained in the device secure password store then this field will be true; otherwise, the value is false.
EncryptedStorageService
This field is true if the encrypted store is to be closed whenever the Viewer is sent to the background, and false otherwise.
EncryptedStorageService
The signal used to indicate that the encrypted storage state has changed.
EncryptedStorageService
encryptedStorageErrorCodes : EncryptedStorageErrorCodes
The supported error codes as an enumeration object.
EncryptedStorageService

Methods

Method Defined By
setSessionOptions(options:EncryptedStorageOptions, successCB:Function, errorCB:Function)
Set the options for using the encrypted storage service.
EncryptedStorageService
open(password:String, successCB:Function, errorCB:Function)
Open the encrypted store with the specified password.
EncryptedStorageService
changePassword(password:String, successCB:Function, errorCB:Function)
Change the encrypted store password to the specified password, which must be defined, non-null, and non-empty.
EncryptedStorageService
close(successCB:Function, errorCB:Function)
The encrypted store is closed.
EncryptedStorageService
resetService(successCB:Function, errorCB:Function)
Resets the state of EncryptedStorageService to initial conditions.
EncryptedStorageService
setItem(keyArg:String, valueArg:Object, successCB:Function, errorCB:Function)
The specified key is associated with the specified value.
EncryptedStorageService
getItem(keyArg:String, successCB:Function, errorCB:Function)
The decrypted value associated with the specified key is returned to the successCB() function.
EncryptedStorageService
removeItem(keyArg:String, successCB:Function, errorCB:Function)
The specified key and its value are removed from the encrypted store.
EncryptedStorageService
getKeys(successCB:Function, errorCB:Function)
All defined keys are returned to successCB() as an array of strings.
EncryptedStorageService
clear(successCB:Function, errorCB:Function)
The encrypted store is cleared of all data.
EncryptedStorageService
Inherited from adobeDPS-Class
Gets the string representation of this instance.
Class Detail
adobeDPS-EncryptedStorageService()
[inner] Create an instance of the EncryptedStorageService.
This is an internal constructor and shouldn't be called by regular users.
Static Field Details
adobeDPS-EncryptedStorageService.instance
The singleton of the EncryptedStorageService.
Field Details
isOpen : Boolean
This field is true if the encrypted store is open and false if closed. If the encrypted store is closed then no access to its contents is possible.
hasSecurePasswordStorage : Boolean
This field is true if secure password storage is supported by the device and false otherwise. On iOS devices the secure password store is provided by the device KeyChain and this field is always true.
retainPassword : Boolean
This field is true if the password supplied to the service is to be retained in the device secure password store. If this field is false then the password will not be retained and must be supplied each time the store is opened. This attribute is set by calling setSessionOptions().
isPasswordAvailable : Boolean
If there is a password retained in the device secure password store then this field will be true; otherwise, the value is false. The retained password allows the encrypted store to be opened without supplying a password to the service.
closeOnBackgrounding : Boolean
This field is true if the encrypted store is to be closed whenever the Viewer is sent to the background, and false otherwise. The encrypted store is always closed if the Viewer is killed. This attribute is set by calling setSessionOptions().
stateChangedSignal : Signal
The signal used to indicate that the encrypted storage state has changed. The state changes in response to updates to any of the state attributes in EncryptedStorageService. This can be as a result of calling open(), close(), setSessionOptions(), resetService(), setItem(), removeItem(), or clear().

If changePassword() is called with the retainPassword option set, and this results in a password being stored when none was previously, then the signal will fire as a result of isPasswordAvailable changing state; otherwise changePassword does not generate a state change that can be detected by the application.

An application may register a handler for this signal in order to track the state of the store. When the handler is invoked the state attributes of the EncryptedStorageService can be examined to determine what changed. There is currenly no automatic mechanism to determine what changed; the application is responsible for examining the state and determining the change. The signal is fired only after any callbacks from the provoking function are called.

encryptedStorageErrorCodes : EncryptedStorageErrorCodes
The supported error codes as an enumeration object.
Method Details
setSessionOptions(options:EncryptedStorageOptions, successCB:Function, errorCB:Function)
Set the options for using the encrypted storage service. The options argument is an instance of EncryptedStorageOptions and defines all the options to be applied to the service.

If retainPassword in the options argument is true, then the password supplied to the next call to open() or changePassword() will be stored in the native secure password store (the KeyChain in iOS) for subsequent use; if the device does not support secure password storage, then errorCB() will be called with the error STORAGE_NO_SECURE_PASSWORD_STORE. Whenever a encrypted storage password is stored it will overwrite any other encrypted storage password that exists there.

Support for secure password storage can be determined by examining the hasSecurePasswordStorage field in the EncryptedStorageService class.

If retainPassword in the options argument is false, then the password will not be saved to the secure password store, and any password stored there will be removed.

If closeOnBackgrounding in the options argument is true, then the encrypted store will automatically be closed when the Viewer is sent to the background and open() will need to be called again to access its contents; otherwise, no such automatic closing is performed.

If no errors are encountered then successCB() is called with no arguments.

Parameters
options EncryptedStorageOptions The options to use. See adobeDPS-EncryptedStorageOptions
successCB Function The callback function that handles the success of the request.
Callback Signature: successCB()
errorCB Function The callback function that receives the error if the request fails.
Callback Signature: errorCB({code: Number, message: String})
Throws:
Error If the errorCB is invalid
Platforms:
iOS
open(password:String, successCB:Function, errorCB:Function)
Open the encrypted store with the specified password. The password may contain up to 64 characters. If the password is longer than 64 characters then errorCB() is called with the error STORAGE_INVALID_PASSWORD. If the encrypted store is already open then errorCB() will be called with the error STORAGE_NOT_CLOSED.

The password argument may be null or empty. If so, then an attempt to retrieve the password from the native secure password store is made. If the password does not exist there, or secure password storage is not supported, then errorCB() will be called with the error STORAGE_PASSWORD_NOT_AVAILABLE.

If the password obtained in either way does not successfully decrypt the store, then errorCB() will be called with the error STORAGE_DECRYPTION_ERROR.

If this is the first usage of the encrypted store on the device, or if the encrypted store has been reset, then this function will set the initial password. Once the encrypted store is closed, this same password must be supplied either from the password argument of open(), or from the device's secure password store, in order to access the contents of the store. The password may be changed with the changePassword() function.

If the encrypted store is opened without problems then successCB() will be called without any arguments.

The options argument to setSessionOptions() determines the behavior of open() with respect to password retention and application background behavior.

Parameters
password String The password to open the encrypted store.
successCB Function The callback function that handles the success of the request.
Callback Signature: successCB()
errorCB Function The callback function that receives the error if the request fails.
Callback Signature: errorCB({code: Number, message: String})
Throws:
Error If the errorCB is invalid
Platforms:
iOS
changePassword(password:String, successCB:Function, errorCB:Function)
Change the encrypted store password to the specified password, which must be defined, non-null, and non-empty. The password may contain up to 64 characters. If the password is longer than 64 characters then errorCB() is called with the error STORAGE_INVALID_PASSWORD. The store must already be open; if not, then errorCB() is called with the error STORAGE_NOT_OPEN.

If the password is changed without problems then successCB() is called without any arguments.

The options argument to setSessionOptions() determines the behavior of changePassword() with respect to password retention. If the retainPassword field of the options argument is set to true, then the password passed to changePassword() will be saved into the native secure password store; if the value is false, then the password is not retained and will have to specified when calling open().

Parameters
password String The password which will replace the current password.
successCB Function The callback function that handles the success of the request.
Callback Signature: successCB()
errorCB Function The callback function that receives the error if the request fails.
Callback Signature: errorCB({code: Number, message: String})
Throws:
Error If the errorCB is invalid
Platforms:
iOS
close(successCB:Function, errorCB:Function)
The encrypted store is closed. Further attempts to access its contents will result in STORAGE_NOT_OPEN errors. If the store is already closed, then errorCB() will be called with the error STORAGE_NOT_OPEN. If the store is successfully closed then successCB() will be called without any arguments.

The options argument to setSessionOptions() provides the option to close the encrypted store whenever the application is sent to the background. If closeOnBackgrounding in the options argument is true, then the store will automatically be closed whenever the application is sent to the background, and open() will need to be called again to access its contents.

Parameters
successCB Function The callback function that handles the success of the request.
Callback Signature: successCB()
errorCB Function The callback function that receives the error if the request fails.
Callback Signature: errorCB({code: Number, message: String})
Throws:
Error If the errorCB is invalid
Platforms:
iOS
resetService(successCB:Function, errorCB:Function)
Resets the state of EncryptedStorageService to initial conditions. All persistent storage used by EncryptedStorageService, including the contents of the store and any retained password in the native secure password store, is deleted and reset to an empty state.

Calling this method should not normally be needed, but it may be useful during application development, or if storage I/O errors or other external problems affect the stability or integrity of the persistent storage. successCB() is called without any arguments if the service is successfully reset.

EncryptedStorageService itself does not define any error codes for this API entry, but the error callback may be called with OS-specific error codes generated from OS file operations.

Parameters
successCB Function The callback function that handles the success of the request.
Callback Signature: successCB()
errorCB Function The callback function that receives the error if the request fails.
Callback Signature: errorCB({code: Number, message: String})
Throws:
Error If the errorCB is invalid
Platforms:
iOS
setItem(keyArg:String, valueArg:Object, successCB:Function, errorCB:Function)
The specified key is associated with the specified value. This is not an encryption key but serves as an identifier for the value to be stored.

The key must be a regular, printable JavaScript string with a maximum of 64 characters. A null or empty string is not allowed. The following special characters encoded with escape notation are not allowed: \' \" \\ \n \r \v \t \b \f. These are the single quote, double quote, backslash, new line, carriage return, vertical tab, tab, backspace, and form feed characters. If the key does not conform to these rules then errorCB() is called with the error STORAGE_INVALID_KEY. This check is performed before any other operation.

If the key already exists in the store then the new value will overwrite the old value. If the encrypted store is not open, then errorCB() will be called with the error STORAGE_NOT_OPEN.

Unlike the JavaScript localStorage API, the specified value may be any JavaScript object, including null, but it must not be undefined. The object is subjected to JSON serialization before passing it over the bridge to the native side, and is deserialized upon return with getItem(). Note that if the value contains binary data, then that binary data it must be encoded into text in order to be serialized into JSON and pass over the JavaScript bridge successfully.

The size of the value object is computed as the length of the JSON representation of the object in characters. It is limited to 16 million characters (1024*1024*16). If the value is larger than this limit, then errorCB() will be called with the error STORAGE_VALUE_SIZE_EXCEEDED.

If setItem() succeeds, then successCB() is called back with the key used to store the value.

Parameters
keyArg String The key to be associated with the specified value.
valueArg Object The object to be associated with the key.
successCB Function The callback function that handles the success of the request.
Callback Signature: successCB(String key)
errorCB Function The callback function that receives the error if the request fails.
Callback Signature: errorCB({code: Number, message: String})
Throws:
Error If the errorCB is invalid
Platforms:
iOS
getItem(keyArg:String, successCB:Function, errorCB:Function)
The decrypted value associated with the specified key is returned to the successCB() function. The key is subject to the same restrictions as in setItem(). If there is no value associated with the key, or if the key is not found, then null will be returned. If the encrypted store is not open, then errorCB() will be called with the error STORAGE_NOT_OPEN.
Parameters
keyArg String The key associated with the value to be returned.
successCB Function The callback function that handles the success of the request. It will receive the requested value.
Callback Signature: successCB(Object value)
errorCB Function The callback function that receives the error if the request fails.
Callback Signature: errorCB({code: Number, message: String})
Throws:
Error If the errorCB is invalid
Platforms:
iOS
removeItem(keyArg:String, successCB:Function, errorCB:Function)
The specified key and its value are removed from the encrypted store. The key is subject to the same restrictions as in setItem(). If the key does not exist, then this function does nothing. If the encrypted store is not open, then errorCB() will be called with the error STORAGE_NOT_OPEN. If the operation is successful, then successCB() is called back with the key that was removed.
Parameters
keyArg String The key associated with the key/value pair to be removed.
successCB Function The callback function that handles the success of the request.
Callback Signature: successCB(String key)
errorCB Function The callback function that receives the error if the request fails.
Callback Signature: errorCB({code: Number, message: String})
Throws:
Error If the errorCB is invalid
Platforms:
iOS
getKeys(successCB:Function, errorCB:Function)
All defined keys are returned to successCB() as an array of strings. If the encrypted store is not open, then errorCB() will be called with the error STORAGE_NOT_OPEN. If there are no keys in the store then successCB() will be called with null.
Parameters
successCB Function The callback function that handles the success of the request. It receives the array of currently defined keys or null if no keys are defined.
Callback Signature: successCB(Array keys)
errorCB Function The callback function that receives the error if the request fails.
Callback Signature: errorCB({code: Number, message: String})
Throws:
Error If the errorCB is invalid
Platforms:
iOS
clear(successCB:Function, errorCB:Function)
The encrypted store is cleared of all data. If the encrypted store is not open, then errorCB() will be called with the error STORAGE_NOT_OPEN. If the operation is successful, then successCB() is called with an empty argument list.
Parameters
successCB Function The callback function that handles the success of the request.
Callback Signature: successCB()
errorCB Function The callback function that receives the error if the request fails.
Callback Signature: errorCB({code: Number, message: String})
Throws:
Error If the errorCB is invalid
Platforms:
iOS
©2012-2013 Adobe Systems, inc
Documentation generated by JsDoc Toolkit 2.4.0 on Mon Aug 31 2015 09:23:26 GMT-0700 (PDT)