Commit 8e93e3be authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Merged revision(s) 66270 from AVS/Sources/TeamlabOffice/branches/server_3.5.0-212_CanBranding:

canBranding для всех false, кроме тех, у кого есть лицензия, пусть даже и просроченная
........


git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@66316 954022d7-b5bf-4e40-9824-e11837661b57
parent 91cfb395
"use strict"; "use strict";
var g_oLicenseResult = {
Error : 1,
Expired : 2,
Success : 3
};
var g_sLicenseDefaultUrl = "/license"; var g_sLicenseDefaultUrl = "/license";
var g_sPublicRSAKey = '-----BEGIN CERTIFICATE-----MIIBvTCCASYCCQD55fNzc0WF7TANBgkqhkiG9w0BAQUFADAjMQswCQYDVQQGEwJKUDEUMBIGA1UEChMLMDAtVEVTVC1SU0EwHhcNMTAwNTI4MDIwODUxWhcNMjAwNTI1MDIwODUxWjAjMQswCQYDVQQGEwJKUDEUMBIGA1UEChMLMDAtVEVTVC1SU0EwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANGEYXtfgDRlWUSDn3haY4NVVQiKI9CzThoua9+DxJuiseyzmBBe7Roh1RPqdvmtOHmEPbJ+kXZYhbozzPRbFGHCJyBfCLzQfVos9/qUQ88u83b0SFA2MGmQWQAlRtLy66EkR4rDRwTj2DzR4EEXgEKpIvo8VBs/3+sHLF3ESgAhAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAEZ6mXFFq3AzfaqWHmCy1ARjlauYAa8ZmUFnLm0emg9dkVBJ63aEqARhtok6bDQDzSJxiLpCEF6G4b/Nv/M/MLyhP+OoOTmETMegAVQMq71choVJyOFE5BtQa6M/lCHEOya5QUfoRF2HF9EjRF44K3OK+u3ivTSj3zwjtpudY5Xo=-----END CERTIFICATE-----'; var g_sPublicRSAKey = '-----BEGIN CERTIFICATE-----MIIBvTCCASYCCQD55fNzc0WF7TANBgkqhkiG9w0BAQUFADAjMQswCQYDVQQGEwJKUDEUMBIGA1UEChMLMDAtVEVTVC1SU0EwHhcNMTAwNTI4MDIwODUxWhcNMjAwNTI1MDIwODUxWjAjMQswCQYDVQQGEwJKUDEUMBIGA1UEChMLMDAtVEVTVC1SU0EwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANGEYXtfgDRlWUSDn3haY4NVVQiKI9CzThoua9+DxJuiseyzmBBe7Roh1RPqdvmtOHmEPbJ+kXZYhbozzPRbFGHCJyBfCLzQfVos9/qUQ88u83b0SFA2MGmQWQAlRtLy66EkR4rDRwTj2DzR4EEXgEKpIvo8VBs/3+sHLF3ESgAhAgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAEZ6mXFFq3AzfaqWHmCy1ARjlauYAa8ZmUFnLm0emg9dkVBJ63aEqARhtok6bDQDzSJxiLpCEF6G4b/Nv/M/MLyhP+OoOTmETMegAVQMq71choVJyOFE5BtQa6M/lCHEOya5QUfoRF2HF9EjRF44K3OK+u3ivTSj3zwjtpudY5Xo=-----END CERTIFICATE-----';
...@@ -7,7 +13,7 @@ function CheckLicense(licenseUrl, customerId, userId, userFirstName, userLastNam ...@@ -7,7 +13,7 @@ function CheckLicense(licenseUrl, customerId, userId, userFirstName, userLastNam
licenseUrl = licenseUrl ? licenseUrl : g_sLicenseDefaultUrl; licenseUrl = licenseUrl ? licenseUrl : g_sLicenseDefaultUrl;
g_fGetJSZipUtils().getBinaryContent(licenseUrl, function(err, data) { g_fGetJSZipUtils().getBinaryContent(licenseUrl, function(err, data) {
if (err) { if (err) {
callback(true, false); callback(true, g_oLicenseResult.Error);
return; return;
} }
...@@ -27,9 +33,9 @@ function CheckLicense(licenseUrl, customerId, userId, userFirstName, userLastNam ...@@ -27,9 +33,9 @@ function CheckLicense(licenseUrl, customerId, userId, userFirstName, userLastNam
var x509 = new X509(); var x509 = new X509();
x509.readCertPEM(g_sPublicRSAKey); x509.readCertPEM(g_sPublicRSAKey);
var isValid = x509.subjectPublicKeyRSA.verifyString(JSON.stringify(oLicense), hSig); var isValid = x509.subjectPublicKeyRSA.verifyString(JSON.stringify(oLicense), hSig);
callback(false, isValid ? CheckUserInLicense(customerId, userId, userFirstName, userLastName, oLicense) : false); callback(false, isValid ? CheckUserInLicense(customerId, userId, userFirstName, userLastName, oLicense) : g_oLicenseResult.Error);
} catch (e) { } catch (e) {
callback(true, false); callback(true, g_oLicenseResult.Error);
} }
}); });
} }
...@@ -43,7 +49,7 @@ function CheckLicense(licenseUrl, customerId, userId, userFirstName, userLastNam ...@@ -43,7 +49,7 @@ function CheckLicense(licenseUrl, customerId, userId, userFirstName, userLastNam
* @returns {boolean} * @returns {boolean}
*/ */
function CheckUserInLicense(customerId, userId, userFirstName, userLastName, oLicense) { function CheckUserInLicense(customerId, userId, userFirstName, userLastName, oLicense) {
var res = false; var res = g_oLicenseResult.Error;
var superuser = 'onlyoffice'; var superuser = 'onlyoffice';
try { try {
if (oLicense['users']) { if (oLicense['users']) {
...@@ -56,11 +62,11 @@ function CheckUserInLicense(customerId, userId, userFirstName, userLastName, oLi ...@@ -56,11 +62,11 @@ function CheckUserInLicense(customerId, userId, userFirstName, userLastName, oLi
} }
if (checkUserHash) { if (checkUserHash) {
var endDate = new Date(oLicense['end_date']); var endDate = new Date(oLicense['end_date']);
res = endDate >= new Date(); res = (endDate >= new Date()) ? g_oLicenseResult.Success : g_oLicenseResult.Expired;
} }
} }
} catch (e) { } catch (e) {
res = false; res = g_oLicenseResult.Error;
} }
return res; return res;
} }
......
...@@ -20,30 +20,14 @@ ...@@ -20,30 +20,14 @@
* @memberOf Asc * @memberOf Asc
*/ */
function asc_CAscEditorPermissions (settings) { function asc_CAscEditorPermissions (settings) {
if ( !(this instanceof asc_CAscEditorPermissions) ) { this.canEdit = true;
return new asc_CAscEditorPermissions(); this.canDownload = true;
} this.canCoAuthoring = true;
if(settings) { this.canReaderMode = true;
this.canLicense = settings["canLicense"]; this.canBranding = false;
this.isAutosaveEnable = true;
this.canEdit = settings["canEdit"]; this.AutosaveMinInterval = 300;
this.canDownload = settings["canDownload"]; this.isAnalyticsEnable = false;
this.canCoAuthoring = settings["canCoAuthoring"];
this.canReaderMode = settings["canReaderMode"];
this.canBranding = settings["canBranding"];
this.isAutosaveEnable = settings["isAutosaveEnable"];
this.AutosaveMinInterval = settings["AutosaveMinInterval"];
this.isAnalyticsEnable = settings["isAnalyticsEnable"];
} else {
this.canEdit = true;
this.canDownload = true;
this.canCoAuthoring = true;
this.canReaderMode = true;
this.canBranding = true;
this.isAutosaveEnable = true;
this.AutosaveMinInterval = 300;
this.isAnalyticsEnable = false;
}
return this; return this;
} }
...@@ -61,15 +45,7 @@ ...@@ -61,15 +45,7 @@
asc_getIsAnalyticsEnable: function(){ return this.isAnalyticsEnable; }, asc_getIsAnalyticsEnable: function(){ return this.isAnalyticsEnable; },
asc_setCanLicense: function(v){ this.canLicense = v; }, asc_setCanLicense: function(v){ this.canLicense = v; },
asc_setCanBranding: function(v){ this.canBranding = v; }
asc_setCanEdit: function(v){ this.canEdit = v; },
asc_setCanDownload: function(v){ this.canDownload = v; },
asc_setCanCoAuthoring: function(v){ this.canCoAuthoring = v; },
asc_setCanReaderMode: function(v){ this.canReaderMode = v; },
asc_setCanBranding: function(v){ this.canBranding = v; },
asc_setIsAutosaveEnable: function(v){ this.isAutosaveEnable = v; },
asc_setAutosaveMinInterval: function(v){ this.AutosaveMinInterval = v; },
asc_setIsAnalyticsEnable: function(v){ this.isAnalyticsEnable = v; }
}; };
/* /*
......
...@@ -30,14 +30,15 @@ ...@@ -30,14 +30,15 @@
}); });
} else { } else {
// Фиктивный вызов // Фиктивный вызов
this._onCheckLicenseEnd(true, false); this._onCheckLicenseEnd(true, g_oLicenseResult.Error);
} }
this._coAuthoringInit(); this._coAuthoringInit();
}; };
asc['spreadsheet_api'].prototype._onEndPermissions = function() { asc['spreadsheet_api'].prototype._onEndPermissions = function() {
if (null !== this.licenseResult && this.isOnFirstConnectEnd) { if (null !== this.licenseResult && this.isOnFirstConnectEnd) {
var oResult = new asc.asc_CAscEditorPermissions(); var oResult = new asc.asc_CAscEditorPermissions();
oResult.asc_setCanLicense(this.licenseResult.res); oResult.asc_setCanLicense(g_oLicenseResult.Success === this.licenseResult.res);
oResult.asc_setCanBranding(g_oLicenseResult.Error !== this.licenseResult.res); // Для тех, у кого есть лицензия, branding доступен
this.handlers.trigger('asc_onGetEditorPermissions', oResult); this.handlers.trigger('asc_onGetEditorPermissions', oResult);
} }
}; };
......
...@@ -14,14 +14,15 @@ asc_docs_api.prototype.asc_getEditorPermissions = function(licenseUrl, customerI ...@@ -14,14 +14,15 @@ asc_docs_api.prototype.asc_getEditorPermissions = function(licenseUrl, customerI
}); });
} else { } else {
// Фиктивный вызов // Фиктивный вызов
this._onCheckLicenseEnd(true, false); this._onCheckLicenseEnd(true, g_oLicenseResult.Error);
} }
this._coAuthoringInit(); this._coAuthoringInit();
}; };
asc_docs_api.prototype._onEndPermissions = function() { asc_docs_api.prototype._onEndPermissions = function() {
if (null !== this.licenseResult && this.isOnFirstConnectEnd) { if (null !== this.licenseResult && this.isOnFirstConnectEnd) {
var oResult = new window['Asc'].asc_CAscEditorPermissions(); var oResult = new window['Asc'].asc_CAscEditorPermissions();
oResult.asc_setCanLicense(this.licenseResult.res); oResult.asc_setCanLicense(g_oLicenseResult.Success === this.licenseResult.res);
oResult.asc_setCanBranding(g_oLicenseResult.Error !== this.licenseResult.res); // Для тех, у кого есть лицензия, branding доступен
this.asc_fireCallback('asc_onGetEditorPermissions', oResult); this.asc_fireCallback('asc_onGetEditorPermissions', oResult);
} }
}; };
\ No newline at end of file
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
*/ */
/** /**
* *
* @constructor * @constructor
* @extends {CCollaborativeEditingBase} * @extends {CCollaborativeEditingBase}
*/ */
......
...@@ -15,14 +15,15 @@ asc_docs_api.prototype.asc_getEditorPermissions = function(licenseUrl, customerI ...@@ -15,14 +15,15 @@ asc_docs_api.prototype.asc_getEditorPermissions = function(licenseUrl, customerI
}); });
} else { } else {
// Фиктивный вызов // Фиктивный вызов
this._onCheckLicenseEnd(true, false); this._onCheckLicenseEnd(true, g_oLicenseResult.Error);
} }
this._coAuthoringInit(); this._coAuthoringInit();
}; };
asc_docs_api.prototype._onEndPermissions = function() { asc_docs_api.prototype._onEndPermissions = function() {
if (null !== this.licenseResult && this.isOnFirstConnectEnd) { if (null !== this.licenseResult && this.isOnFirstConnectEnd) {
var oResult = new window['Asc'].asc_CAscEditorPermissions(); var oResult = new window['Asc'].asc_CAscEditorPermissions();
oResult.asc_setCanLicense(this.licenseResult.res); oResult.asc_setCanLicense(g_oLicenseResult.Success === this.licenseResult.res);
oResult.asc_setCanBranding(g_oLicenseResult.Error !== this.licenseResult.res); // Для тех, у кого есть лицензия, branding доступен
this.asc_fireCallback('asc_onGetEditorPermissions', oResult); this.asc_fireCallback('asc_onGetEditorPermissions', oResult);
} }
}; };
\ No newline at end of file
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