Commit c1b8e58e authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Moved flash cross domain to the open source version. JM-537

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@9389 b35dd754-fafc-0310-a699-88a17e54d16e
parent 59aef113
......@@ -2370,6 +2370,8 @@ ports.media_proxy.desc=The port used for the proxy service that allows Jingle co
the XMPP network.
ports.stun=STUN Service
ports.stun.desc=The port used for the service that ensures connectivity between entities when behind a NAT.
ports.flash_cross_domain=Flash Cross Domain
ports.flash_cross_domain.desc=Service that allows Flash clients connect to other hostnames and ports.
# Media Proxy
......
......@@ -2226,4 +2226,6 @@ system.clustering.using-embedded-db=Clustering no esta disponible cuando se util
system.clustering.not-installed=No se ha encontrado soporte para clustering en el sistema. Instale Openfire Corporativo para habilitarlo.
system.clustering.not-valid-license=La licencia de Openfire Corporativo no incluye clustering. Necesita actualizar su licencia para habilitar clustering.
system.clustering.starting=Clustering esta arrancando. Puede tardar hasta 30 segundos para completar. Haga clic {0}aqui{1} para refrescar.
setup.ldap.user.vcard.photo=Foto/Avatar
\ No newline at end of file
setup.ldap.user.vcard.photo=Foto/Avatar
ports.flash_cross_domain=Flash Cross Domain
ports.flash_cross_domain.desc=Servicio que permite a clientes Flash connectarse a otros dominios y puertos.
\ No newline at end of file
/**
* $RCSfile: $
* $Revision: $
* $Date: $
*
* Copyright (C) 2007 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.
*/
package org.jivesoftware.openfire;
import org.jivesoftware.openfire.container.BasicModule;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
public class FlashCrossDomainHandler extends BasicModule {
private ServerSocket serverSocket;
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>";
public FlashCrossDomainHandler() {
super("Flash CrossDomain Handler");
}
public void start() {
Thread thread = new Thread(new Runnable() {
public void run() {
try {
startServer();
}
catch (Exception e) {
Log.error(e);
}
}
}, "Flash Cross Domain");
thread.start();
}
public void stop() {
try {
if (serverSocket != null) {
serverSocket.close();
}
}
catch (IOException e) {
Log.error(e);
}
}
public int getPort() {
return serverSocket != null ? serverSocket.getLocalPort() : 0;
}
private void startServer() throws Exception {
try {
// Listen on a specific network interface if it has been set.
String interfaceName = JiveGlobals.getXMLProperty("network.interface");
InetAddress bindInterface = null;
int port = 5229;
if (interfaceName != null) {
if (interfaceName.trim().length() > 0) {
bindInterface = InetAddress.getByName(interfaceName);
}
}
serverSocket = new ServerSocket(port, -1, bindInterface);
Log.debug("Flash cross domain is listening on " + interfaceName + " on port " + port);
}
catch (IOException e) {
Log.error("Could not listen on port: 5229.", e);
return;
}
while (true) {
Socket clientSocket;
try {
clientSocket = serverSocket.accept();
// Validate that we have a license
PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true);
out.println(CROSS_DOMAIN_TEXT +
XMPPServer.getInstance().getConnectionManager().getClientListenerPort() +
CROSS_DOMAIN_END_TEXT);
out.println("\n");
out.flush();
out.close();
}
catch (IOException e) {
if (XMPPServer.getInstance().isShuttingDown()) {
break;
}
Log.error(e);
}
}
}
}
......@@ -515,6 +515,7 @@ public class XMPPServer {
loadModule(IQDiscoInfoHandler.class.getName());
loadModule(IQDiscoItemsHandler.class.getName());
loadModule(UpdateManager.class.getName());
loadModule(FlashCrossDomainHandler.class.getName());
loadModule(InternalComponentManager.class.getName());
// Load this module always last since we don't want to start listening for clients
// before the rest of the modules have been started
......@@ -1377,6 +1378,17 @@ public class XMPPServer {
return (STUNService) modules.get(STUNService.class);
}
/**
* Returns the <code>FlashCrossDomainHandler</code> registered with this server. The
* <code>FlashCrossDomainHandler</code> was registered with the server as a module while starting up
* the server.
*
* @return the <code>FlashCrossDomainHandler</code> registered with this server.
*/
public FlashCrossDomainHandler getFlashCrossDomainHandler() {
return (FlashCrossDomainHandler) modules.get(FlashCrossDomainHandler.class);
}
/**
* Returns the <code>VCardManager</code> registered with this server. The
* <code>VCardManager</code> was registered with the server as a module while starting up
......
......@@ -36,6 +36,7 @@
<%@ page import="java.net.URL" %>
<%@ page import="java.text.DecimalFormat" %>
<%@ page import="java.util.List" %>
<%@ page import="org.jivesoftware.openfire.FlashCrossDomainHandler" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
......@@ -80,6 +81,7 @@
HttpBindManager httpBindManager = HttpBindManager.getInstance();
MediaProxyService mediaProxyService = XMPPServer.getInstance().getMediaProxyService();
STUNService stunService = XMPPServer.getInstance().getSTUNService();
FlashCrossDomainHandler flashCrossDomainHandler = XMPPServer.getInstance().getFlashCrossDomainHandler();
// Search for s2s and external component ports info
for (ServerPort port : XMPPServer.getInstance().getServerInfo().getServerPorts()) {
......@@ -587,6 +589,13 @@
<td><fmt:message key="ports.stun.desc" /></td>
</tr>
<% } %>
<tr>
<td><%= interfaceName == null ? LocaleUtils.getLocalizedString("ports.all_ports") : interfaceName %></td>
<td><%= flashCrossDomainHandler.getPort() %></td>
<td><img src="images/blank.gif" width="1" height="1"></td>
<td><fmt:message key="ports.flash_cross_domain" /></td>
<td><fmt:message key="ports.flash_cross_domain.desc" /></td>
</tr>
</tbody>
</table>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment