Adobe® Flex® 4 Language Reference
Hide Packages and Classes List |  Packages  |  Classes  |  Index  |  Appendixes
flash.data 
EncryptedLocalStore 
Packageflash.data
Classpublic class EncryptedLocalStore
InheritanceEncryptedLocalStore Inheritance Object

Language Version: ActionScript 3.0
Runtime Versions: AIR 1.0

The EncryptedLocalStore class provides methods for setting and getting objects in the encrypted local data store for an AIR application. A persistent encrypted local store is available for each AIR application installed on a user's computer. This lets you save and retrieve data that is stored on the user's local hard drive in an encrypted format that cannot be deciphered by other applications or users. A separate encrypted local store is used for each AIR application, and each AIR application uses a separate encrypted local store for each user.

You may want to use the encrypted local store to store information that must be secured, such as login credentials for web services.

When testing an application in the AIR Debug Launcher (ADL), the application uses a different encrypted local store than is used by the installed AIR application.

AIR uses DPAPI on Windows®, KeyChain on Mac® OS®, and KeyRing or KWallet on Linux® to associate the encrypted local store to each application and user. The encrypted local store uses AES-CBC 128-bit encryption.

Information in the encrypted local store is available only to AIR application content in the application security sandbox.

Items in the encrypted local store are identified with a string. All items are stored as byte array data.

The encrypted local store may perform more slowly if the stored data exceeds 10MB.

When you uninstall an AIR application, the uninstaller does not delete data stored in the encrypted local store.

Encrypted local store data is put in a subdirectory of the user's application data directory; the subdirectory path is Adobe/AIR/ELS/ followed by the application ID.

View the examples



Public Properties
 PropertyDefined By
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
 Inheritedprototype : Object
[static] A reference to the prototype object of a class or function object.
Object
Public Methods
 MethodDefined By
  
[static] Returns the data for the item with the given name in the encrypted local store.
EncryptedLocalStore
 Inherited
Indicates whether an object has a specified property defined.
Object
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
  
[static] Removes the item with the given name from the encrypted local store.
EncryptedLocalStore
  
[static] Clears the entire encrypted local store, deleting all data.
EncryptedLocalStore
  
AIR-only setItem(name:String, data:ByteArray, stronglyBound:Boolean = false):void
[static] Sets the item with the given name to the provided ByteArray data.
EncryptedLocalStore
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
 Inherited
Returns the string representation of this object, formatted according to locale-specific conventions.
Object
 Inherited
Returns the string representation of the specified object.
Object
 Inherited
Returns the primitive value of the specified object.
Object
Method Detail

AIR-only getItem

()method
public static function getItem(name:String):ByteArray

Language Version: ActionScript 3.0
Runtime Versions: AIR 1.0

Returns the data for the item with the given name in the encrypted local store. If an item does not exist by the specified name, this method returns null.

Parameters

name:String — The name of the item in the encrypted local store.

Returns
ByteArray — The ByteArray data. If there is no data for the provided name, the method returns null.

Throws
ArgumentError — The name value is null or an empty string.

AIR-only removeItem

()method 
public static function removeItem(name:String):void

Language Version: ActionScript 3.0
Runtime Versions: AIR 1.0

Removes the item with the given name from the encrypted local store.

Parameters

name:String — The name of the item in the encrypted local store.


Throws
ArgumentError — The name value is null or an empty string.

AIR-only reset

()method 
public static function reset():void

Language Version: ActionScript 3.0
Runtime Versions: AIR 1.0

Clears the entire encrypted local store, deleting all data.

AIR-only setItem

()method 
public static function setItem(name:String, data:ByteArray, stronglyBound:Boolean = false):void

Language Version: ActionScript 3.0
Runtime Versions: AIR 1.0

Sets the item with the given name to the provided ByteArray data.

Parameters

name:String — The name of the item in the encrypted local store.
 
data:ByteArray — The data.
 
stronglyBound:Boolean (default = false) — If set to true, the stored item is strongly bound to the digital signature and bits of the AIR application (the contents of the application directory), in addition to the application's publisher ID. A subsequent call to getItem() for this item results in a run-time exception if the calling AIR application's bits do not match those of the storing application. If you update your application, it cannot read strongly bound data that was previously written to the encrypted local store.

If the stronglyBound parameter is set to false (the default), only the publisher ID needs to stay the same for the application to read the data. The bits of the application may change (and they need to be signed by the publisher), but they do not need to be the exact same bits as were in application that stored the data.


Throws
ArgumentError — The name value is null or an empty string.

By default, an AIR application cannot read the encrypted local store of another application. The stronglyBound setting provides extra binding (to the data in the application bits) that prevents an attacker application from attempting to read from your application's encrypted local store by trying to hijack your application's publisher ID.

EncryptedLocalStore.1.as

The following code stores a string in the encrypted local store, retrieves it, and then deletes it:
var str:String = "Bob";
var bytes:ByteArray = new ByteArray();
bytes.writeUTFBytes(str);
EncryptedLocalStore.setItem("firstName", bytes);

var storedValue:ByteArray = EncryptedLocalStore.getItem("firstName");
trace(storedValue.readUTFBytes(storedValue.length)); // "Bob"

EncryptedLocalStore.removeItem("firstName");