From 29ccfdf5b23da2115f4c8c3aa1fbce50955d8561 Mon Sep 17 00:00:00 2001 From: Alex Tran Date: Sun, 14 Jan 2018 04:24:05 +0700 Subject: [PATCH] IMAPD Configuration on Admin Console --- .../ZaGlobalConfigViewController.js | 36 ++++ .../globalconfig/model/ZaGlobalConfig.js | 22 ++- .../view/GlobalConfigXFormView.js | 115 +++++++++++- .../servers/controller/ZaServerController.js | 170 +++++++++++++++++- .../js/zimbraAdmin/servers/model/ZaServer.js | 28 ++- .../servers/view/ZaServerXFormView.js | 112 +++++++++++- WebRoot/messages/ZaMsg.properties | 15 ++ 7 files changed, 487 insertions(+), 11 deletions(-) mode change 100644 => 100755 WebRoot/js/zimbraAdmin/globalconfig/model/ZaGlobalConfig.js mode change 100644 => 100755 WebRoot/js/zimbraAdmin/globalconfig/view/GlobalConfigXFormView.js mode change 100644 => 100755 WebRoot/js/zimbraAdmin/servers/view/ZaServerXFormView.js mode change 100644 => 100755 WebRoot/messages/ZaMsg.properties diff --git a/WebRoot/js/zimbraAdmin/globalconfig/controller/ZaGlobalConfigViewController.js b/WebRoot/js/zimbraAdmin/globalconfig/controller/ZaGlobalConfigViewController.js index 26fc509b14..035960f789 100644 --- a/WebRoot/js/zimbraAdmin/globalconfig/controller/ZaGlobalConfigViewController.js +++ b/WebRoot/js/zimbraAdmin/globalconfig/controller/ZaGlobalConfigViewController.js @@ -377,6 +377,42 @@ function () { mods[ZaGlobalConfig.A_zimbraMtaBlockedExtension] = ""; } } + + //Check validation of reverse proxy upstream imap server: host name or IP address format + var invalidValues = []; + var isValidValue = true; + if(ZaItem.hasWritePermission(ZaGlobalConfig.A_zimbraReverseProxyUpstreamImapServers,tmpObj)) { + if (!AjxUtil.isEmpty(tmpObj.attrs[ZaGlobalConfig.A_zimbraReverseProxyUpstreamImapServers])) { + var proxies = tmpObj.attrs[ZaGlobalConfig.A_zimbraReverseProxyUpstreamImapServers]; + + if(proxies.length == 1 && proxies[0] == "") { + this.runValidationStack(params); + return; + } + + for(var i = 0; i < proxies.length; i++) { + if(!ZaServerController.isValidHostName(proxies[i])) { + isValidValue = false; + } + if(!isValidValue) { + try { + var exIPData = ZaIPUtil.isValidIP(proxies[i]); + isValidValue = true; + } catch (ex) { + isValidValue = false; + } + } + if(!isValidValue) { + invalidValues.push(proxies[i]); + } + } + } + + if(invalidValues.length > 0) { + throw new AjxException(AjxMessageFormat.format(ZaMsg.ERROR_INVALID_IP_OR_HOSTNAME,invalidValues.join(",")),AjxException.INVALID_PARAM,"ZaServerController.prototype.validateReverseProxyUpstreamImapServers"); + } + } + //save the model if (this._currentObject[ZaModel.currentTab]!= tmpObj[ZaModel.currentTab]) this._currentObject[ZaModel.currentTab] = tmpObj[ZaModel.currentTab]; diff --git a/WebRoot/js/zimbraAdmin/globalconfig/model/ZaGlobalConfig.js b/WebRoot/js/zimbraAdmin/globalconfig/model/ZaGlobalConfig.js old mode 100644 new mode 100755 index 3b7817811a..0a517a4cda --- a/WebRoot/js/zimbraAdmin/globalconfig/model/ZaGlobalConfig.js +++ b/WebRoot/js/zimbraAdmin/globalconfig/model/ZaGlobalConfig.js @@ -229,6 +229,13 @@ ZaGlobalConfig.A2_retentionPoliciesPurge_Selection = "retentionPoliciesPurge_Sel ZaGlobalConfig.A_zimbraHelpAdminURL = "zimbraHelpAdminURL"; ZaGlobalConfig.A_zimbraHelpDelegatedURL = "zimbraHelpDelegatedURL"; +//IMAPD +ZaGlobalConfig.A_zimbraRemoteImapServerEnabled = "zimbraRemoteImapServerEnabled"; +ZaGlobalConfig.A_zimbraRemoteImapSSLServerEnabled = "zimbraRemoteImapSSLServerEnabled"; +ZaGlobalConfig.A_zimbraReverseProxyUpstreamImapServers = "zimbraReverseProxyUpstreamImapServers"; +ZaGlobalConfig.A_zimbraRemoteImapBindPort = "zimbraRemoteImapBindPort"; +ZaGlobalConfig.A_zimbraRemoteImapSSLBindPort = "zimbraRemoteImapSSLBindPort"; + ZaGlobalConfig.__configInstance = null; ZaGlobalConfig.isDirty = true; @@ -297,6 +304,11 @@ ZaGlobalConfig.prototype.initFromJS = function(obj) { if(AjxUtil.isString(this.attrs[ZaGlobalConfig.A_zimbraWebClientLogoutURLAllowedIP])) { this.attrs[ZaGlobalConfig.A_zimbraWebClientLogoutURLAllowedIP] = [this.attrs[ZaGlobalConfig.A_zimbraWebClientLogoutURLAllowedIP]]; } + + if(AjxUtil.isString(this.attrs[ZaGlobalConfig.A_zimbraReverseProxyUpstreamImapServers])) { + this.attrs[ZaGlobalConfig.A_zimbraReverseProxyUpstreamImapServers] = [this.attrs[ZaGlobalConfig.A_zimbraReverseProxyUpstreamImapServers]]; + } + // convert available components to hidden fields for xform binding var components = this.attrs[ZaGlobalConfig.A_zimbraComponentAvailable]; if (components) { @@ -635,7 +647,13 @@ ZaGlobalConfig.myXModel = { {id:ZaGlobalConfig.A2_retentionPoliciesKeep, type:_LIST_}, {id:ZaGlobalConfig.A2_retentionPoliciesPurge, type:_LIST_}, {id:ZaGlobalConfig.A2_retentionPoliciesKeep_Selection, type:_LIST_}, - {id:ZaGlobalConfig.A2_retentionPoliciesPurge_Selection, type:_LIST_} - + {id:ZaGlobalConfig.A2_retentionPoliciesPurge_Selection, type:_LIST_}, + + //IMAPD + { id:ZaGlobalConfig.A_zimbraRemoteImapServerEnabled, ref:"attrs/" + ZaGlobalConfig.A_zimbraRemoteImapServerEnabled, type:_ENUM_, choices:ZaModel.BOOLEAN_CHOICES}, + { id:ZaGlobalConfig.A_zimbraRemoteImapSSLServerEnabled, ref:"attrs/" + ZaGlobalConfig.A_zimbraRemoteImapSSLServerEnabled, type:_ENUM_, choices:ZaModel.BOOLEAN_CHOICES}, + { id:ZaGlobalConfig.A_zimbraReverseProxyUpstreamImapServers, ref:"attrs/" + ZaGlobalConfig.A_zimbraReverseProxyUpstreamImapServers, type:_LIST_, listItem:{ type:_STRING_, maxLength: 256} }, + { id:ZaGlobalConfig.A_zimbraRemoteImapBindPort, ref:"attrs/" + ZaGlobalConfig.A_zimbraRemoteImapBindPort, type:_PORT_ }, + { id:ZaGlobalConfig.A_zimbraRemoteImapSSLBindPort, ref:"attrs/" + ZaGlobalConfig.A_zimbraRemoteImapSSLBindPort, type:_PORT_ } ] } diff --git a/WebRoot/js/zimbraAdmin/globalconfig/view/GlobalConfigXFormView.js b/WebRoot/js/zimbraAdmin/globalconfig/view/GlobalConfigXFormView.js old mode 100644 new mode 100755 index f1bdd41f26..ea6b5ff2ae --- a/WebRoot/js/zimbraAdmin/globalconfig/view/GlobalConfigXFormView.js +++ b/WebRoot/js/zimbraAdmin/globalconfig/view/GlobalConfigXFormView.js @@ -105,6 +105,31 @@ GlobalConfigXFormView.shouldEnableAddAllButton = function() { return (!AjxUtil.isEmpty(this.getInstanceValue(ZaGlobalConfig.A_zimbraMtaCommonBlockedExtension))); } +GlobalConfigXFormView.getRemoteIMAPEnabled = function () { + var value = this.getModel().getInstanceValue(this.getInstance(),ZaGlobalConfig.A_zimbraRemoteImapServerEnabled); + return value == 'TRUE'; +} + +GlobalConfigXFormView.getRemoteIMAPSSLEnabled = function () { + var value = this.getModel().getInstanceValue(this.getInstance(),ZaGlobalConfig.A_zimbraRemoteImapSSLServerEnabled); + return (value == 'TRUE' && GlobalConfigXFormView.getRemoteIMAPEnabled.call(this)); +} + +GlobalConfigXFormView.isImapdInstalledInAnyServer = function() { + var isImapdInstalled = false; + + var servers = ZaServer.getAll().getArray(); + for (var i = 0; i < servers.length; i++) { + var s = servers[i]; + if (s.attrs[ZaServer.A_zimbraImapdServiceInstalled]) { + isImapdInstalled = true; + break; + } + } + + return isImapdInstalled; +} + GlobalConfigXFormView.removeExt = function() { var blockedExtArray = this.getInstanceValue(ZaGlobalConfig.A_zimbraMtaBlockedExtension); var selectedExtArray = this.getInstanceValue(ZaGlobalConfig.A2_blocked_extension_selection); @@ -385,6 +410,11 @@ GlobalConfigXFormView.AUTO_PROV_TAB_ATTRS = [ ZaGlobalConfig.A_zimbraAutoProvNot ZaGlobalConfig.A_zimbraAutoProvNotificationSubject ]; GlobalConfigXFormView.AUTO_PROV_TAB_RIGHTS = []; +GlobalConfigXFormView.IMAPD_TAB_ATTRS = [ ZaGlobalConfig.A_zimbraRemoteImapServerEnabled, + ZaGlobalConfig.A_zimbraRemoteImapSSLServerEnabled, ZaGlobalConfig.A_zimbraReverseProxyUpstreamImapServers, + ZaGlobalConfig.A_zimbraRemoteImapBindPort, ZaGlobalConfig.A_zimbraRemoteImapSSLBindPort]; +GlobalConfigXFormView.IMAPD_TAB_RIGHTS = []; + GlobalConfigXFormView.RETENTION_POLICY_TAB_ATTRS = []; GlobalConfigXFormView.RETENTION_POLICY_TAB_RIGHTS = []; @@ -436,7 +466,7 @@ GlobalConfigXFormView.myXFormModifier = function(xFormObject, entry) { "auto", null, null, true, true); xFormObject.tableCssStyle = "width:100%;overflow:auto;"; - var _tab1, _tab2, _tab3, _tab4, _tab5, _tab6, _tab7, _tab8, _tab9, _tab10, _tab11; + var _tab1, _tab2, _tab3, _tab4, _tab5, _tab6, _tab7, _tab8, _tab9, _tab10, _tab11, _tab12; var tabBarChoices = []; var switchItems = []; @@ -1115,6 +1145,89 @@ GlobalConfigXFormView.myXFormModifier = function(xFormObject, entry) { switchItems.push(case4); } + if (GlobalConfigXFormView.isImapdInstalledInAnyServer()){ + if (ZaTabView.isTAB_ENABLED(entry, GlobalConfigXFormView.IMAPD_TAB_ATTRS, GlobalConfigXFormView.IMAPD_TAB_RIGHTS)) { + _tab12 = ++this.TAB_INDEX; + //this.helpMap[_tab12] = [ location.pathname, ZaUtil.HELP_URL, + // "managing_global_settings/.htm", "?locid=", AjxEnv.DEFAULT_LOCALE ].join(""); + tabBarChoices.push({ + value : _tab12, + label : ZaMsg.NAD_Tab_IMAPD + }); + var case12 = { + type : _ZATABCASE_, + caseKey : _tab12, + paddingStyle : "padding-left:15px;", + width : "98%", + cellpadding : 2, + colSizes : [ "auto" ], + numCols : 1, + id : "global_remote_imap_tab", + items : [{ + type : _DWT_ALERT_, + containerCssStyle : "padding-bottom:0px", + style : DwtAlert.WARNING, + iconVisible : true, + content : ZaMsg.Alert_ServerRestart + }, { + type : _ZA_TOP_GROUPER_, + label : ZaMsg.Global_IMAPD_ServiceGrp, + items : [{ + ref : ZaGlobalConfig.A_zimbraReverseProxyUpstreamImapServers, + type : _REPEAT_, + label : ZaMsg.Reverse_Proxy_Upstream_Imap, + labelLocation : _LEFT_, + align : _LEFT_, + repeatInstance : "", + showAddButton : true, + showRemoveButton : true, + showAddOnNextRow : true, + addButtonLabel : ZaMsg.Add_zimbraReverseProxyUpstreamImapServers, + removeButtonLabel : ZaMsg.Remove_zimbraReverseProxyUpstreamImapServers, + removeButtonCSSStyle : "margin-left: 50px", + visibilityChecks : [ ZaItem.hasReadPermission ], + items : [ { + ref : ".", + type : _TEXTFIELD_, + label : null, + labelLocation : _NONE_, + width : 200, + toolTipContent : ZaMsg.tt_zimbraReverseProxyUpstreamImapServers, + visibilityChecks : [ ZaItem.hasReadPermission ] + } ] + }, { + ref : ZaGlobalConfig.A_zimbraRemoteImapServerEnabled, + type : _CHECKBOX_, + label : ZaMsg.Remote_IMAP_Server, + trueValue : "TRUE", + falseValue : "FALSE" + }, { + ref : ZaGlobalConfig.A_zimbraRemoteImapSSLServerEnabled, + type : _CHECKBOX_, + label : ZaMsg.Remote_IMAP_SSLServer, + trueValue : "TRUE", + falseValue : "FALSE" + }] + }, { + type:_ZA_TOP_GROUPER_, + label:ZaMsg.Global_IMAPD_NetworkGrp, + items: [{ + ref: ZaGlobalConfig.A_zimbraRemoteImapBindPort, type: _TEXTFIELD_, + enableDisableChecks:[GlobalConfigXFormView.getRemoteIMAPEnabled,ZaItem.hasReadPermission], + enableDisableChangeEventSources:[ZaGlobalConfig.A_zimbraRemoteImapServerEnabled], + label: ZaMsg.Remote_IMAP_Bind_Port, width: "5em" + }, { + ref: ZaGlobalConfig.A_zimbraRemoteImapSSLBindPort, type: _TEXTFIELD_, + enableDisableChecks:[GlobalConfigXFormView.getRemoteIMAPEnabled, GlobalConfigXFormView.getRemoteIMAPSSLEnabled,ZaItem.hasReadPermission], + enableDisableChangeEventSources:[ZaGlobalConfig.A_zimbraRemoteImapServerEnabled, ZaGlobalConfig.A_zimbraRemoteImapSSLServerEnabled], + label: ZaMsg.Remote_IMAP_SSL_Bind_Port, width: "5em" + }] + }] + }; + switchItems.push(case12); + } + } + if (ZaTabView.isTAB_ENABLED(entry, GlobalConfigXFormView.POP_TAB_ATTRS, GlobalConfigXFormView.POP_TAB_RIGHTS)) { _tab5 = ++this.TAB_INDEX; this.helpMap[_tab5] = [ location.pathname, ZaUtil.HELP_URL, "managing_global_settings/configuring_pop.htm", diff --git a/WebRoot/js/zimbraAdmin/servers/controller/ZaServerController.js b/WebRoot/js/zimbraAdmin/servers/controller/ZaServerController.js index feb894a172..400540e506 100644 --- a/WebRoot/js/zimbraAdmin/servers/controller/ZaServerController.js +++ b/WebRoot/js/zimbraAdmin/servers/controller/ZaServerController.js @@ -165,8 +165,46 @@ function () { ZaServerController.prototype._saveChanges = function () { var obj = this._view.getObject(); - if (this._currentObject[ZaModel.currentTab]!= obj[ZaModel.currentTab]) - this._currentObject[ZaModel.currentTab] = obj[ZaModel.currentTab]; + if (this._currentObject[ZaModel.currentTab]!= obj[ZaModel.currentTab]) { + this._currentObject[ZaModel.currentTab] = obj[ZaModel.currentTab]; + } + + //Check validation of reverse proxy upstream imap server: host name or IP address format + var invalidValues = []; + var isValidValue = true; + + if (ZaItem.hasWritePermission(ZaServer.A_zimbraReverseProxyUpstreamImapServers,obj)) { + if (!AjxUtil.isEmpty(obj.attrs[ZaServer.A_zimbraReverseProxyUpstreamImapServers])) { + var proxies = obj.attrs[ZaServer.A_zimbraReverseProxyUpstreamImapServers]; + + if (proxies.length == 1 && proxies[0] == "") { + this.runValidationStack(params); + return; + } + + for (var i = 0; i < proxies.length; i++) { + if (!ZaServerController.isValidHostName(proxies[i])) { + isValidValue = false; + } + if (!isValidValue) { + try { + var exIPData = ZaIPUtil.isValidIP(proxies[i]); + isValidValue = true; + } catch (ex) { + isValidValue = false; + } + } + if (!isValidValue) { + invalidValues.push(proxies[i]); + } + } + } + + if (invalidValues.length > 0) { + throw new AjxException(AjxMessageFormat.format(ZaMsg.ERROR_INVALID_IP_OR_HOSTNAME,invalidValues.join(",")),AjxException.INVALID_PARAM,"ZaServerController.prototype.validateReverseProxyUpstreamImapServers"); + } + } + this._currentObject.modify(obj); this._view.setDirty(false); ZaApp.getInstance().getAppCtxt().getAppController().setActionStatusMsg(AjxMessageFormat.format(ZaMsg.ServerModified,[this._currentObject.name])); @@ -472,6 +510,61 @@ function (params) { } ZaXFormViewController.preSaveValidationMethods["ZaServerController"].push(ZaServerController.prototype.validateImapSSLBindPort); +ZaServerController.prototype.validateRemoteImapBindPort = +function (params) { + if(!ZaItem.hasWritePermission(ZaServer.A_zimbraRemoteImapBindPort,this._currentObject)) { + this.runValidationStack(params); + return; + } + var obj = this._view.getObject(); + var tmpObj = {selectedChoice:0, choice1Label:"",choice2Label:"",choice3Label:"",warningMsg:"",fieldRef:""}; + + if( (obj.attrs[ZaServer.A_zimbraMailProxyServiceEnabled] != this._currentObject.attrs[ZaServer.A_zimbraMailProxyServiceEnabled] && obj.attrs[ZaServer.A_zimbraMailProxyServiceEnabled] == true) + ) { + if ((obj.attrs[ZaServer.A_zimbraRemoteImapBindPort] != ZaServer.DEFAULT_REMOTE_IMAP_PORT_ZCS && (obj.attrs[ZaServer.A_zimbraRemoteImapBindPort] != null)) || (obj.attrs[ZaServer.A_zimbraRemoteImapBindPort] == null && (obj._defaultValues.attrs[ZaServer.A_zimbraRemoteImapBindPort] != ZaServer.DEFAULT_REMOTE_IMAP_PORT_ZCS))) { + tmpObj.defVal = ZaServer.DEFAULT_REMOTE_IMAP_PORT_ZCS; + tmpObj.warningMsg = AjxMessageFormat.format(ZaMsg.Server_WrongPortWarning,[ZaMsg.IMAP_Port,obj.attrs[ZaServer.A_zimbraRemoteImapBindPort]]); + tmpObj.choice1Label = AjxMessageFormat.format(ZaMsg.Server_WrongPortWarning_OP1,[ZaMsg.IMAP_Port,ZaServer.DEFAULT_REMOTE_IMAP_PORT_ZCS]); + tmpObj.choice2Label = AjxMessageFormat.format(ZaMsg.Server_WrongPortWarning_OP2,[ZaMsg.IMAP_Port,obj.attrs[ZaServer.A_zimbraRemoteImapBindPort]]); + tmpObj.choice3Label = ZaMsg.Server_WrongPortWarning_OP3; + tmpObj.fieldRef = ZaServer.A_zimbraRemoteImapBindPort; + ZaServerController.showPortWarning.call(this, params,tmpObj); + } else { + this.runValidationStack(params); + return; + } + } else { + this.runValidationStack(params); + return; + } +} +ZaXFormViewController.preSaveValidationMethods["ZaServerController"].push(ZaServerController.prototype.validateRemoteImapBindPort); + +ZaServerController.prototype.validateRemoteImapSSLBindPort = +function (params) { + var obj = this._view.getObject(); + var tmpObj = {selectedChoice:0, choice1Label:"",choice2Label:"",choice3Label:"",warningMsg:"",fieldRef:""}; + + if( (obj.attrs[ZaServer.A_zimbraMailProxyServiceEnabled] != this._currentObject.attrs[ZaServer.A_zimbraMailProxyServiceEnabled] && obj.attrs[ZaServer.A_zimbraMailProxyServiceEnabled] == true)) { + if ((obj.attrs[ZaServer.A_zimbraRemoteImapSSLBindPort] != ZaServer.DEFAULT_REMOTE_IMAP_SSL_PORT_ZCS && (obj.attrs[ZaServer.A_zimbraRemoteImapSSLBindPort] != null)) || (obj.attrs[ZaServer.A_zimbraRemoteImapSSLBindPort] == null && (obj._defaultValues.attrs[ZaServer.A_zimbraRemoteImapSSLBindPort] != ZaServer.DEFAULT_REMOTE_IMAP_SSL_PORT_ZCS))) { + tmpObj.defVal = ZaServer.DEFAULT_REMOTE_IMAP_SSL_PORT_ZCS; + tmpObj.warningMsg = AjxMessageFormat.format(ZaMsg.Server_WrongPortWarning,[ZaMsg.IMAP_Port,obj.attrs[ZaServer.A_zimbraRemoteImapSSLBindPort]]); + tmpObj.choice1Label = AjxMessageFormat.format(ZaMsg.Server_WrongPortWarning_OP1,[ZaMsg.IMAP_SSLPort,ZaServer.DEFAULT_REMOTE_IMAP_SSL_PORT_ZCS]); + tmpObj.choice2Label = AjxMessageFormat.format(ZaMsg.Server_WrongPortWarning_OP2,[ZaMsg.IMAP_SSLPort,obj.attrs[ZaServer.A_zimbraRemoteImapSSLBindPort]]); + tmpObj.choice3Label = ZaMsg.Server_WrongPortWarning_OP3; + tmpObj.fieldRef = ZaServer.A_zimbraRemoteImapSSLBindPort; + ZaServerController.showPortWarning.call(this, params,tmpObj); + } else { + this.runValidationStack(params); + return; + } + } else { + this.runValidationStack(params); + return; + } +} +ZaXFormViewController.preSaveValidationMethods["ZaServerController"].push(ZaServerController.prototype.validateRemoteImapSSLBindPort); + ZaServerController.prototype.validatePop3BindPort = function (params) { if(!ZaItem.hasWritePermission(ZaServer.A_zimbraPop3BindPort,this._currentObject)) { @@ -689,6 +782,79 @@ function (params) { } ZaXFormViewController.preSaveValidationMethods["ZaServerController"].push(ZaServerController.prototype.validatePop3SSLProxyBindPort); +ZaServerController.prototype.validateReverseProxyUpstreamImapServers = +function (params) { + if(!ZaItem.hasWritePermission(ZaServer.A_zimbraReverseProxyUpstreamImapServers,this._currentObject)) { + this.runValidationStack(params); + return; + } + var obj = this._view.getObject(); + var invalidValues = []; + var isValidValue = true; + + if(obj.attrs[ZaServer.A_zimbraReverseProxyUpstreamImapServers]) { + var proxies = obj.attrs[ZaServer.A_zimbraReverseProxyUpstreamImapServers]; + + if (proxies.length == 1 && proxies[0] == "") { + this.runValidationStack(params); + return; + } + + for(var i = 0; i < proxies.length; i++) { + if(!ZaServerController.isValidHostName(proxies[i])) { + isValidValue = false; + } + if(!isValidValue) { + try { + var exIPData = ZaIPUtil.isValidIP(proxies[i]); + isValidValue = true; + } catch (ex) { + isValidValue = false; + } + } + if(!isValidValue) { + invalidValues.push(proxies[i]); + } + } + } + + if(invalidValues.length > 0) { + throw new AjxException(AjxMessageFormat.format(ZaMsg.ERROR_INVALID_IP_OR_HOSTNAME,invalidValues.join(",")),AjxException.INVALID_PARAM,"ZaServerController.prototype.validateReverseProxyUpstreamImapServers"); + } else { + this.runValidationStack(params); + } +} +ZaXFormViewController.preSaveValidationMethods["ZaServerController"].push(ZaServerController.prototype.validateReverseProxyUpstreamImapServers); + +ZaServerController.isValidHostName = function (isHostNameStr) { + if (!isHostNameStr) { + return false; + } + + //Check isHostNameStr has '.' at index 0 (First dot in host name) + if (isHostNameStr[0] == ".") { + return false; + } + + //Check isHostNameStr has '.' at the end of host name (Last dot in host name) + if (isHostNameStr[isHostNameStr.length -1] == ".") { + return false; + } + + //Invalid host name that has two or more adjacent dot + for(var i = 0; i < isHostNameStr.length - 1; i++) { + if (isHostNameStr[i] == "." && isHostNameStr[i+1] == ".") { + return false; + } + } + + if(AjxUtil.isHostName(isHostNameStr)) { + return true; + } + + return false; +} + ZaServerController.showPortWarning = function (params, instanceObj) { if(ZaApp.getInstance().dialogs["confirmMessageDialog"]) diff --git a/WebRoot/js/zimbraAdmin/servers/model/ZaServer.js b/WebRoot/js/zimbraAdmin/servers/model/ZaServer.js index 997c343f94..9eeab20002 100755 --- a/WebRoot/js/zimbraAdmin/servers/model/ZaServer.js +++ b/WebRoot/js/zimbraAdmin/servers/model/ZaServer.js @@ -65,6 +65,7 @@ ZaServer.A_zimbraLoggerServiceInstalled = "_"+ZaServer.A_zimbraServiceInstalled+ ZaServer.A_zimbraMailProxyServiceInstalled = "_"+ZaServer.A_zimbraServiceInstalled+"_proxy"; ZaServer.A_zimbraVmwareHAServiceInstalled = "_"+ ZaServer.A_zimbraServiceInstalled+"_vmwareha"; ZaServer.A_zimbraPolicydServiceInstalled = "_"+ ZaServer.A_zimbraServiceInstalled+"_cbpolicyd"; +ZaServer.A_zimbraImapdServiceInstalled = "_"+ ZaServer.A_zimbraServiceInstalled+"_imapd"; ZaServer.A_zimbraReverseProxyHttpEnabled = "zimbraReverseProxyHttpEnabled"; ZaServer.A_zimbraServiceEnabled = "zimbraServiceEnabled"; @@ -191,6 +192,13 @@ ZaServer.A_zimbraReverseProxyMailMode = "zimbraReverseProxyMailMode"; ZaServer.A_zimbraReverseProxyClientCertMode = "zimbraReverseProxyClientCertMode"; ZaServer.A_zimbraReverseProxyClientCertCA = "zimbraReverseProxyClientCertCA"; +//IMAPD +ZaServer.A_zimbraRemoteImapServerEnabled = "zimbraRemoteImapServerEnabled"; +ZaServer.A_zimbraRemoteImapSSLServerEnabled = "zimbraRemoteImapSSLServerEnabled"; +ZaServer.A_zimbraReverseProxyUpstreamImapServers = "zimbraReverseProxyUpstreamImapServers"; +ZaServer.A_zimbraRemoteImapBindPort = "zimbraRemoteImapBindPort"; +ZaServer.A_zimbraRemoteImapSSLBindPort = "zimbraRemoteImapSSLBindPort"; + // other ZaServer.A_zimbraScheduledTaskNumThreads = "zimbraScheduledTaskNumThreads" ; ZaServer.A_zimbraMailPurgeSleepInterval = "zimbraMailPurgeSleepInterval" ; @@ -260,6 +268,8 @@ ZaServer.DEFAULT_IMAP_PORT_ZCS=7143; ZaServer.DEFAULT_IMAP_SSL_PORT_ZCS=7993; ZaServer.DEFAULT_POP3_PORT_ZCS=7110; ZaServer.DEFAULT_POP3_SSL_PORT_ZCS=7995; +ZaServer.DEFAULT_REMOTE_IMAP_PORT_ZCS=8143; +ZaServer.DEFAULT_REMOTE_IMAP_SSL_PORT_ZCS=8993; ZaServer.ERR_NOT_CIDR = 1; ZaServer.ERR_NOT_STARTING_ADDR = 2; @@ -533,7 +543,7 @@ ZaServer.myXModel = { {id:ZaServer.A_zimbraSpellServiceEnabled, ref:"attrs/"+ZaServer.A_zimbraSpellServiceEnabled, type: _ENUM_, choices: [false,true] }, {id:ZaServer.A_zimbraLoggerServiceEnabled, ref:"attrs/"+ZaServer.A_zimbraLoggerServiceEnabled, type: _ENUM_, choices: [false,true] }, {id:ZaServer.A_zimbraVmwareHAServiceEnabled, ref:"attrs/"+ZaServer.A_zimbraVmwareHAServiceEnabled, type: _ENUM_, choices: [false,true] }, - {id:ZaServer.A_zimbraMailProxyServiceEnabled, ref:"attrs/"+ZaServer.A_zimbraMailProxyServiceEnabled, type: _ENUM_, choices: [false,true] }, + {id:ZaServer.A_zimbraMailProxyServiceEnabled, ref:"attrs/"+ZaServer.A_zimbraMailProxyServiceEnabled, type: _ENUM_, choices: [false,true] }, {id:ZaServer.A_zimbraReverseProxyLookupTarget, ref:"attrs/"+ZaServer.A_zimbraReverseProxyLookupTarget, type: _COS_ENUM_, choices: ZaModel.BOOLEAN_CHOICES}, {id:ZaServer.A_zimbraLdapServiceInstalled, ref:"attrs/"+ZaServer.A_zimbraLdapServiceInstalled, type: _ENUM_, choices: [false,true] }, {id:ZaServer.A_zimbraMailboxServiceInstalled, ref:"attrs/"+ZaServer.A_zimbraMailboxServiceInstalled, type: _ENUM_, choices: [false,true] }, @@ -551,7 +561,9 @@ ZaServer.myXModel = { {id:ZaServer.A_zimbraLoggerServiceInstalled, ref:"attrs/"+ZaServer.A_zimbraLoggerServiceInstalled, type: _ENUM_, choices: [false,true] }, {id:ZaServer.A_zimbraMailProxyServiceInstalled, ref:"attrs/"+ZaServer.A_zimbraMailProxyServiceInstalled, type: _ENUM_, choices: [false,true] }, {id:ZaServer.A_zimbraVmwareHAServiceInstalled, ref:"attrs/"+ZaServer.A_zimbraVmwareHAServiceInstalled, type: _ENUM_, choices: [false,true] }, - {id:ZaServer.A_zimbraPolicydServiceInstalled, ref:"attrs/"+ZaServer.A_zimbraPolicydServiceInstalled, type: _ENUM_, choices: [false,true] }, + {id:ZaServer.A_zimbraPolicydServiceInstalled, ref:"attrs/"+ZaServer.A_zimbraPolicydServiceInstalled, type: _ENUM_, choices: [false,true] }, + {id:ZaServer.A_zimbraImapdServiceInstalled, ref:"attrs/"+ZaServer.A_zimbraImapdServiceInstalled, type: _ENUM_, choices: [false,true] }, + // MTA {id:ZaServer.A_zimbraMtaSaslAuthEnable, ref:"attrs/" + ZaServer.A_zimbraMtaSaslAuthEnable, type: _COS_ENUM_, choices: ["yes", "no"] }, {id:ZaServer.A_zimbraMtaTlsAuthOnly, ref:"attrs/" + ZaServer.A_zimbraMtaTlsAuthOnly, type: _COS_ENUM_, choices: ZaModel.BOOLEAN_CHOICES }, @@ -595,7 +607,14 @@ ZaServer.myXModel = { {id:ZaServer.A_zimbraImapBindPort, ref:"attrs/" + ZaServer.A_zimbraImapBindPort, type:_COS_PORT_ }, {id:ZaServer.A_ImapServerEnabled, ref:"attrs/" + ZaServer.A_ImapServerEnabled, type:_COS_ENUM_, choices:ZaModel.BOOLEAN_CHOICES}, {id:ZaServer.A_ImapSSLBindPort, ref:"attrs/" + ZaServer.A_ImapSSLBindPort, type:_COS_PORT_ }, - {id:ZaServer.A_ImapSSLServerEnabled, ref:"attrs/" + ZaServer.A_ImapSSLServerEnabled, type:_COS_ENUM_, choices:ZaModel.BOOLEAN_CHOICES}, + {id:ZaServer.A_ImapSSLServerEnabled, ref:"attrs/" + ZaServer.A_ImapSSLServerEnabled, type:_COS_ENUM_, choices:ZaModel.BOOLEAN_CHOICES}, + + //IMAPD + {id:ZaServer.A_zimbraRemoteImapServerEnabled, ref:"attrs/" + ZaServer.A_zimbraRemoteImapServerEnabled, type:_COS_ENUM_, choices:ZaModel.BOOLEAN_CHOICES}, + {id:ZaServer.A_zimbraRemoteImapSSLServerEnabled, ref:"attrs/" + ZaServer.A_zimbraRemoteImapSSLServerEnabled, type:_COS_ENUM_, choices:ZaModel.BOOLEAN_CHOICES}, + {id:ZaServer.A_zimbraReverseProxyUpstreamImapServers, ref:"attrs/" + ZaServer.A_zimbraReverseProxyUpstreamImapServers, type:_COS_LIST_, listItem:{type:_STRING_, maxLength: 256} }, + {id:ZaServer.A_zimbraRemoteImapBindPort, ref:"attrs/" + ZaServer.A_zimbraRemoteImapBindPort, type:_COS_PORT_ }, + {id:ZaServer.A_zimbraRemoteImapSSLBindPort, ref:"attrs/" + ZaServer.A_zimbraRemoteImapSSLBindPort, type:_COS_PORT_ }, //ip address bindings {id:ZaServer.A_zimbraMailBindAddress, ref:"attrs/" + ZaServer.A_zimbraMailBindAddress, type:_IP_}, @@ -1129,6 +1148,9 @@ ZaServer.prototype.initFromJS = function(server) { this.attrs[ZaServer.A_zimbraAutoProvScheduledDomains] = [this.attrs[ZaServer.A_zimbraAutoProvScheduledDomains]]; } + if(this.attrs[ZaServer.A_zimbraReverseProxyUpstreamImapServers] && !(this.attrs[ZaServer.A_zimbraReverseProxyUpstreamImapServers] instanceof Array)) { + this.attrs[ZaServer.A_zimbraReverseProxyUpstreamImapServers] = [this.attrs[ZaServer.A_zimbraReverseProxyUpstreamImapServers]]; + } } ZaServer.prototype.parseCurrentVolumesResponse = diff --git a/WebRoot/js/zimbraAdmin/servers/view/ZaServerXFormView.js b/WebRoot/js/zimbraAdmin/servers/view/ZaServerXFormView.js old mode 100644 new mode 100755 index f05d86c729..b2efe32b77 --- a/WebRoot/js/zimbraAdmin/servers/view/ZaServerXFormView.js +++ b/WebRoot/js/zimbraAdmin/servers/view/ZaServerXFormView.js @@ -230,6 +230,24 @@ ZaServerXFormView.getIsReverseProxyLookupTarget = function () { return (this.getModel().getInstanceValue(this.getInstance(),ZaServer.A_zimbraReverseProxyLookupTarget) == "TRUE"); } +ZaServerXFormView.getRemoteIMAPEnabled = function () { + var value = this.getModel().getInstanceValue(this.getInstance(),ZaServer.A_zimbraRemoteImapServerEnabled); + return value == 'TRUE'; +} + +ZaServerXFormView.getRemoteIMAPSSLEnabled = function () { + var value = this.getModel().getInstanceValue(this.getInstance(),ZaServer.A_zimbraRemoteImapSSLServerEnabled); + return (value == 'TRUE' && ZaServerXFormView.getRemoteIMAPEnabled.call(this)); +} + +ZaServerXFormView.isImapdInstalled = function(server) { + if(server.attrs[ZaServer.A_zimbraImapdServiceInstalled] == true) { + return true; + } + + return false; +} + ZaServerXFormView.volumeSelectionListener = function (ev) { //var instance = this.getInstance(); @@ -661,6 +679,11 @@ ZaServerXFormView.MTA_SERVICE_GROUP_ATTRS = [ZaServer.A_ImapServerEnabled, ZaSer ZaServerXFormView.BIND_IP_TAB_ATTRS = [ZaServer.A_zimbraMailBindAddress, ZaServer.A_zimbraMailSSLBindAddress, ZaServer.A_zimbraMailSSLClientCertBindAddress, ZaServer.A_zimbraAdminBindAddress]; ZaServerXFormView.BIND_IP_TAB_RIGHTS = []; + +ZaServerXFormView.IMAPD_TAB_ATTRS = [ZaServer.A_zimbraRemoteImapServerEnabled, ZaServer.A_zimbraRemoteImapSSLServerEnabled, + ZaServer.A_zimbraReverseProxyUpstreamImapServers, ZaServer.A_zimbraRemoteImapBindPort, ZaServer.A_zimbraRemoteImapSSLBindPort]; +ZaServerXFormView.IMAPD_TAB_RIGHTS = []; + /** * This method is added to the map {@link ZaTabView#XFormModifiers} * @param xFormObject {Object} a definition of the form. This method adds/removes/modifies xFormObject to construct @@ -705,7 +728,15 @@ ZaServerXFormView.myXFormModifier = function(xFormObject, entry) { _tab5 = ++this.TAB_INDEX; tabBarChoices.push ({value:_tab5, label:ZaMsg.NAD_Tab_IMAP}); this.helpMap[_tab5] = [location.pathname, ZaUtil.HELP_URL, "managing_servers/configuring_imap_settings.htm", "?locid=", AjxEnv.DEFAULT_LOCALE].join(""); - } + } + + if(ZaServerXFormView.isImapdInstalled(entry)) { + if(ZaTabView.isTAB_ENABLED(entry,ZaServerXFormView.IMAPD_TAB_ATTRS, ZaServerXFormView.IMAPD_TAB_RIGHTS)) { + _tab9 = ++this.TAB_INDEX; + tabBarChoices.push ({value:_tab9, label:ZaMsg.NAD_Tab_IMAPD}); + //this.helpMap[_tab9] = [location.pathname, ZaUtil.HELP_URL, "managing_servers/setting_up_ip_address_binding.htm", "?locid=", AjxEnv.DEFAULT_LOCALE].join(""); + } + } if(ZaTabView.isTAB_ENABLED(entry,ZaServerXFormView.POP_TAB_ATTRS, ZaServerXFormView.POP_TAB_RIGHTS)) { _tab6 = ++this.TAB_INDEX; @@ -1272,8 +1303,7 @@ ZaServerXFormView.myXFormModifier = function(xFormObject, entry) { }, { ref: ZaServer.A_zimbraPop3BindPort, type:_TEXTFIELD_, enableDisableChangeEventSources:[ZaServer.A_Pop3ServerEnabled], - enableDisableChecks:[ZaServerXFormView.getPOP3Enabled,ZaItem.hasWritePermission], - + enableDisableChecks:[ZaServerXFormView.getPOP3Enabled,ZaItem.hasWritePermission], label: ZaMsg.LBL_POP_Port, labelLocation:_LEFT_, textFieldCssClass:"admin_xform_number_input", @@ -1425,6 +1455,82 @@ ZaServerXFormView.myXFormModifier = function(xFormObject, entry) { switchItems.push (case8) ; } + if(_tab9) { + var case9 = {type:_ZATABCASE_, colSizes:["auto"],numCols:1, caseKey:_tab9, id:"server_remote_imap_tab", + items:[{ type: _DWT_ALERT_, + containerCssStyle: "padding-bottom:0;", + style: DwtAlert.INFO, + iconVisible: false, + content: ZaMsg.Alert_ServerRestart + }] + }; + + if(ZAGroup_XFormItem.isGroupVisible(entry,ZaServerXFormView.IMAPD_TAB_ATTRS,[])) { + case9.items.push({ + type:_ZA_TOP_GROUPER_, colSizes:["275", "100%"], numCols:2,label:ZaMsg.Global_IMAPD_ServiceGrp, + items: [{ + ref : ZaServer.A_zimbraReverseProxyUpstreamImapServers, + type : _SUPER_REPEAT_, + label : ZaMsg.Reverse_Proxy_Upstream_Imap, + labelLocation : _LEFT_, + align : _LEFT_, + resetToSuperLabel:ZaMsg.NAD_ResetToGlobal, + repeatInstance : "", + showAddButton : true, + showRemoveButton : true, + showAddOnNextRow : true, + addButtonLabel : ZaMsg.Add_zimbraReverseProxyUpstreamImapServers, + removeButtonLabel : ZaMsg.Remove_zimbraReverseProxyUpstreamImapServers, + removeButtonCSSStyle : "margin-left: 50px", + visibilityChecks : [ ZaItem.hasReadPermission ], + repeatItems : [{ + ref : ".", + type : _TEXTFIELD_, + label : null, + labelLocation : _NONE_, + width : 200, + toolTipContent : ZaMsg.tt_zimbraReverseProxyUpstreamImapServers, + visibilityChecks : [ ZaItem.hasReadPermission ] + }] + },{ + ref: ZaServer.A_zimbraRemoteImapServerEnabled, type: _SUPER_CHECKBOX_, + checkBoxLabel:ZaMsg.Remote_IMAP_Server, + trueValue: "TRUE", falseValue: "FALSE", + onChange: ZaServerXFormView.onFormFieldChanged, + resetToSuperLabel:ZaMsg.NAD_ResetToGlobal + },{ + ref: ZaServer.A_zimbraRemoteImapSSLServerEnabled, type: _SUPER_CHECKBOX_, + checkBoxLabel:ZaMsg.Remote_IMAP_SSLServer, + trueValue: "TRUE", falseValue: "FALSE", + onChange: ZaServerXFormView.onFormFieldChanged, + resetToSuperLabel:ZaMsg.NAD_ResetToGlobal + }] + }); + } + + if(ZAGroup_XFormItem.isGroupVisible(entry,ZaServerXFormView.IMAPD_TAB_ATTRS,[])) { + case9.items.push({ + type:_ZA_TOP_GROUPER_, label:ZaMsg.Global_IMAPD_NetworkGrp, + items: [{ + ref: ZaServer.A_zimbraRemoteImapBindPort, type: _SUPER_TEXTFIELD_, + enableDisableChecks:[ZaServerXFormView.getRemoteIMAPEnabled, ZaItem.hasReadPermission], + enableDisableChangeEventSources:[ZaServer.A_zimbraRemoteImapServerEnabled], + label: ZaMsg.Remote_IMAP_Bind_Port, textFieldWidth: "5em", + onChange: ZaServerXFormView.onFormFieldChanged, + resetToSuperLabel:ZaMsg.NAD_ResetToGlobal + }, { + ref: ZaServer.A_zimbraRemoteImapSSLBindPort, type: _SUPER_TEXTFIELD_, + enableDisableChecks:[ZaServerXFormView.getRemoteIMAPEnabled, ZaServerXFormView.getRemoteIMAPSSLEnabled, ZaItem.hasReadPermission], + enableDisableChangeEventSources:[ZaServer.A_zimbraRemoteImapServerEnabled, ZaServer.A_zimbraRemoteImapSSLServerEnabled], + label: ZaMsg.Remote_IMAP_SSL_Bind_Port, textFieldWidth: "5em", + onChange: ZaServerXFormView.onFormFieldChanged, + resetToSuperLabel:ZaMsg.NAD_ResetToGlobal + }] + }); + } + + switchItems.push (case9) ; + } xFormObject.tableCssStyle="width:100%;position:static;overflow:auto;"; diff --git a/WebRoot/messages/ZaMsg.properties b/WebRoot/messages/ZaMsg.properties old mode 100644 new mode 100755 index 8a026da7a5..23cfcf0abf --- a/WebRoot/messages/ZaMsg.properties +++ b/WebRoot/messages/ZaMsg.properties @@ -849,6 +849,7 @@ NAD_Tab_MTA = MTA NAD_Tab_AUTH = Authentication NAD_Tab_POP = POP NAD_Tab_IMAP = IMAP +NAD_Tab_IMAPD = IMAPD NAD_Tab_Services = Services NAD_Tab_VolumeMgt = Volumes NAD_Tab_HSM = HSM @@ -902,8 +903,11 @@ NAD_MTA_AuthenticationEnabled = Enabled NAD_MTA_TlsAuthenticationOnly = TLS authentication only LBL_zimbraSmtpHostname = Web mail MTA Hostnames: tt_zimbraSmtpHostname = The MTA that the web server will connect to for sending mails +tt_zimbraReverseProxyUpstreamImapServers = The pool of servers that are available to the proxy for handling IMAP sessions. Add_zimbraSmtpHostname = Add Remove_zimbraSmtpHostname = Remove +Add_zimbraReverseProxyUpstreamImapServers = Add +Remove_zimbraReverseProxyUpstreamImapServers = Remove NAD_MTA_WebMailPort = Web mail MTA Port: NAD_MTA_WebMailTimeout = Web mail MTA timeout (s): NAD_MTA_RelayMTA = Relay MTA for external delivery: @@ -1324,6 +1328,16 @@ IMAP_SSL_Proxy_Port = IMAP SSL proxy port number IMAP_SSLService = Enable SSL for IMAP service IMAP_CleartextLoginEnabled = Enable clear text login IMAP_NumThreads = Number of threads: + +#imapd +Global_IMAPD_ServiceGrp = Service +Global_IMAPD_NetworkGrp = Network +Remote_IMAP_Server = Enable Remote IMAP Server +Remote_IMAP_SSLServer = Enable SSL for Remote IMAP Server +Remote_IMAP_Bind_Port = Remote IMAP port number +Remote_IMAP_SSL_Bind_Port = Remote IMAP SSL port number +Reverse_Proxy_Upstream_Imap = Reverse Upstream Server + Server_WrongPortWarningTitle = Warning! Server_WrongPortWarning = Warning! {0} is set to {1}. This value is not advised when IMAP/POP proxy service is enabled. What would you like to do? Server_WrongPortWarning_OP1 = 1. Change the value of {0} to {1} (recommended value)? @@ -1805,6 +1819,7 @@ ERROR_NOT_CIDR = Error! {0} is not a valid subnet value in CIDR notation!
A ERROR_NOT_STARTING_ADDR = Error! non-null host address bits in {0}, perhaps you should use {1} instead!
Additional information about MTA Trusted Networks configuration can be found at https://wiki.zimbra.com/index.php?title=ZimbraMtaMyNetworks. ERROR_LOCAL_ADDR_EXCLUDED = Error! Local interface address {0} is excluded from MTA Trusted Networks by entry {1}. ERROR_INVALID_EXCLUDE_ADDR = Error! {0} is not a valid IP address or network mask. +ERROR_INVALID_IP_OR_HOSTNAME = Error! {0} is not a valid IP address or host name. ERROR_INVALID_IP_ADDR = Invalid IP address ERROR_ONE_FP_PREFIX_ALLOWED = Only one foreign principal for the same provider is allowed. WARNING_DOMAIN_DS_NOT_CONFIGRED = Warning: GAL datasources are not configured for this domain.