2 Replies Latest reply on Aug 10, 2009 11:02 PM by Anup Jayapal Rao

    Help serving Cross domain policy file with Boa Web Server

    Anup Jayapal Rao

      Hi,

       

      I am a flex newbie. I have prepared an SWF using Flex 3.3 SDK (MPL).

      The SWF is served using the Boa Web Server on port 80. I am able to serve the content and view it locally. The SWF allows communication between the SWF and a locally running server using XMLsocket. This setup works fine as long as I use the python based policy server (available from http://www.adobe.com/devnet/flashplayer/articles/socket_policy_files.html)

       

      However, I would like to serve the cross domain policy file using Boa without using the python based policy server. I have placed the XML file in the root of the served contents. For example I am able to see the contents of the XML file in a browser if  I type the following URL

       

      http://10.x.y.z/crossdomain.xml

       

      The content for the xml in my development setup is as follows:

       

      <?xml version="1.0"?>
      <!DOCTYPE cross-domain-policy SYSTEM "/xml/dtds/cross-domain-policy.dtd">


      <!-- Policy file for xmlsocket://socks.example.com -->
      <cross-domain-policy>


          <!-- This is a master socket policy file -->
          <!-- No other socket policies on the host will be permitted -->
          <site-control permitted-cross-domain-policies="master-only"/>


          <!-- Instead of setting to-ports="*", administrator's can use ranges and com$
          <!-- This will allow access to ports 123, 456, 457 and 458 -->
          <allow-access-from domain="*" to-ports="*" />


      </cross-domain-policy>

       

       

      However, including the line Security.loadPolicyFile("http://10.x.y.z/crossdomain.xml"); in my actionscript does not seem to help.

      I end up seeing the <policy-file-request/> tag on the locally running server.

       

      I am sure, there is something missing in my setup. Kindly help me identify the missing link.

       

      Regards,

      Anup

        • 1. Re: Help serving Cross domain policy file with Boa Web Server
          flex Creek

          String xml = new String(buf,0,len);
                          xml= xml.replaceAll("[\\x00-\\x1f]", " ");
                          xml = "<cmdList><cmds><cmd></cmd></cmds>"+xml+"</cmdList>";
                          if(xml.indexOf("<policy-file-request/>") >=0)
                          {
                              String cXml = "<cross-domain-policy> <allow-access-from domain=\"*\" to-ports=\"*\"/> </cross-domain-policy>";
                              PrintWriter writer=new PrintWriter(socket.getOutputStream(),true);
                              writer.print(cXml + "\0");
                              writer.flush();
                              writer.close();
                              return;
                         }

           

          your flex app will connect server twice. firse policy-file-request. if it pass then connect again. it will be successful

          1 person found this helpful
          • 2. Re: Help serving Cross domain policy file with Boa Web Server
            Anup Jayapal Rao Level 1

            Hi Bing Feng,

             

            Thank you for your reply.

            This solution will work but it is a programmatic solution.

             

            As I mentioned, I am trying to serve the crossdomain.xml policy file via a http web server called Boa.

            I am currently using a C based policy server that I came up with. However, I am looking for the something that will use the web server.

             

            Thanks once again.

             

            Kind regards,

            Anup