Commit e11ebf97 authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

add companyId

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@65081 954022d7-b5bf-4e40-9824-e11837661b57
parent 62247685
...@@ -4,7 +4,7 @@ var g_sLicenseDefaultUrl = "/license"; ...@@ -4,7 +4,7 @@ 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-----';
var g_sAESKey = '7f3d2338390c1e3e154c21005f51010e065b0f1a1e101600202473150c022a11'; var g_sAESKey = '7f3d2338390c1e3e154c21005f51010e065b0f1a1e101600202473150c022a11';
function CheckLicense(licenseUrl, userId, callback) { function CheckLicense(licenseUrl, companyId, userId, callback) {
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) {
...@@ -27,7 +27,7 @@ function CheckLicense(licenseUrl, userId, callback) { ...@@ -27,7 +27,7 @@ function CheckLicense(licenseUrl, userId, callback) {
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(userId, oLicense) : false); callback(false, isValid ? CheckUserInLicense(companyId, userId, oLicense) : false);
} catch(e) { } catch(e) {
callback(true, false); callback(true, false);
} }
...@@ -35,17 +35,18 @@ function CheckLicense(licenseUrl, userId, callback) { ...@@ -35,17 +35,18 @@ function CheckLicense(licenseUrl, userId, callback) {
} }
/** /**
* *
* @param companyId
* @param userId * @param userId
* @param oLicense * @param oLicense
* @returns {boolean} * @returns {boolean}
*/ */
function CheckUserInLicense(userId, oLicense) { function CheckUserInLicense(companyId, userId, oLicense) {
var res = false; var res = false;
var superuser = 'onlyoffice'; var superuser = 'onlyoffice';
try { try {
if (oLicense.users) { if (oLicense.users) {
if (oLicense.users.hasOwnProperty(userId) || (superuser === oLicense['company_id'] && if ((companyId === oLicense['company_id'] && oLicense.users.hasOwnProperty(userId)) ||
oLicense.users.hasOwnProperty(userId = superuser))) { (superuser === oLicense['company_id'] && oLicense.users.hasOwnProperty(userId = superuser))) {
var endDate = new Date(oLicense.users[userId]['end_date']); var endDate = new Date(oLicense.users[userId]['end_date']);
res = endDate >= new Date(); res = endDate >= new Date();
} }
......
...@@ -24,10 +24,10 @@ ...@@ -24,10 +24,10 @@
} }
}; };
asc['spreadsheet_api'].prototype.asc_getEditorPermissions = function(licenseUrl) { asc['spreadsheet_api'].prototype.asc_getEditorPermissions = function(licenseUrl, companyId) {
var t = this; var t = this;
if (this.DocInfo && this.DocInfo["Id"] && this.DocInfo["Url"]) { if (this.DocInfo && this.DocInfo["Id"] && this.DocInfo["Url"]) {
CheckLicense(licenseUrl, this.DocInfo["UserId"], function(err, res) { CheckLicense(licenseUrl, companyId, this.DocInfo["UserId"], function(err, res) {
t._onCheckLicenseEnd(err, res); t._onCheckLicenseEnd(err, res);
}); });
} else { } else {
......
...@@ -16,10 +16,10 @@ asc_docs_api.prototype.asc_addComment = function(AscCommentData) { ...@@ -16,10 +16,10 @@ asc_docs_api.prototype.asc_addComment = function(AscCommentData) {
return Comment.Get_Id(); return Comment.Get_Id();
} }
}; };
asc_docs_api.prototype.asc_getEditorPermissions = function(licenseUrl) { asc_docs_api.prototype.asc_getEditorPermissions = function(licenseUrl, companyId) {
var t = this; var t = this;
if (this.DocInfo && this.DocInfo.get_Id()) { if (this.DocInfo && this.DocInfo.get_Id()) {
CheckLicense(licenseUrl, this.DocInfo.get_UserId(), function(err, res) { CheckLicense(licenseUrl, companyId, this.DocInfo.get_UserId(), function(err, res) {
t._onCheckLicenseEnd(err, res); t._onCheckLicenseEnd(err, res);
}); });
} else { } else {
......
...@@ -23,10 +23,10 @@ asc_docs_api.prototype.asc_addComment = function(AscCommentData) { ...@@ -23,10 +23,10 @@ asc_docs_api.prototype.asc_addComment = function(AscCommentData) {
return Comment.Get_Id(); return Comment.Get_Id();
} }
}; };
asc_docs_api.prototype.asc_getEditorPermissions = function(licenseUrl) { asc_docs_api.prototype.asc_getEditorPermissions = function(licenseUrl, companyId) {
var t = this; var t = this;
if (this.DocInfo && this.DocInfo.get_Id()) { if (this.DocInfo && this.DocInfo.get_Id()) {
CheckLicense(licenseUrl, this.DocInfo.get_UserId(), function(err, res) { CheckLicense(licenseUrl, companyId, this.DocInfo.get_UserId(), function(err, res) {
t._onCheckLicenseEnd(err, res); t._onCheckLicenseEnd(err, res);
}); });
} else { } else {
......
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