`

flash mina --策略文件問題詳解

 
阅读更多

首先我們看一下以下這篇文章:

http://www.adobe.com/devnet/flashplayer/articles/socket_policy_files.html

注意以下內容:

Socket policy request process

Flash Player checks for a socket policy file in three places for each IP connection. The checks occur in the following order:

  1. Flash Player first checks port 843 to determine if there is a socket master policy file. If there is no socket master policy file or the socket master policy file has asite-controltag specifying"all", then Flash Player proceeds to the next step. If thesite-controltag has a value of"none", then the process stops and the socket is denied a connection.
  2. If an ActionScriptSecurity.loadPolicyFile()command exists within the SWF file, then the Flash Player runtime checks that location. Flash Player checks the destination of theloadPolicyFile()only after it has checked the master policy file on port 843 for permission to acknowledge other policy files. If the developer has not specified aloadPolicyFile()command, then Flash Player checks the destination port of the connection.
  3. The destination port of the connection is the last check made by Flash Player. This check is only performed if the socket master policy file permits Flash Player to check additional locations. If Flash Player still cannot locate a policy file granting permission, then the socket connection is denied.

What data is sent in the request and response?

The request for a policy file is very simple: Flash Player sends the string<policy-file-request/>followed by aNULLbyte to the port where it is requesting a policy file; no more, no less. Flash developers cannot modify the string that is sent. In return, Flash Player expects to receive the socket policy file as text. Once Flash Player receives the socket policy file, it closes the connection and opens a new connection if the policy file approves the request.

所以我們要做的就是在flash端設置檢索策略文件的位置,此設置應該在socket.connect()之前

Security.loadPolicyFile("xmlsocket://yourpolicyserver:port");

然後在指定端口監聽,並返回策略文件即可

如下(使用apache mina):







分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics