13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

Security<br />

Unless there are administrator restrictions to the user's computer, AIR applications are privileged to write to any<br />

location on the user's hard drive. Developers are advised to use the app-storage:/ path for local storage related to<br />

their application. Files writt<strong>en</strong> to app-storage:/ from an application are put in a standard location:<br />

On Mac OS: the storage directory of an application is //Local Store/ where is<br />

the user's prefer<strong>en</strong>ces folder. This is typically /Users//Library/Prefer<strong>en</strong>ces<br />

On Windows: the storage directory of an application is \\Local Store\ where is<br />

the user's CSIDL_APPDATA Special Folder. This is typically C:\Docum<strong>en</strong>ts and<br />

Settings\\Application Data<br />

On Linux: //Local Store/where is /home//.appdata<br />

If an application is designed to interact with existing files in the user's file system, be sure to read “Best security<br />

practices for developers” on page 1080.<br />

Working securely with untrusted cont<strong>en</strong>t<br />

Adobe AIR 1.0 and later<br />

Cont<strong>en</strong>t not assigned to the application sandbox can provide additional scripting functionality to your application, but<br />

only if it meets the security criteria of the runtime. This topic explains the AIR security contract with non-application<br />

cont<strong>en</strong>t.<br />

Security.allowDomain()<br />

Adobe AIR 1.0 and later<br />

AIR applications restrict scripting access for non-application cont<strong>en</strong>t more string<strong>en</strong>tly than the Flash Player browser<br />

plug-in restricts scripting access for untrusted cont<strong>en</strong>t. For example, in Flash Player in the browser, wh<strong>en</strong> a SWF file<br />

that is assigned to the local-trusted sandbox calls the System.allowDomain() method, scripting access is granted<br />

to any SWF loaded from the specified domain. The analogous approach is not permitted from application cont<strong>en</strong>t<br />

in AIR applications, since it would grant unreasonable access unto the non-application file into the user's file system.<br />

Remote files cannot directly access the application sandbox, regardless of calls to the Security.allowDomain()<br />

method.<br />

Scripting betwe<strong>en</strong> application and non-application cont<strong>en</strong>t<br />

Adobe AIR 1.0 and later<br />

AIR applications that script betwe<strong>en</strong> application and non-application cont<strong>en</strong>t have more complex security<br />

arrangem<strong>en</strong>ts. Files that are not in the application sandbox are only allowed to access the properties and methods of<br />

files in the application sandbox through the use of a sandbox bridge. A sandbox bridge acts as a gateway betwe<strong>en</strong><br />

application cont<strong>en</strong>t and non-application cont<strong>en</strong>t, providing explicit interaction betwe<strong>en</strong> the two files. Wh<strong>en</strong> used<br />

correctly, sandbox bridges provide an extra layer of security, restricting non-application cont<strong>en</strong>t from accessing object<br />

refer<strong>en</strong>ces that are part of application cont<strong>en</strong>t.<br />

The b<strong>en</strong>efit of sandbox bridges is best illustrated through example. Suppose an AIR music store application wants to<br />

provide an API to advertisers who want to create their own SWF files, with which the store application can th<strong>en</strong><br />

communicate. The store wants to provide advertisers with methods to look up artists and CDs from the store, but also<br />

wants to isolate some methods and properties from the third-party SWF file for security reasons.<br />

Last updated 6/6/2012<br />

1079

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!