在插件上下文(由另一个swf加载的swf)中,是否有任何方式限制对加载的swf在同一时间访问文件系统和网络?安全:限制插件访问文件系统和网络
编译选项“-use-network = true | false”不适合,因为您不能限制文件/网络。
代码例如:
空气应用:
package
{
import flash.display.Loader;
import flash.display.Sprite;
import flash.filesystem.File;
import flash.net.URLRequest;
public class TestContentSecurity extends Sprite
{
private var l :Loader = new Loader;
public function TestContentSecurity()
{
addChild(l);
l.load(new URLRequest(File.documentsDirectory.nativePath + "/Content.swf"));
}
}
}
加载的SWF:
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.system.ApplicationDomain;
import flash.text.TextField;
public class Content extends Sprite
{
private var _log : TextField = new TextField;
private var l: URLLoader;
public function Content()
{
addChild(_log)
_log.multiline = true;
_log.width = 500;
_log.height = 500;
l = new URLLoader();
l.addEventListener(Event.COMPLETE, onLoad);
l.addEventListener(IOErrorEvent.IO_ERROR, onError);
l.load(new URLRequest("c:/Windows/regedit.exe"))
}
public function onLoad(e:Event) : void{
_log.text += "SUCCESS\n" ;
}
public function onError(e:IOErrorEvent) : void{
_log.text += "ERROR\n";
}
}
}
加载的SWF是在用户的文档文件夹中,外部空气的应用程序的文件夹。目前,加载的瑞士法郎能够加载“c:/Windows/regedit.exe”,我不希望它(既不在网络上发送信息)。
这个项目是一个AIR应用程序,但我没有看到任何可以帮助我的东西。我需要禁止网络使用和本地访问。 – 2011-02-14 12:03:03