FlashCrossDomainServlet.java 1.69 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
/**
 * $RCSfile$
 * $Revision: $
 * $Date: $
 *
 * Copyright (C) 2006 Jive Software. All rights reserved.
 *
 * This software is published under the terms of the GNU Public License (GPL),
 * a copy of which is included in this distribution.
 */
11
package org.jivesoftware.openfire.http;
12

13 14
import org.jivesoftware.openfire.XMPPServer;

15 16 17 18 19 20 21 22 23 24 25 26 27 28
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletException;
import java.io.IOException;

/**
 * Serves up the flash cross domain xml file which allows other domains to access http-binding
 * using flash.
 *
 * @author Alexander Wenckus
 */
public class FlashCrossDomainServlet extends HttpServlet {

29 30 31 32 33 34 35
    public static String CROSS_DOMAIN_TEXT = "<?xml version=\"1.0\"?>" +
            "<!DOCTYPE cross-domain-policy SYSTEM \"http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd\">" +
            "<cross-domain-policy>" +
            "<allow-access-from domain=\"*\" to-ports=\"";

    public static String CROSS_DOMAIN_END_TEXT = "\" /></cross-domain-policy>";

36 37 38 39 40
    @Override
    protected void doGet(HttpServletRequest httpServletRequest,
                         HttpServletResponse response) throws
            ServletException, IOException {
        StringBuilder builder = new StringBuilder();
41 42 43 44
        builder.append(CROSS_DOMAIN_TEXT +
                XMPPServer.getInstance().getConnectionManager().getClientListenerPort() +
                CROSS_DOMAIN_END_TEXT);
        builder.append("\n");
45 46 47 48
        response.setContentType("text/xml");
        response.getOutputStream().write(builder.toString().getBytes());
    }
}