`

Flex跨域问题

    博客分类:
  • Flex
阅读更多

From ESRI:

 

 The client browser will then download the SWF file. After this point, the user might not connect back to this Web server at all but rather directly to the servers containing map content and tasks. Note that if your web application is not hosted on the same server as the ArcGIS Server, you will have to have a crossdomain.xml on the ArcGIS Server.

About crossdomain.xml

To access data from a different server than the one hosting your Flex application, the remote server needs to have a cross-domain file in the root directory. For security reasons, the Web browser cannot access data that resides outside the exact Web domain where the SWF file originated. However, Adobe Flash Player can load data across domains if permission is granted from the server. This is accomplished by including a small crossdomain.xml file on the remote server that permits Flash to connect to services on that server. For instance:

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
    <site-control permitted-cross-domain-policies="all"/>
    <allow-access-from domain="*"/>
</cross-domain-policy>

For additional information, read Using cross-domain policy files in the Adobe Flex 3 Help, see the Adobe TechNote "External data not accessible outside a Macromedia Flash movie's domain," or view a sample cross-domain file.

Deploying crossdomain.xml

To deploy the cross-domain file on ArcGIS Server, see the instructions specific to your platform.

  • .NET
    Add crossdomain.xml to your Web server root directory, for example, C:\inetpub\wwwroot.
  • Java
    Add crossdomain.xml to <ArcGIS_Server_Install_Location>\ArcGIS\java\web_output, for example, C:\Program Files\ArcGIS\java\web_output.

 

From Adobe:

 

 http://livedocs.adobe.com/flex/3/html/help.html?content=security2_04.html#139879

Loading assets

<!--googleoff: index--><!-- END PAGE TITLE --><!-- BEGIN CONTENT WRAPPER -->

<!--googleon: index-->

Update 4/30/2008:
NOTE: Flash Player 9.0.124 includes updates that affect the use of crossdomain policy files. For more information, see the Policy file changes in Flash Player 9 article in the Adobe Developer Connection.

The most common task that developers perform that requires an understanding of security is loading external assets.

Data compared to content

The Flash Player security model makes a distinction between loading content and accessing or loading data. Content is defined as media: visual media that Flash Player can display, such as audio, video, or a SWF file that includes displayed media. Data is defined as something that you can manipulate only with ActionScript code.

You can load data in one of two ways: by extracting data from loaded media content, or by directly loading data from an external file (such as an XML file) or socket connection. You can extract data from loaded media by using the BitmapData.draw() method, the Sound.id3 property, or the SoundMixer.computeSpectrum() method. You can load data by using classes such as the SWFLoader, URLStream, URLLoader, Socket, and XMLSocket classes.

The Flash Player security model defines different rules for loading content and accessing data. Loading content has fewer restrictions than accessing data. In general, content such as SWF files, bitmaps, MP3 files, and videos can be loaded from anywhere, but if the content is from a domain other than that of the loading SWF file, it will be partitioned in a separate security sandbox.

Loading remote assets

Loading remote or network assets relies on three factors:

  • Type of asset. If the target asset is a content asset, such as an image file, you do not need any specific permissions from the target domain to load its assets into your Flex application. If the target asset is a data asset, such as an XML file, you must have the target domain's permission to access this asset. For more information on the types of assets, see Data compared to content.
  • Target domain. If you are loading data assets from a different domain, the target domain must provide a crossdomain.xml policy file. This file contains a list of URLs and URL patterns that it allows access from. The calling domain must match one of the URLs or URL patterns in that list. For more information about the crossdomain.xml file, see Using cross-domain policy files. If the target asset is a SWF file, you can also provide permissions by calling the loadPolicyFile() method and loading an alternative policy file inside that target SWF file. For more information, see Using cross-domain policy files.
  • Loading SWF file's sandbox. To load an asset from a network address, you must ensure that your SWF file is in either the remote or local-with-networking sandbox. To ensure that a SWF file can load assets over the network, you must set the use-network compiler option to true when you compile the Flex application. This is the default. If the application was loaded from the local file system with use-network set to false, the application is put in the local-with-filesystem sandbox and it cannot load remote SWF files.

Loading assets from a remote location that you do not control can potentially expose your users to risks. For example, the remote website B contains a SWF file that is loaded by your website A. This SWF file normally displays an advertisement. However, if website B is compromised and its SWF file is replaced with one that asks for a username and password, some users might disclose their login information. To prevent data submission, the loader has a property called allowNetworking with a default value of never.

Using cross-domain policy files

To make data available to SWF files in different domains, use a cross-domain policy file. A cross-domain policy file is an XML file that provides a way for the server to indicate that its data and documents are available to SWF files served from other domains. Any SWF file that is served from a domain that the server's policy file specifies is permitted to access data or assets from that server.

When a Flash document attempts to access data from another domain, Flash Player attempts to load a policy file from that domain. If the domain of the Flash document that is attempting to access the data is included in the policy file, the data is automatically accessible.

The default policy file is named crossdomain.xml and resides at the root directory of the server that is serving the data. The following example policy file permits access to Flash documents that originate from foo.com, friendOfFoo.com, *.foo.com, and 105.216.0.40:

<?xml version="1.0"?>
<!-- http://www.foo.com/crossdomain.xml -->
<cross-domain-policy>
    <allow-access-from domain="www.friendOfFoo.com"/>
    <allow-access-from domain="*.foo.com"/>
    <allow-access-from domain="105.216.0.40"/>
</cross-domain-policy>

You can also configure ports in the crossdomain.xml file. For more information about crossdomain.xml policy files, see Programming ActionScript 3.0.

You can use the loadPolicyFile() method to access a nondefault policy file.

<!--googleoff: index-->
分享到:
评论

相关推荐

    flex跨域访问问题

    flex 跨域访问问题, flex不在同一个域,解决办法

    flex 跨域访问文件

    flex 跨域访问文件,安全沙相问题,很有用的,放在iis里就行了

    flex跨域上传

    flex跨域上传,需nginx,tomcat host: 127.0.0.1 test1.zwh.com 127.0.0.1 test2.zwh.com nginx: client_max_body_size 2048m; server { listen 80; server_name test2.zwh.com; location / { proxy_set_...

    weblogic跨域flex

    提供flex跨域解决的办法 直接在根目录发布这个包就行了

    Flex3.0跨域调用webservice

    eclipse环境下集成flex之后调用webservice的相关资源

    lex for arcgis java tomcat环境不能跨域问题 (安全沙箱问题2048

    flex for arcgis java tomcat环境不能跨域问题 网上找了很多都不能解决我的问题,后来看帮助文档,提供了思路,希望能帮助同样被问题困扰的人。

    Flex3.0跨域调用webservice(part3)

    eclipse和flex集成环境下的

    Flex3.0跨域调用webservice(part2)

    eclipse和flex集成环境下的

    Flex企业应用开发实战源代码

    3.2.5 域及跨域访问 99 3.3 Flex Module 101 3.3.1 创建模块 102 3.3.2 模块的编辑与编译 104 3.3.3 模块文件的加载 104 3.3.4 主应用和模块的交互 107 3.4 Flex库文件SWC 107 3.5 Flex编译模式、链接模式与...

    FLEX企业应用开发实战.part1

     3.2.5 域及跨域访问  3.3 Flex Module  3.3.1 创建模块  3.3.2 模块的编辑与编译  3.3.3 模块文件的加载  3.3.4 主应用和模块的交互  3.4 Flex库文件SWC  3.5 Flex编译模式、链接模式与RSL  3.5.1...

    FLEX企业应用开发实战.part2

     3.2.5 域及跨域访问  3.3 Flex Module  3.3.1 创建模块  3.3.2 模块的编辑与编译  3.3.3 模块文件的加载  3.3.4 主应用和模块的交互  3.4 Flex库文件SWC  3.5 Flex编译模式、链接模式与RSL  3.5.1...

    Flex-Puzzle:仿美图秀秀在线拼图(Flex版)

    Flex-Puzzle 仿美图秀秀在线拼图(Flex版) 1.API接口参见美图秀秀 ...4.跨域问题: loadPhoto的图片地址服务器上需要有crossdomain.xml文件,否则图片只可以显示不可以进行像素级操作(截图,保存等)

    flex3的cookbook书籍完整版dpf(包含目录)

    使用跨域的RSL 22.3节.使用FlexFramework作为RSL 22.4节.优化RSL 22.5节.创建基于MXML的模块 22.6节.创建基于ActionScript的模块 22.7节.使用ModuleLoader载入模块 22.8节.使用ModuleManager载入模块 22.9节.载入...

    最新版vue前端面试题20230321整理

    1. 使⽤用过的koa2中间件 2. koa-body原理理 3. 介绍⾃自⼰己写过的中间件 ...17. 如何解决跨域的问题 18. 常⻅见Http请求头 19. 移动端适配1px的问题 20. 介绍flex布局 21. 其他css⽅方式设置垂直居

    前端工程师面试必备开发知识视频教学合集

    前端面试题 ...08.面试题_flex 元素水平垂直居 中.avi 13.面试题_函数 节流和防抖.avi 09.面试题_css实 现三角形.avi 14.面试题跨域. avi 10.面试题_rem 适配,avi 15.面试题 _nodejs事件轮询 机制.avi

    FlashSec:存储库旨在编译可在渗透测试期间使用的脚本和工具,以评估不同闪存相关场景的安全性

    Crossdomain.mxml:用 FLEX 编写的脚本,利用宽松的跨域 Flash 策略文件向目标网站发出任意请求。 要编译,只需下载 FLEX SDK(可从)并运行mxmlc : $ ./mxmlc Crossdomain.mxml Loading configuration file C:\...

    flash bingogame

    因公司业务需要,临时凑场,搞了一个flash转盘抽奖的程序,没搞过flash,纯粹初级水平,参考了很多其他网友的资料把功能组合了一下,可以正常使用,仅读取奖品图片不可跨域,其他都没什么问题, 压缩包里为完整flash...

    front-end-world

    Flex布局 网格布局 CSS动画 Java脚本 基本语法 基本类型 Javascript对象 原型和继承 作用域 闭包 这 ES6 + 单线程与异步Javascript DOM / BOM API 前端基础知识 浏览器 浏览器DOM事件流/事件委托 浏览器加载顺序 ...

    leetcode怎么查看以前提交的代码-interview:面试

    遇到的问题 3、懒加载怎么实现的(因为第二问说了) 4、vue响应式原理,数组监听,vue3有了解吗,区别 5、es6:箭头函数和普通函数区别?this绑定,判断数组 6、http缓存,cache-control属性 7、项目优化,(nginx配置...

Global site tag (gtag.js) - Google Analytics