【问题标题】:Is it possible to bypass the cross-domain.xml requirement for an Adobe AIR application built with Flex?是否可以绕过使用 Flex 构建的 Adob​​e AIR 应用程序的 cross-domain.xml 要求?
【发布时间】:2010-04-24 06:41:10
【问题描述】:

Adobe AIR 应用程序是否可以连接到不公开 cross-domain.xml 文件的删除 Web 服务?如果是这样,您如何配置 Air 中的安全沙箱以允许这样做?

我尝试了一个套接字连接并收到以下错误:

securityErrorHandler: 
[SecurityErrorEvent 
    type="securityError" 
    bubbles=false 
    cancelable=false 
    eventPhase=2 
    text="Error #2048: Security sandbox violation: app:/MyApp.swf cannot 
            load data from gmail.com:5222." errorID=0
]

【问题讨论】:

    标签: apache-flex flash air cross-domain


    【解决方案1】:

    AIR 应用程序的域策略与浏览器中的 Flash Player 不同。因此,AIR 应用程序通常不需要跨域策略文件。但是,有时 AIR 会抛出可以忽略的 SecurityErrorEvent。这是一个例子:

    <?xml version="1.0" encoding="utf-8"?>
    <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml">
    
      <mx:applicationComplete>
        <![CDATA[
          var s:Socket = new Socket();
          s.addEventListener(ProgressEvent.SOCKET_DATA, function(event:ProgressEvent):void {
            t.text += event.target.readUTFBytes(event.target.bytesAvailable);
          });
          s.addEventListener(Event.CONNECT, function(event:Event):void {
            t.text += "Event.CONNECT\n\n";
            s.writeUTF("GET / HTTP/1.0\n\n");
          });
          s.addEventListener(SecurityErrorEvent.SECURITY_ERROR, function(event:SecurityErrorEvent):void {
            trace('security sandbox error ignored');
          });
          s.connect("www.jamesward.com", 80);
        ]]>
      </mx:applicationComplete>
    
      <mx:TextArea id="t" width="100%" height="100%"/>
    
    </mx:WindowedApplication>
    

    【讨论】:

    • 我本以为这也是正确的,但是,我在尝试连接时收到错误消息。
    • 我已经用更多细节更新了答案。如果这对您不起作用,那么您可以发布一个显示问题的测试用例吗?
    猜你喜欢
    • 1970-01-01
    • 2012-12-09
    • 1970-01-01
    • 1970-01-01
    • 2020-07-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-14
    相关资源
    最近更新 更多