Commit 378bb804 authored by Alex Wenckus's avatar Alex Wenckus Committed by alex

Separate http bind code from admin console

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@6477 b35dd754-fafc-0310-a699-88a17e54d16e
parent fceebc10
This diff is collapsed.
......@@ -3,11 +3,14 @@
<component name="AntConfiguration">
<defaultAnt bundledAnt="true" />
<buildFile url="file://$PROJECT_DIR$/build/build.xml">
<additionalClassPath />
<additionalClassPath>
<entry dir="file://$PROJECT_DIR$/../../jive/apache-ant-1.6.5/lib" />
</additionalClassPath>
<antReference projectDefault="true" />
<customJdkName value="" />
<maximumHeapSize value="128" />
<properties />
<executeOn event="beforeRun" target="wildfire" runConfigurationType="Application" runConfigurationName="Wildfire" />
</buildFile>
</component>
<component name="BuildJarProjectSettings">
......@@ -54,11 +57,14 @@
<option name="ENUM_CONSTANTS_WRAP" value="1" />
</value>
</option>
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
<option name="USE_PER_PROJECT_SETTINGS" value="false" />
</component>
<component name="CompilerConfiguration">
<option name="DEFAULT_COMPILER" value="Javac" />
<option name="DEPLOY_AFTER_MAKE" value="0" />
<excludeFromCompile>
<file url="file://$PROJECT_DIR$/src/plugins/gateway/src/java/org/jivesoftware/wildfire/gateway/web/GatewayDWR.java" />
</excludeFromCompile>
<resourceExtensions>
<entry name=".+\.(properties|xml|html|dtd|tld)" />
<entry name=".+\.(gif|png|jpeg|jpg)" />
......@@ -73,6 +79,7 @@
<entry name="?*.png" />
<entry name="?*.jpeg" />
<entry name="?*.jpg" />
<entry name="*.js" />
</wildcardResourcePatterns>
</component>
<component name="DataSourceManagerImpl" />
......@@ -297,6 +304,7 @@
<modules>
<module fileurl="file://$PROJECT_DIR$/Admin.iml" filepath="$PROJECT_DIR$/Admin.iml" />
<module fileurl="file://$PROJECT_DIR$/Plugins.iml" filepath="$PROJECT_DIR$/Plugins.iml" />
<module fileurl="file://$PROJECT_DIR$/Spank.iml" filepath="$PROJECT_DIR$/Spank.iml" />
<module fileurl="file://$PROJECT_DIR$/Wildfire.iml" filepath="$PROJECT_DIR$/Wildfire.iml" />
</modules>
</component>
......
......@@ -73,6 +73,7 @@
<property name="src.test.java.dir" value="${src.test.dir}/java"/>
<property name="docs.dir" value="${basedir}/documentation"/>
<property name="web.dir" value="${src.dir}/web"/>
<property name="spank.dir" value="${src.dir}/spank"/>
<property name="lib.build.dir" value="${basedir}/build/lib"/>
<property name="lib.build.installer.dir" value="${basedir}/build/installer"/>
<property name="lib.merge.dir" value="${lib.build.dir}/merge"/>
......@@ -593,6 +594,10 @@
<param name="plugin.dest.dir" value="${target.wildfireHome}/plugins"/>
</antcall>
<antcall target="spank">
<param name="plugin.dest.dir" value="${target.wildfireHome}/plugins"/>
</antcall>
<!-- Copy compiled plugins if we need to -->
<if>
<equals arg1="${wildfireHome.no.plugins}" arg2="false"/>
......@@ -648,6 +653,20 @@
</if>
</target>
<target name="spank">
<mkdir dir="${target.wildfireHome}/resources/spank"/>
<copy todir="${target.wildfireHome}/resources/spank">
<!-- All web resources minus jsp's and jspf's - those are precompiled -->
<fileset dir="${spank.dir}">
<patternset refid="web.sources"/>
<exclude name="**/*.jsp"/>
<exclude name="**/*.jspf"/>
<include name="**/*.xml"/>
<include name="**/*.swf"/>
</fileset>
</copy>
</target>
<!-- dist.src =============================================================================== -->
<target name="dist.src" depends="javadoc, -i18n"
description="Creates a source distribution package">
......
/**
* $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.
*/
package org.jivesoftware.util.log.util;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.LogConfigurationException;
import org.jivesoftware.util.Log;
/**
* A LogFactory implementation to override the default commons-logging behavior. All log
* statements are written to the Wildfire logs. Info level logging is sent to debug.
*/
public class CommonsLogFactory extends LogFactory {
private org.apache.commons.logging.Log log;
public CommonsLogFactory() {
log = new org.apache.commons.logging.Log() {
public boolean isDebugEnabled() {
return Log.isDebugEnabled();
}
public boolean isErrorEnabled() {
return Log.isErrorEnabled();
}
public boolean isFatalEnabled() {
return Log.isErrorEnabled();
}
public boolean isInfoEnabled() {
return Log.isInfoEnabled();
}
public boolean isTraceEnabled() {
return Log.isDebugEnabled();
}
public boolean isWarnEnabled() {
return Log.isWarnEnabled();
}
public void trace(Object object) {
// Ignore.
}
public void trace(Object object, Throwable throwable) {
// Ignore.
}
public void debug(Object object) {
Log.debug(object.toString());
}
public void debug(Object object, Throwable throwable) {
Log.debug(object.toString(), throwable);
}
public void info(Object object) {
// Send info log messages to debug because they are generally not useful.
Log.debug(object.toString());
}
public void info(Object object, Throwable throwable) {
// Send info log messages to debug because they are generally not useful.
Log.debug(object.toString(), throwable);
}
public void warn(Object object) {
Log.warn(object.toString());
}
public void warn(Object object, Throwable throwable) {
Log.warn(object.toString(), throwable);
}
public void error(Object object) {
Log.error(object.toString());
}
public void error(Object object, Throwable throwable) {
Log.error(object.toString(), throwable);
}
public void fatal(Object object) {
Log.error(object.toString());
}
public void fatal(Object object, Throwable throwable) {
Log.error(object.toString(), throwable);
}
};
}
public Object getAttribute(String string) {
return null;
}
public String[] getAttributeNames() {
return new String[0];
}
public org.apache.commons.logging.Log getInstance(Class aClass)
throws LogConfigurationException {
return log;
}
public org.apache.commons.logging.Log getInstance(String string)
throws LogConfigurationException
{
return log;
}
public void release() {
}
public void removeAttribute(String string) {
}
public void setAttribute(String string, Object object) {
}
}
/**
* $RCSfile: $
* $Revision: $
* $Date: $
*
* Copyright (C) 2006 Jive Software. All rights reserved.
* This software is the proprietary information of Jive Software. Use is subject to license terms.
*/
package org.jivesoftware.util.log.util;
import org.mortbay.log.Logger;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
/**
* A Logger implementation to override the default Jetty logging behavior. All log statements
* are written to the Wildfire logs. Info level logging is sent to debug.
*/
public class JettyLog implements Logger {
/**
* Only enable Jetty debug logging if it's specifically enabled. Otherwise, Jetty debug logs
* pollute the Wildfire debug log with too much data.
*/
private boolean debugEnabled = JiveGlobals.getBooleanProperty("jetty.debugEnabled");
public boolean isDebugEnabled() {
return debugEnabled && Log.isDebugEnabled();
}
public void setDebugEnabled(boolean b) {
// Do nothing.
}
public void info(String string, Object object, Object object1) {
// Send info log messages to debug because they are generally not useful.
Log.debug(string);
}
public void debug(String string, Throwable throwable) {
Log.debug(string, throwable);
}
public void debug(String string, Object object, Object object1) {
Log.debug(string);
}
public void warn(String string, Object object, Object object1) {
Log.warn(string);
}
public void warn(String string, Throwable throwable) {
Log.warn(string, throwable);
}
public Logger getLogger(String string) {
return new JettyLog();
}
}
......@@ -10,7 +10,7 @@ package org.jivesoftware.wildfire.commands.admin;
import org.jivesoftware.wildfire.commands.AdHocCommand;
import org.jivesoftware.wildfire.commands.SessionData;
import org.jivesoftware.wildfire.HttpServerManager;
import org.jivesoftware.wildfire.http.HttpBindManager;
import org.jivesoftware.wildfire.component.InternalComponentManager;
import org.dom4j.Element;
import org.xmpp.forms.DataForm;
......@@ -48,14 +48,14 @@ public class HttpBindStatus extends AdHocCommand {
field.setVariable("FORM_TYPE");
field.addValue("http://jabber.org/protocol/admin");
HttpServerManager manager = HttpServerManager.getInstance();
HttpBindManager manager = HttpBindManager.getInstance();
boolean isEnabled = manager.isHttpBindEnabled();
field = form.addField();
field.setLabel("Http Bind Enabled");
field.setVariable("httpbindenabled");
field.addValue(String.valueOf(isEnabled));
if(isEnabled) {
if (isEnabled) {
field = form.addField();
field.setLabel("Http Bind Address");
field.setVariable("httpbindaddress");
......@@ -65,6 +65,14 @@ public class HttpBindStatus extends AdHocCommand {
field.setLabel("Http Bind Secure Address");
field.setVariable("httpbindsecureaddress");
field.addValue(manager.getHttpBindSecureAddress());
String jsUrl = manager.getJavaScriptUrl();
if (jsUrl != null) {
field = form.addField();
field.setLabel("Http Bind JavaScript Address");
field.setVariable("javascriptaddress");
field.addValue(jsUrl);
}
}
command.add(form.getElement());
......
/**
* $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.
*/
package org.jivesoftware.wildfire.http;
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 {
@Override
protected void doGet(HttpServletRequest httpServletRequest,
HttpServletResponse response) throws
ServletException, IOException {
StringBuilder builder = new StringBuilder();
builder.append("<?xml version=\"1.0\"?>\n" +
"<!DOCTYPE cross-domain-policy " +
"SYSTEM \"http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd\">" +
"<cross-domain-policy><allow-access-from domain=\"*\" /></cross-domain-policy>");
response.setContentType("text/xml");
response.getOutputStream().write(builder.toString().getBytes());
}
}
......@@ -50,13 +50,13 @@ public class HttpBindServlet extends HttpServlet {
}
}
public HttpBindServlet(HttpSessionManager sessionManager) {
this.sessionManager = sessionManager;
public HttpBindServlet() {
}
@Override public void init(ServletConfig servletConfig) throws ServletException {
super.init(servletConfig);
sessionManager = HttpBindManager.getInstance().getSessionManager();
sessionManager.start();
}
......
/**
* $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.
*/
package org.jivesoftware.wildfire.http;
import org.jivesoftware.util.*;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.zip.GZIPOutputStream;
import java.io.*;
/**
*
*/
public class JavaScriptServlet extends HttpServlet {
// private static String suffix = ""; // Set to "_src" to use source version
private static long expiresOffset = 3600 * 24 * 10; // 10 days util client cache expires
private boolean debug = false;
private boolean disableCompression = false;
private static Cache<String, byte[]> cache = CacheManager.initializeCache(
"Javascript Cache", "javascript", 128 * 1024, expiresOffset);
public void init(ServletConfig config) throws ServletException {
super.init(config);
debug = Boolean.valueOf(config.getInitParameter("debug"));
disableCompression = Boolean.valueOf(config.getInitParameter("disableCompression"));
}
public void service(HttpServletRequest request, HttpServletResponse response) {
boolean compress = false;
if (!disableCompression) {
if (request.getHeader("accept-encoding") != null &&
request.getHeader("accept-encoding").indexOf("gzip") != -1)
{
compress = true;
}
else if (request.getHeader("---------------") != null) {
// norton internet security
compress = true;
}
}
response.setHeader("Content-type", "text/javascript");
response.setHeader("Vary", "Accept-Encoding"); // Handle proxies
if (!debug) {
DateFormat formatter = new SimpleDateFormat("d MMM yyyy HH:mm:ss 'GMT'", Locale.US);
formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
response.setHeader("Expires", formatter.format(new Date(System.currentTimeMillis()
+ expiresOffset)));
response.setHeader("Cache-Control", "max-age=" + expiresOffset);
}
else {
response.setHeader("Expires", "1");
compress = false;
}
OutputStream out = null;
InputStream in = null;
try {
byte[] jsContent;
String cacheKey = String.valueOf(compress);
jsContent = cache.get(cacheKey);
if (debug || jsContent == null) {
jsContent = getJavaScriptContent(compress);
cache.put(cacheKey, jsContent);
}
response.setContentLength(jsContent.length);
if (compress) {
response.setHeader("Content-Encoding", "gzip");
}
// Write the content out
in = new ByteArrayInputStream(jsContent);
out = response.getOutputStream();
// Use a 128K buffer.
byte[] buf = new byte[128*1024];
int len;
while ((len=in.read(buf)) != -1) {
out.write(buf, 0, len);
}
out.flush();
}
catch (IOException e) {
Log.error(e);
}
finally {
try { if (in != null) { in.close(); } } catch (Exception ignored) { /* ignored */ }
try { if (out != null) { out.close(); } } catch (Exception ignored) { /* ignored */ }
}
}
private static byte[] getJavaScriptContent(boolean compress) throws IOException
{
StringWriter writer = new StringWriter();
for(String file : getJavascriptFiles()) {
writer.write(getJavaScriptFile(file));
}
if (compress) {
ByteArrayOutputStream baos = null;
GZIPOutputStream gzos = null;
try {
baos = new ByteArrayOutputStream();
gzos = new GZIPOutputStream(baos);
gzos.write(writer.toString().getBytes());
gzos.finish();
gzos.flush();
gzos.close();
return baos.toByteArray();
}
finally {
try { if (gzos != null) { gzos.close(); } }
catch (Exception ignored) { /* ignored */ }
try { if (baos != null) { baos.close(); } }
catch (Exception ignored) { /* ignored */ }
}
}
else {
return writer.toString().getBytes();
}
}
private static Collection<String> getJavascriptFiles() {
return Arrays.asList("xmlextras.js", "connection.js", "dojo.js",
"flash.js");
}
private static String getJavaScriptFile(String path) {
StringBuilder sb = new StringBuilder();
InputStream in = null;
InputStreamReader isr = null;
BufferedReader br = null;
try {
in = getResourceAsStream(path);
if (in == null) {
Log.error("Unable to find javascript file: '" + path + "' in classpath");
return "";
}
isr = new InputStreamReader(in, "ISO-8859-1");
br = new BufferedReader(isr);
String line;
while ((line = br.readLine()) != null) {
sb.append(line.trim()).append('\n');
}
}
catch (Exception e) {
Log.error("Error loading JavaScript file: '" + path + "'.", e);
}
finally {
try { if (br != null) { br.close(); } } catch (Exception ignored) { /* ignored */ }
try { if (isr != null) { isr.close(); } } catch (Exception ignored) { /* ignored */ }
try { if (in != null) { in.close(); } } catch (Exception ignored) { /* ignored */ }
}
return sb.toString();
}
private static InputStream getResourceAsStream(String resourceName) {
File file = new File(JiveGlobals.getHomeDirectory() + File.separator +
"resources" + File.separator + "spank" + File.separator + "scripts", resourceName);
try {
return new FileInputStream(file);
}
catch (FileNotFoundException e) {
return null;
}
}
}
......@@ -13,8 +13,8 @@ package org.jivesoftware.wildfire.spi;
import org.jivesoftware.util.*;
import org.jivesoftware.wildfire.*;
import org.jivesoftware.wildfire.container.BasicModule;
import org.jivesoftware.wildfire.http.HttpBindManager;
import org.jivesoftware.wildfire.container.BasicModule;
import org.jivesoftware.wildfire.multiplex.MultiplexerPacketDeliverer;
import org.jivesoftware.wildfire.net.*;
......@@ -50,12 +50,10 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
private boolean isStarted = false;
// Used to know if the sockets have been started
private boolean isSocketStarted = false;
private HttpServerManager serverManager;
public ConnectionManagerImpl() {
super("Connection Manager");
ports = new ArrayList<ServerPort>(4);
serverManager = HttpServerManager.getInstance();
}
private void createSocket() {
......@@ -306,7 +304,7 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
}
private void startHTTPBindListeners() {
serverManager.setHttpBindContext(HttpBindManager.getInstance().getServlets());
HttpBindManager.getInstance().start();
}
public void initialize(XMPPServer server) {
......@@ -560,6 +558,7 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
stopComponentListener();
stopConnectionManagerListener();
stopServerListener();
HttpBindManager.getInstance().stop();
SocketSendingTracker.getInstance().shutdown();
CertificateManager.removeListener(this);
serverName = null;
......
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<servlet>
<servlet-name>HttpBindServlet</servlet-name>
<servlet-class>org.jivesoftware.wildfire.http.HttpBindServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>HttpBindServlet</servlet-name>
<url-pattern>/http-bind/</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>JavaScriptServlet</servlet-name>
<servlet-class>org.jivesoftware.wildfire.http.JavaScriptServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>JavaScriptServlet</servlet-name>
<url-pattern>/scripts/</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>FlashCrossDomain</servlet-name>
<servlet-class>org.jivesoftware.wildfire.http.FlashCrossDomainServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>FlashCrossDomain</servlet-name>
<url-pattern>/crossdomain.xml</url-pattern>
</servlet-mapping>
</web-app>
This diff is collapsed.
var Flash = {
installed: false,
callbacks: new Array(),
install: function(callbackName) {
dojo.event.connect(dojo.flash, "loaded", callbackName);
dojo.flash.setSwf({flash6: "/crossdomain_version6.swf",
flash8: "/crossdomain_version8.swf",
visible: false});
},
request: function() {
var self = this;
var _method, _url = null;
var _contentType = "application/x-www-form-urlencoded";
var _headers = new Array();
// responseXML
// status
this.open = function(method, url, async, user, password) {
_method = method;
_url = url;
}
this.send = function(body) {
function callback(response) {
self.responseText = response;
self.responseXML = XmlDocument.create();
self.responseXML.loadXML(response);
if (self.onload) {
self.onload(self);
}
}
dojo.flash.comm.XmlHttp(
_url, Flash.registerCallback(callback), _method, body, _contentType);
}
this.setRequestHeader = function(header, value) {
if (header.toLowerCase() == "Content-Type".toLowerCase()) {
_contentType = value;
return;
}
}
this.getRequestHeader = function() { alert("not supported"); }
this.getResponseHeader = function(a) { alert("not supported"); }
this.getAllResponseHeaders = function() { alert("not supported"); }
this.abort = function() { alert("not supported"); }
this.addEventListener = function(a, b, c) { alert("not supported"); }
this.dispatchEvent = function(e) { alert("not supported"); }
this.openRequest = function(a, b, c, d, e) { this.open(a, b, c, d, e); }
this.overrideMimeType = function(e) { alert("not supported"); }
this.removeEventListener = function(a, b, c) { alert("not supported"); }
},
registerCallback: function(callback) {
// todo: could be improved (look for the first available spot in the callbacks table,
// if necessary, expand it)
var length = this.callbacks.push(selfDeleteCallback);
var callbackID = length - 1;
return "Flash.callbacks[" + callbackID + "]";
function selfDeleteCallback(obj) {
delete Flash.callbacks[callbackID];
setTimeout(function() { callback(obj); }, 0);
return;
}
}
}
\ No newline at end of file
This diff is collapsed.
/*----------------------------------------------------------------------------\
| XML Extras |
|-----------------------------------------------------------------------------|
| Created by Erik Arvidsson |
| (http://webfx.eae.net/contact.html#erik) |
| For WebFX (http://webfx.eae.net/) |
|-----------------------------------------------------------------------------|
| XML and XML HTTP request abstraction. |
|-----------------------------------------------------------------------------|
| Copyright (c) 2001, 2002, 2003, 2006 Erik Arvidsson |
|-----------------------------------------------------------------------------|
| Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| use this file except in compliance with the License. You may obtain a copy |
| of the License at http://www.apache.org/licenses/LICENSE-2.0 |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| License for the specific language governing permissions and limitations |
| under the License. |
|-----------------------------------------------------------------------------|
| 2001-09-27 | Original Version Posted. |
| 2006-05-29 | Changed license to Apache Software License 2.0. |
|-----------------------------------------------------------------------------|
| Created 2001-09-27 | All changes are in the log above. | Updated 2006-05-29 |
\----------------------------------------------------------------------------*/
//<script>
//////////////////
// Helper Stuff //
//////////////////
// used to find the Automation server name
function getDomDocumentPrefix() {
if (getDomDocumentPrefix.prefix)
return getDomDocumentPrefix.prefix;
var prefixes = ["MSXML2", "Microsoft", "MSXML", "MSXML3"];
var o;
for (var i = 0; i < prefixes.length; i++) {
try {
// try to create the objects
o = new ActiveXObject(prefixes[i] + ".DomDocument");
return getDomDocumentPrefix.prefix = prefixes[i];
}
catch (ex) {};
}
throw new Error("Could not find an installed XML parser");
}
function getXmlHttpPrefix() {
if (getXmlHttpPrefix.prefix)
return getXmlHttpPrefix.prefix;
var prefixes = ["MSXML2", "Microsoft", "MSXML", "MSXML3"];
var o;
for (var i = 0; i < prefixes.length; i++) {
try {
// try to create the objects
o = new ActiveXObject(prefixes[i] + ".XmlHttp");
return getXmlHttpPrefix.prefix = prefixes[i];
}
catch (ex) {};
}
throw new Error("Could not find an installed XML parser");
}
//////////////////////////
// Start the Real stuff //
//////////////////////////
// XmlHttp factory
function XmlHttp() {}
XmlHttp.create = function () {
try {
if (window.XMLHttpRequest) {
var req = new XMLHttpRequest();
// some versions of Moz do not support the readyState property
// and the onreadystate event so we patch it!
if (req.readyState == null) {
req.readyState = 1;
req.addEventListener("load", function () {
req.readyState = 4;
if (typeof req.onreadystatechange == "function")
req.onreadystatechange();
}, false);
}
return req;
}
if (window.ActiveXObject) {
return new ActiveXObject(getXmlHttpPrefix() + ".XmlHttp");
}
}
catch (ex) {}
// fell through
throw new Error("Your browser does not support XmlHttp objects");
};
// XmlDocument factory
function XmlDocument() {}
XmlDocument.create = function () {
try {
// DOM2
if (document.implementation && document.implementation.createDocument) {
var doc = document.implementation.createDocument("", "", null);
// some versions of Moz do not support the readyState property
// and the onreadystate event so we patch it!
if (doc.readyState == null) {
doc.readyState = 1;
doc.addEventListener("load", function () {
doc.readyState = 4;
if (typeof doc.onreadystatechange == "function")
doc.onreadystatechange();
}, false);
}
return doc;
}
if (window.ActiveXObject)
return new ActiveXObject(getDomDocumentPrefix() + ".DomDocument");
}
catch (ex) {}
throw new Error("Your browser does not support XmlDocument objects");
};
// Create the loadXML method and xml getter for Mozilla
if (window.DOMParser &&
window.XMLSerializer &&
window.Node && Node.prototype && Node.prototype.__defineGetter__) {
// XMLDocument did not extend the Document interface in some versions
// of Mozilla. Extend both!
//XMLDocument.prototype.loadXML =
Document.prototype.loadXML = function (s) {
// parse the string to a new doc
var doc2 = (new DOMParser()).parseFromString(s, "text/xml");
// remove all initial children
while (this.hasChildNodes())
this.removeChild(this.lastChild);
// insert and import nodes
for (var i = 0; i < doc2.childNodes.length; i++) {
this.appendChild(this.importNode(doc2.childNodes[i], true));
}
};
/*
* xml getter
*
* This serializes the DOM tree to an XML String
*
* Usage: var sXml = oNode.xml
*
*/
// XMLDocument did not extend the Document interface in some versions
// of Mozilla. Extend both!
/*
XMLDocument.prototype.__defineGetter__("xml", function () {
return (new XMLSerializer()).serializeToString(this);
});
*/
Document.prototype.__defineGetter__("xml", function () {
return (new XMLSerializer()).serializeToString(this);
});
}
\ No newline at end of file
......@@ -7,33 +7,23 @@
- This software is published under the terms of the GNU Public License (GPL),
- a copy of which is included in this distribution.
--%>
<%@ page import="org.jivesoftware.wildfire.HttpServerManager" %>
<%@ page import="org.jivesoftware.util.ParamUtils" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="org.jivesoftware.util.Log" %>
<%@ page import="org.jivesoftware.wildfire.http.HttpBindManager" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
<%!
HttpServerManager serverManager = HttpServerManager.getInstance();
HttpBindManager serverManager = HttpBindManager.getInstance();
Map<String, String> handleUpdate(HttpServletRequest request) {
Map<String, String> errorMap = new HashMap<String, String>();
boolean isEnabled = ParamUtils.getBooleanParameter(request, "httpBindEnabled");
if (isEnabled) {
boolean httpPortsDistinct = ParamUtils.getBooleanParameter(request, "httpPortsDistinct",
false);
int requestedPort;
int requestedSecurePort;
if (httpPortsDistinct) {
requestedPort = ParamUtils.getIntParameter(request, "port", -1);
requestedSecurePort = ParamUtils.getIntParameter(request, "securePort", -1);
}
else {
requestedPort = serverManager.getAdminUnsecurePort();
requestedSecurePort = serverManager.getAdminSecurePort();
}
int requestedPort = ParamUtils.getIntParameter(request, "port", -1);
int requestedSecurePort = ParamUtils.getIntParameter(request, "securePort", -1);
try {
serverManager.setHttpBindPorts(requestedPort, requestedSecurePort);
}
......@@ -56,7 +46,6 @@
}
boolean isHttpBindEnabled = serverManager.isHttpBindEnabled();
boolean isHttpBindServerSperate = serverManager.isSeperateHttpBindServerConfigured();
int port = serverManager.getHttpBindUnsecurePort();
int securePort = serverManager.getHttpBindSecurePort();
%>
......@@ -68,12 +57,9 @@
<meta name="pageID" content="http-bind"/>
<script type="text/javascript">
var enabled = <%=isHttpBindEnabled%>;
var distinct = <%=isHttpBindServerSperate%>
var setEnabled = function() {
$("rb03").disabled = !enabled;
$("rb04").disabled = !enabled;
$("port").disabled = !enabled || !distinct;
$("securePort").disabled = !enabled || !distinct;
$("port").disabled = !enabled
$("securePort").disabled = !enabled;
}
window.onload = setTimeout("setEnabled()", 500);
</script>
......@@ -132,42 +118,6 @@
</label>
</td>
</tr>
<tr valign="middle">
<td width="1%">
&nbsp;
</td>
<td width="1%" nowrap>
<input type="radio" name="httpPortsDistinct" value="false" id="rb03"
onclick="distinct = false; setEnabled();"
<%= (!isHttpBindServerSperate ? "checked" : "") %>>
</td>
<td width="98%">
<label for="rb03">
<b>
<fmt:message key="httpbind.settings.label_seperate"/>
</b> -
<fmt:message key="httpbind.settings.label_seperate_info"/>
</label>
</td>
</tr>
<tr valign="middle">
<td width="1%">
&nbsp;
</td>
<td width="1%" nowrap>
<input type="radio" name="httpPortsDistinct" value="true" id="rb04"
onclick="distinct = true; setEnabled();"
<%= (isHttpBindServerSperate ? "checked" : "") %>>
</td>
<td width="98%">
<label for="rb04">
<b>
<fmt:message key="httpbind.settings.label_same"/>
</b> -
<fmt:message key="httpbind.settings.label_same_info"/>
</label>
</td>
</tr>
<tr>
<td width="1%">
&nbsp;
......
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