Trouble creating a Java policy server for a simple Flash app

Posted by simonwulf on Stack Overflow See other posts from Stack Overflow or by simonwulf
Published on 2010-04-03T00:33:00Z Indexed on 2010/04/03 0:43 UTC
Read the original article Hit count: 409

Filed under:
|
|
|
|

I'm trying to create a simple Flash chat application for educational purposes, but I'm stuck trying to send a policy file from my Java server to the Flash app (after several hours of googling with little luck).

The policy file request reaches the server that sends a harcoded policy xml back to the app, but the Flash app doesn't seem to react to it at all until it gives me a security sandbox error.


I'm loading the policy file using the following code in the client:

Security.loadPolicyFile("xmlsocket://myhostname:" + PORT);

The server recognizes the request as "<policy-file-request/>" and responds by sending the following xml string to the client:

public static final String POLICY_XML =
    "<?xml version=\"1.0\"?>"
  + "<cross-domain-policy>"
  + "<allow-access-from domain=\"*\" to-ports=\"*\" />"
  + "</cross-domain-policy>";

The code used to send it looks like this:

try {
    _dataOut.write(PolicyServer.POLICY_XML + (char)0x00);
    _dataOut.flush();
    System.out.println("Policy sent to client: " + PolicyServer.POLICY_XML);
} catch (Exception e) {
    trace(e);
}

Did I mess something up with the xml or is there something else I might have overlooked?

© Stack Overflow or respective owner

Related posts about java

Related posts about flash