Flash 跨域访问安全策略(转)

来源:互联网 发布:网络水军哪里找 编辑:程序博客网 时间:2024/05/17 00:13

转:http://www.ydjps.sc.cn/windson/myblog/article.asp?id=33

        相关学习源文件:点击下载此文件

       了解和认识Flash Player 8 的安全问题,对于程序开始,动画设计和网站管理人员来说都是必要的.目前Flash Player 8 相关的安全API是放在System类下的.

System下的所有方法:

IME

setClipboard

security

exactSettings

showSettings

Product

Capabilities

System.exactSettings

是否是精确域匹配,player 6以前都是超域匹配,player7以后为精确匹配 赋值类型为Boolean,可写属性。

 

System.security

Flash player 8,0,22,0中目前能看见的System.security的方法有:

loadPolicyFile:加载xml策略文件

(策略文件的定义:

<cross-domain-policy>

<allow-access-from domain="*" to-ports="507" /> <allow-access-from domain="*.foo.com" to-ports="507,516" /> <allow-access-from domain="*.bar.com" to-ports="516-523" /> <allow-access-from domain="www.foo.com" to-ports="507,516-523" /> <allow-access-from domain="www.bar.com" to-ports="*" /> </cross-domain-policy>

(备注:如果由

loadPolicyFile()

指定的任何策略文件都未对请求进行授权,则 Flash Player 会查询原始的默认位置 /crossdomain.xml,这是最终的后备操作。)

allowInsecureDomain:允许多个swf文件多种协议交流(http和https)

allowDomain:允许多个swf文件通过http协议跨域交流

Flash player 8,0,22,0中目前隐藏的System.security的方法有:

sandboxType:安全沙盒类型

escapeDomain

chooseLocalSwfPath

System.security.sandboxType的属性值包括:(目前是只读属性)

Remote:swf文件来自远程

localWithFile:swf文件来自本地,能读取本地数据,但不能访问网络

localWithNetwork:swf文件来自本地,能读网络数据,但不能访问本地数据

localTrusted:即能访问网络也能访问本地。

在Flash8调试环境中System.security.sandboxType的值为localTrusted

在本地外部使用播放器打开System.security.sandboxType的值为localWithFile

 

SWF file loading APIs

MovieClip.loadMovie

MovieClip.loadMovieNum

MovieClipLoader.load

安全检测:

1、    如果加载影片的文件安全沙盒为loca-with-filesystem而被加载的文件来自网络或是local-with-networking 安全沙盒,则Loading将加载失败。

地,则Loading将失败。

 

Data loading

LoadVars.load()

LoadVars. sendAndLoad()

XML.load()

XML.sendAndLoad()

安全检测:

如果加载影片的文件安全沙盒为loca-with-filesystem而被加载的文件来自网络或是local-with-networking 安全沙盒,则Loading将加载失败。

许可机制:

Policy File—The default is to deny access between sandboxes. The website can enable access to a resource by adding a policy file.

XMLSocket. connect()

安全检测:

1、  如果文件处于local-with-file安全沙盒则不允许连接

2、  如果访问的端口低于1024则不允许连接

许可机制:

Policy File—The default is to deny access between sandboxes. The website can enable access to a resource by adding a policy file with the XMLSocket protocol. The author can invoke loadPolicyFile(). NetConnection. connect()((AMF Remoting only)

安全检测: 如果文件处于local-with-file安全沙盒则不允许连接

许可机制:

Policy File—The default is to deny access between sandboxes. The website can enable access to a resource by adding a policy file. NetConnection. connect()(Flash Communication Server RTMP only)

安全检测:

如果文件处于local-with-file安全沙盒而被访问的资源再非local安全沙盒则不允许连接

许可机制:

Server-side ActionScript—The default is to allow access. The website can deny access to a resource by adding server-side ActionScript application logic in Flash Communication Server.

NetStream.play() / Sound.load()

安全检测:

如果文件处于local-with-file安全沙盒则不允许连接

许可机制: 1、Policy File—Network sandbox access from local trusted or local-with-networking sandbox requires permission from website

2、Default for other cross-domain requests is to allow access.

FileReference. upload() FileReference. download()

安全检测:

如果调用的文件是不受信任的本地文件则不允许访问

许可机制:

Policy File—The default is to deny access between sandboxes. A website can enable access to a resource by adding a policy file.

 
原创粉丝点击