Commit 1822a48b authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Added support to use proxy server when checking for updates. JM-752

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@4305 b35dd754-fafc-0310-a699-88a17e54d16e
parent 44e17860
......@@ -1669,6 +1669,16 @@ manage-updates.notif.label_disable_info=Administr\u00e1to\u0159i neobdr\u017e\u0
manage-updates.notif.label_enable=Povoleno
manage-updates.notif.label_enable_info=Administr\u00e1to\u0159i obdr\u017e\u00ed upozorn\u011bn\u00ed, kdy\u017e jsou dostupn\u00e9 nov\u00e9 aktualizace.
manage-updates.proxy.enabled.legend=Connection Method
manage-updates.proxy.label_disable=Direct Connection
manage-updates.proxy.label_disable_info=Use a direct connection to the internet to check for updates.
manage-updates.proxy.label_enable=Proxy Connection
manage-updates.proxy.label_enable_info=Specify a proxy server to check for updates:
manage-updates.proxy.host=Host:
manage-updates.proxy.port=Port:
manage-updates.proxy.valid.host=Please enter a valid host name.
manage-updates.proxy.valid.port=Please enter a port greater than zero.
# Available plugins page
plugin.available.title=Dostupn\u00e9 dopl\u0148ky
plugin.available.info=Dopl\u0148ky p\u0159id\u00e1vaj\u00ed serveru nov\u00e9 funkce. Seznam dopl\u0148k\u016f dostupn\u00fdch \
......
......@@ -1666,6 +1666,16 @@ manage-updates.notif.label_disable_info=Administrators will not receive notifica
manage-updates.notif.label_enable=Enabled
manage-updates.notif.label_enable_info=Administrators will receive notifications when new updates are available.
manage-updates.proxy.enabled.legend=Connection Method
manage-updates.proxy.label_disable=Direct Connection
manage-updates.proxy.label_disable_info=Use a direct connection to the internet to check for updates.
manage-updates.proxy.label_enable=Proxy Connection
manage-updates.proxy.label_enable_info=Specify a proxy server to check for updates:
manage-updates.proxy.host=Host:
manage-updates.proxy.port=Port:
manage-updates.proxy.valid.host=Please enter a valid host name.
manage-updates.proxy.valid.port=Please enter a port greater than zero.
# Available plugins page
plugin.available.title=Available Plugins
plugin.available.info=Plugins add new functionality to the server. The list of plugins available \
......
......@@ -215,6 +215,9 @@
## Added key: 'calendar.today'
## Added key: 'calendar.time_part'
## Added key: 'calendar.time'
##
## 3.0.0
## Added section: 'manage-updates.proxy.*'
# Wildfire
......@@ -1876,6 +1879,16 @@ manage-updates.notif.label_disable_info=Administrators will not receive notifica
manage-updates.notif.label_enable=Enabled
manage-updates.notif.label_enable_info=Administrators will receive notifications when new updates are available.
manage-updates.proxy.enabled.legend=Connection Method
manage-updates.proxy.label_disable=Direct Connection
manage-updates.proxy.label_disable_info=Use a direct connection to the internet to check for updates.
manage-updates.proxy.label_enable=Proxy Connection
manage-updates.proxy.label_enable_info=Specify a proxy server to check for updates:
manage-updates.proxy.host=Host:
manage-updates.proxy.port=Port:
manage-updates.proxy.valid.host=Please enter a valid host name.
manage-updates.proxy.valid.port=Please enter a port greater than zero.
# Available plugins page
plugin.available.title=Available Plugins
plugin.available.info=Plugins add new functionality to the server. The list of plugins available \
......
......@@ -1542,6 +1542,16 @@ manage-updates.notif.label_disable_info=Administradores no recibir\u00e1n notifi
manage-updates.notif.label_enable=Habilitado
manage-updates.notif.label_enable_info=Administradores recibir\u00e1n notificaciones cuando nuevas actualizaciones est\u00e9n disponibles.
manage-updates.proxy.enabled.legend=Método de Conexi\u00f3n
manage-updates.proxy.label_disable=Conexi\u00f3n Directa
manage-updates.proxy.label_disable_info=Verificar actualizaciones utilizando una conexi\u00f3n directa a internet.
manage-updates.proxy.label_enable=Conexi\u00f3n con Proxy
manage-updates.proxy.label_enable_info=Especifique el servidor proxy server para verificar actualizaciones:
manage-updates.proxy.host=Host:
manage-updates.proxy.port=Puerto:
manage-updates.proxy.valid.host=Ingrese un nombre v\u00e1lido del host.
manage-updates.proxy.valid.port=Ingrese un valor de puerto mayor a cero.
# Available plugins page
plugin.available.title=Plugins Disponibles
plugin.available.info=Los plugins agregan nueva funcionalidad al servidor. La lista de plugins disponibles \
......
......@@ -409,6 +409,15 @@ manage-updates.notif.label_disable=D\u00e9sactiv\u00e9
manage-updates.notif.label_disable_info=Les Administrateurs ne recevront pas de notifications lorsque des mises \u00e0 jour sont disponibles.
manage-updates.notif.label_enable=Activ\u00e9
manage-updates.notif.label_enable_info=Les Administrateurs recevront un message de notification lorsqe des mises \u00e0 jour sont disponibles.
manage-updates.proxy.enabled.legend=Connection Method
manage-updates.proxy.label_disable=Direct Connection
manage-updates.proxy.label_disable_info=Use a direct connection to the internet to check for updates.
manage-updates.proxy.label_enable=Proxy Connection
manage-updates.proxy.label_enable_info=Specify a proxy server to check for updates:
manage-updates.proxy.host=Host:
manage-updates.proxy.port=Port:
manage-updates.proxy.valid.host=Please enter a valid host name.
manage-updates.proxy.valid.port=Please enter a port greater than zero.
manage-updates.title=Administration des Mises \u00e0 Jour
muc.create.permission.add_jid=Ajouter un Utilisateur (JID) :
muc.create.permission.add_user=Utilisateur ajout\u00e9 avec succ\u00e8s.
......
......@@ -1669,6 +1669,16 @@ manage-updates.notif.label_disable_info=Administrators will not receive notifica
manage-updates.notif.label_enable=Enabled
manage-updates.notif.label_enable_info=Administrators will receive notifications when new updates are available.
manage-updates.proxy.enabled.legend=Connection Method
manage-updates.proxy.label_disable=Direct Connection
manage-updates.proxy.label_disable_info=Use a direct connection to the internet to check for updates.
manage-updates.proxy.label_enable=Proxy Connection
manage-updates.proxy.label_enable_info=Specify a proxy server to check for updates:
manage-updates.proxy.host=Host:
manage-updates.proxy.port=Port:
manage-updates.proxy.valid.host=Please enter a valid host name.
manage-updates.proxy.valid.port=Please enter a port greater than zero.
# Available plugins page
plugin.available.title=Available Plugins
plugin.available.info=Plugins add new functionality to the server. The list of plugins available \
......
......@@ -1640,6 +1640,16 @@ manage-updates.notif.label_disable_info=Administratorzy nie b\u0119d\u0105 otrzy
manage-updates.notif.label_enable=W\u0142\u0105czone
manage-updates.notif.label_enable_info=Administratorzy b\u0119d\u0105 otrzymywa\u0107 powiadomienia kiedy pojawi\u0105 si\u0119 aktualizacje.
manage-updates.proxy.enabled.legend=Connection Method
manage-updates.proxy.label_disable=Direct Connection
manage-updates.proxy.label_disable_info=Use a direct connection to the internet to check for updates.
manage-updates.proxy.label_enable=Proxy Connection
manage-updates.proxy.label_enable_info=Specify a proxy server to check for updates:
manage-updates.proxy.host=Host:
manage-updates.proxy.port=Port:
manage-updates.proxy.valid.host=Please enter a valid host name.
manage-updates.proxy.valid.port=Please enter a port greater than zero.
# Available plugins page
plugin.available.title=Dost\u0119pne wtyczki
plugin.available.info=Wtyczki rozszerzaj\u0105 funkcjonalno\u015b\u0107 serwera. Poni\u017cej znajduje si\u0119 lista wtyczek dost\u0119pnych do zainstalowania. \
......
......@@ -1670,6 +1670,16 @@ manage-updates.notif.label_disable_info=Os administradores n\u00e3o receber\u00e
manage-updates.notif.label_enable=Ativado
manage-updates.notif.label_enable_info=Os administradores receber\u00e3o notifica\u00e7\u00f5es quando novas atualiza\u00e7\u00f5es estiverem dispon\u00edveis.
manage-updates.proxy.enabled.legend=Connection Method
manage-updates.proxy.label_disable=Direct Connection
manage-updates.proxy.label_disable_info=Use a direct connection to the internet to check for updates.
manage-updates.proxy.label_enable=Proxy Connection
manage-updates.proxy.label_enable_info=Specify a proxy server to check for updates:
manage-updates.proxy.host=Host:
manage-updates.proxy.port=Port:
manage-updates.proxy.valid.host=Please enter a valid host name.
manage-updates.proxy.valid.port=Please enter a port greater than zero.
# Available plugins page
plugin.available.title=Plugins Dispon\u00edveis
plugin.available.info=Os Plugins adicionam novas funcionalidades ao servidor. A lista de plugins dispon\u00edveis \
......
......@@ -1529,6 +1529,16 @@ manage-updates.notif.label_disable_info=\u5f53\u6709\u65b0\u7684\u66f4\u65b0\u4f
manage-updates.notif.label_enable=\u542f\u7528
manage-updates.notif.label_enable_info=\u5f53\u6709\u65b0\u7684\u66f4\u65b0\u4fe1\u606f\u65f6\u7ba1\u7406\u5458\u5c06\u6536\u5230\u66f4\u65b0\u901a\u77e5\u3002
manage-updates.proxy.enabled.legend=Connection Method
manage-updates.proxy.label_disable=Direct Connection
manage-updates.proxy.label_disable_info=Use a direct connection to the internet to check for updates.
manage-updates.proxy.label_enable=Proxy Connection
manage-updates.proxy.label_enable_info=Specify a proxy server to check for updates:
manage-updates.proxy.host=Host:
manage-updates.proxy.port=Port:
manage-updates.proxy.valid.host=Please enter a valid host name.
manage-updates.proxy.valid.port=Please enter a port greater than zero.
# Available plugins page
plugin.available.title=\u6709\u6548\u7684\u63d2\u4ef6
plugin.available.info=\u63d2\u4ef6\u53ef\u4ee5\u7ed9\u670d\u52a1\u5668\u589e\u52a0\u65b0\u7684\u529f\u80fd\u3002\u5df2\u7ecf\u5b89\u88c5\u7684\u63d2\u4ef6\u4f1a\u5728\u4e0b\u8868\u4e2d\u663e\u793a\u3002\u5f53\u63d2\u4ef6\u5df2\u7ecf\u4e0b\u8f7d\u540e\u53ef\u80fd\u9700\u8981\u4e00\u6bb5\u65f6\u95f4\u7528\u4e8e\u5b89\u88c5\u3002\u5f53\u63d2\u4ef6\u5b89\u88c5\u6210\u529f\u540e\u4f1a\u5728\u5217\u8868\u4e2d\u663e\u793a\u3002
......
......@@ -11,6 +11,7 @@
package org.jivesoftware.wildfire.update;
import org.apache.commons.httpclient.HostConfiguration;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.methods.GetMethod;
......@@ -166,6 +167,12 @@ public class UpdateManager extends BasicModule {
String requestXML = getServerUpdateRequest();
// Send the request to the server
HttpClient httpClient = new HttpClient();
// Check if a proxy should be used
if (isUsingProxy()) {
HostConfiguration hc = new HostConfiguration();
hc.setProxy(getProxyHost(), getProxyPort());
httpClient.setHostConfiguration(hc);
}
PostMethod postMethod = new PostMethod(updateServiceURL);
NameValuePair[] data = {
new NameValuePair("type", "update"),
......@@ -184,6 +191,12 @@ public class UpdateManager extends BasicModule {
String requestXML = getAvailablePluginsUpdateRequest();
// Send the request to the server
HttpClient httpClient = new HttpClient();
// Check if a proxy should be used
if (isUsingProxy()) {
HostConfiguration hc = new HostConfiguration();
hc.setProxy(getProxyHost(), getProxyPort());
httpClient.setHostConfiguration(hc);
}
PostMethod postMethod = new PostMethod(updateServiceURL);
NameValuePair[] data = {
new NameValuePair("type", "available"),
......@@ -340,6 +353,65 @@ public class UpdateManager extends BasicModule {
JiveGlobals.setProperty("update.frequency", Integer.toString(checkFrequency));
}
/**
* Returns true if a proxy is being used to connect to jivesoftware.org or false if
* a direct connection should be attempted.
*
* @return true if a proxy is being used to connect to jivesoftware.org.
*/
public boolean isUsingProxy() {
return getProxyHost() != null;
}
/**
* Returns the host of the proxy to use to connect to jivesoftware.org or <tt>null</tt>
* if no proxy is used.
*
* @return the host of the proxy or null if no proxy is used.
*/
public String getProxyHost() {
return JiveGlobals.getProperty("update.proxy.host");
}
/**
* Sets the host of the proxy to use to connect to jivesoftware.org or <tt>null</tt>
* if no proxy is used.
*
* @param host the host of the proxy or null if no proxy is used.
*/
public void setProxyHost(String host) {
if (host == null) {
// Remove the property
JiveGlobals.deleteProperty("update.proxy.host");
}
else {
// Create or update the property
JiveGlobals.setProperty("update.proxy.host", host);
}
}
/**
* Returns the port of the proxy to use to connect to jivesoftware.org or -1 if no
* proxy is being used.
*
* @return the port of the proxy to use to connect to jivesoftware.org or -1 if no
* proxy is being used.
*/
public int getProxyPort() {
return JiveGlobals.getIntProperty("update.proxy.port", -1);
}
/**
* Sets the port of the proxy to use to connect to jivesoftware.org or -1 if no
* proxy is being used.
*
* @param port the port of the proxy to use to connect to jivesoftware.org or -1 if no
* proxy is being used.
*/
public void setProxyPort(int port) {
JiveGlobals.setProperty("update.proxy.port", Integer.toString(port));
}
/**
* Returns the server update or <tt>null</tt> if the server is up to date.
*
......
......@@ -33,6 +33,9 @@
boolean notificationUpdate = request.getParameter("notificationUpdate") != null;
boolean serviceEnabled = ParamUtils.getBooleanParameter(request, "serviceEnabled");
boolean notificationsEnabled = ParamUtils.getBooleanParameter(request, "notificationsEnabled");
boolean proxyEnabled = ParamUtils.getBooleanParameter(request,"proxyEnabled");
String proxyHost = ParamUtils.getParameter(request,"proxyHost");
int proxyPort = ParamUtils.getIntParameter(request,"proxyPort", -1);
boolean updateSucess = false;
UpdateManager updateManager = XMPPServer.getInstance().getUpdateManager();
......@@ -40,16 +43,37 @@
// Update the session kick policy if requested
Map<String, String> errors = new HashMap<String, String>();
if (update) {
// Validate params
if (proxyEnabled) {
if (proxyHost == null || proxyHost.trim().length() == 0) {
errors.put("proxyHost","");
}
if (proxyPort <= 0) {
errors.put("proxyPort","");
}
}
else {
proxyHost = null;
proxyPort = -1;
}
// If no errors, continue:
if (errors.isEmpty()) {
updateManager.setServiceEnabled(serviceEnabled);
updateSucess = true;
updateManager.setNotificationEnabled(notificationsEnabled);
updateManager.setProxyHost(proxyHost);
updateManager.setProxyPort(proxyPort);
updateSucess = true;
}
}
// Set page vars
if (errors.size() == 0) {
serviceEnabled = updateManager.isServiceEnabled();
notificationsEnabled = updateManager.isNotificationEnabled();
proxyEnabled = updateManager.isUsingProxy();
proxyHost = updateManager.getProxyHost();
proxyPort = updateManager.getProxyPort();
}
else {
}
......@@ -61,7 +85,22 @@
<% if (!errors.isEmpty()) { %>
<div class="error">
<div class="jive-error">
<table cellpadding="0" cellspacing="0" border="0">
<tbody>
<tr>
<td class="jive-icon"><img src="images/error-16x16.gif" width="16" height="16" border="0"/></td>
<td class="jive-icon-label">
<% if (errors.get("proxyHost") != null) { %>
<fmt:message key="manage-updates.proxy.valid.host" />
<% } else if (errors.get("proxyPort") != null) { %>
<fmt:message key="manage-updates.proxy.valid.port" />
<% } %>
</td>
</tr>
</tbody>
</table>
</div>
<br>
......@@ -105,32 +144,31 @@ else if (updateSucess) { %>
</tr>
</tbody>
</table>
</fieldset>
<br/><br/>
<fieldset>
<fieldset>
<legend><fmt:message key="manage-updates.notif.enabled.legend"/></legend>
<div>
<table cellpadding="3" cellspacing="0" border="0" width="100%">
<tbody>
<tr valign="middle">
<td width="1%" nowrap>
<input type="radio" name="notificationsEnabled" value="false" id="rb01"
<input type="radio" name="notificationsEnabled" value="false" id="rb03"
<%= (!notificationsEnabled ? "checked" : "") %>>
</td>
<td width="99%">
<label for="rb01">
<label for="rb03">
<b><fmt:message key="manage-updates.notif.label_disable"/></b> - <fmt:message key="manage-updates.notif.label_disable_info"/>
</label>
</td>
</tr>
<tr valign="middle">
<td width="1%" nowrap>
<input type="radio" name="notificationsEnabled" value="true" id="rb02"
<input type="radio" name="notificationsEnabled" value="true" id="rb04"
<%= (notificationsEnabled ? "checked" : "") %>>
</td>
<td width="99%">
<label for="rb02">
<label for="rb04">
<b><fmt:message key="manage-updates.notif.label_enable"/></b> - <fmt:message key="manage-updates.notif.label_enable_info"/>
</label>
</td>
......@@ -139,6 +177,65 @@ else if (updateSucess) { %>
</table>
</div>
</fieldset>
<br/><br/>
<fieldset>
<legend><fmt:message key="manage-updates.proxy.enabled.legend"/></legend>
<div>
<table cellpadding="3" cellspacing="0" border="0" width="100%">
<tbody>
<tr valign="middle">
<td width="1%" nowrap>
<input type="radio" name="proxyEnabled" value="false" id="rb05"
<%= (!proxyEnabled ? "checked" : "") %>>
</td>
<td width="99%">
<label for="rb05">
<b><fmt:message key="manage-updates.proxy.label_disable"/></b> - <fmt:message key="manage-updates.proxy.label_disable_info"/>
</label>
</td>
</tr>
<tr valign="middle">
<td width="1%" nowrap>
<input type="radio" name="proxyEnabled" value="true" id="rb06"
<%= (proxyEnabled ? "checked" : "") %>>
</td>
<td width="99%">
<label for="rb06">
<b><fmt:message key="manage-updates.proxy.label_enable"/></b> - <fmt:message key="manage-updates.proxy.label_enable_info"/>
</label>
</td>
</tr>
<tr valign="top">
<td width="1%" nowrap>
&nbsp;
</td>
<td width="99%">
<table cellpadding="3" cellspacing="0" border="0">
<tr valign="top">
<td width="1%" nowrap align="right" class="c1">
<fmt:message key="manage-updates.proxy.host" />
</td>
<td width="99%">
<input type="text" size="15" maxlength="70" name="proxyHost"
value="<%= ((proxyHost != null) ? proxyHost : "") %>">
</td>
</tr>
<tr valign="top">
<td width="1%" align="right" nowrap class="c1">
<fmt:message key="manage-updates.proxy.port" />
</td>
<td width="99%">
<input type="text" size="10" maxlength="50" name="proxyPort"
value="<%= ((proxyPort > 0) ? proxyPort : "") %>">
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</fieldset>
<br>
<input type="submit" name="update" value="<fmt:message key="global.save_settings" />">
......
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