Commit 82cebfb0 authored by Sergey.Luzyanin's avatar Sergey.Luzyanin

Правки в проверке лицензии

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@65307 954022d7-b5bf-4e40-9824-e11837661b57
parent ed323cf6
......@@ -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_sAESKey = '7f3d2338390c1e3e154c21005f51010e065b0f1a1e101600202473150c022a11';
function CheckLicense(licenseUrl, customerId, userId, userName, callback) {
function CheckLicense(licenseUrl, customerId, userId, userFirstName, userLastName, callback) {
licenseUrl = licenseUrl ? licenseUrl : g_sLicenseDefaultUrl;
g_fGetJSZipUtils().getBinaryContent(licenseUrl, function(err, data) {
if (err) {
......@@ -27,7 +27,7 @@ function CheckLicense(licenseUrl, customerId, userId, userName, callback) {
var x509 = new X509();
x509.readCertPEM(g_sPublicRSAKey);
var isValid = x509.subjectPublicKeyRSA.verifyString(JSON.stringify(oLicense), hSig);
callback(false, isValid ? CheckUserInLicense(customerId, userId, userName, oLicense) : false);
callback(false, isValid ? CheckUserInLicense(customerId, userId, userFirstName, userLastName, oLicense) : false);
} catch(e) {
callback(true, false);
}
......@@ -40,11 +40,13 @@ function CheckLicense(licenseUrl, customerId, userId, userName, callback) {
* @param oLicense
* @returns {boolean}
*/
function CheckUserInLicense(customerId, userId, userName, oLicense) {
function CheckUserInLicense(customerId, userId, userFirstName, userLastName, oLicense) {
var res = false;
var superuser = 'onlyoffice';
try {
if (oLicense.users) {
var userName = (typeof userFirstName === "string" ? userFirstName : "") + (typeof userLastName === "string" ? userLastName : "");
var sUserHash = CryptoJS.SHA256(userId + userName).toString(CryptoJS.enc.Hex).toLowerCase();
if ((customerId === oLicense['customer_id'] && oLicense.users.hasOwnProperty(sUserHash)) ||
(superuser === oLicense['customer_id'] && oLicense.users.hasOwnProperty(sUserHash = superuser))) {
......
......@@ -2744,25 +2744,12 @@
asc_CDocInfo.prototype.get_UserName = asc_CDocInfo.prototype.asc_getUserName = function(){
return (this.UserInfo ? this.UserInfo.get_FullName() : null );
};
asc_CDocInfo.prototype.get_UserName2 = asc_CDocInfo.prototype.asc_getUserName2 = function(){
if(!this.UserInfo)
{
return "";
}
var sFirstName = this.UserInfo.asc_getFirstName();
var sLastName = this.UserInfo.asc_getLastName();
return (typeof sFirstName === "string" ? sFirstName : "") + (typeof sLastName === "string" ? sLastName : "");
};
asc_CDocInfo.prototype.get_Options = asc_CDocInfo.prototype.asc_getOptions = function(){return this.Options;};
asc_CDocInfo.prototype.put_Options = asc_CDocInfo.prototype.asc_putOptions = function(v){this.Options = v;};
asc_CDocInfo.prototype.get_CallbackUrl = asc_CDocInfo.prototype.asc_getCallbackUrl = function(){return this.CallbackUrl;};
asc_CDocInfo.prototype.put_CallbackUrl = asc_CDocInfo.prototype.asc_putCallbackUrl = function(v){this.CallbackUrl = v;};
asc_CDocInfo.prototype.get_TemplateReplacement = asc_CDocInfo.prototype.asc_getTemplateReplacement = function(){return this.TemplateReplacement;};
asc_CDocInfo.prototype.put_TemplateReplacement = asc_CDocInfo.prototype.asc_putTemplateReplacement = function(v){this.TemplateReplacement = v;};
asc_CDocInfo.prototype.get_UserFirstName = asc_CDocInfo.prototype.asc_getUserFirstName = function(){return this.UserFirstName;};
asc_CDocInfo.prototype.put_UserFirstName = asc_CDocInfo.prototype.asc_putUserFirstName = function(v){this.UserFirstName = v;};
asc_CDocInfo.prototype.get_UserLastName = asc_CDocInfo.prototype.asc_getUserLastName = function(){return this.UserLastName;};
asc_CDocInfo.prototype.put_UserLastName = asc_CDocInfo.prototype.asc_putUserLastName = function(v){this.UserLastName = v;};
asc_CDocInfo.prototype.get_ChartEditor = asc_CDocInfo.prototype.asc_getChartEditor = function(){return this.ChartEditor;};
asc_CDocInfo.prototype.put_ChartEditor = asc_CDocInfo.prototype.asc_putChartEditor = function(v){this.ChartEditor = v;};
asc_CDocInfo.prototype.get_UserInfo = asc_CDocInfo.prototype.asc_getUserInfo = function(){return this.UserInfo;};
......@@ -2785,19 +2772,13 @@
prot["get_OfflineApp"] = prot["asc_getOfflineApp"] = prot.asc_getOfflineApp;
prot["put_OfflineApp"] = prot["asc_putOfflineApp"] = prot.asc_putOfflineApp;
prot["get_UserId"] = prot["asc_getUserId"] = prot.asc_getUserId;
prot["put_UserId"] = prot["asc_putUserId"] = prot.asc_putUserId;
prot["get_UserName"] = prot["asc_getUserName"] = prot.asc_getUserName;
prot["get_UserName2"] = prot["asc_getUserName2"] = prot.asc_getUserName2;
prot["get_Options"] = prot["asc_getOptions"] = prot.asc_getOptions;
prot["put_Options"] = prot["asc_putOptions"] = prot.asc_putOptions;
prot["get_CallbackUrl"] = prot["asc_getCallbackUrl"] = prot.asc_getCallbackUrl;
prot["put_CallbackUrl"] = prot["asc_putCallbackUrl"] = prot.asc_putCallbackUrl;
prot["get_TemplateReplacement"] = prot["asc_getTemplateReplacement"] = prot.asc_getTemplateReplacement;
prot["put_TemplateReplacement"] = prot["asc_putTemplateReplacement"] = prot.asc_putTemplateReplacement;
prot["get_UserFirstName"] = prot["asc_getUserFirstName"] = prot.asc_getUserFirstName;
prot["put_UserFirstName"] = prot["asc_putUserFirstName"] = prot.asc_putUserFirstName;
prot["get_UserLastName"] = prot["asc_getUserLastName"] = prot.asc_getUserLastName;
prot["put_UserLastName"] = prot["asc_putUserLastName"] = prot.asc_putUserLastName;
prot["get_ChartEditor"] = prot["asc_getChartEditor"] = prot.asc_getChartEditor;
prot["put_ChartEditor"] = prot["asc_putChartEditor"] = prot.asc_putChartEditor;
prot["get_UserInfo"] = prot["asc_getUserInfo"] = prot.asc_getUserInfo;
......
......@@ -27,7 +27,14 @@
asc['spreadsheet_api'].prototype.asc_getEditorPermissions = function(licenseUrl, customerId) {
var t = this;
if (this.DocInfo && this.DocInfo.asc_getId() && this.DocInfo.asc_getUrl()) {
CheckLicense(licenseUrl, customerId, this.DocInfo.asc_getUserId(), this.DocInfo.get_UserName2(), function(err, res) {
var sUserFirstName = null, sUserLastName = null;
var oUserInfo = this.DocInfo.get_UserInfo();
if(oUserInfo){
sUserFirstName = oUserInfo.get_FirstName();
sUserLastName = oUserInfo.get_LastName();
}
CheckLicense(licenseUrl, customerId, this.DocInfo.asc_getUserId(), sUserFirstName, sUserLastName, function(err, res) {
t._onCheckLicenseEnd(err, res);
});
} else {
......
......@@ -19,7 +19,14 @@ asc_docs_api.prototype.asc_addComment = function(AscCommentData) {
asc_docs_api.prototype.asc_getEditorPermissions = function(licenseUrl, customerId) {
var t = this;
if (this.DocInfo && this.DocInfo.get_Id()) {
CheckLicense(licenseUrl, customerId, this.DocInfo.get_UserId(), this.DocInfo.get_UserName2(), function(err, res) {
var sUserFirstName = null, sUserLastName = null;
var oUserInfo = this.DocInfo.get_UserInfo();
if(oUserInfo){
sUserFirstName = oUserInfo.get_FirstName();
sUserLastName = oUserInfo.get_LastName();
}
CheckLicense(licenseUrl, customerId, this.DocInfo.get_UserId(), sUserFirstName, sUserLastName, function(err, res) {
t._onCheckLicenseEnd(err, res);
});
} else {
......
......@@ -26,7 +26,14 @@ asc_docs_api.prototype.asc_addComment = function(AscCommentData) {
asc_docs_api.prototype.asc_getEditorPermissions = function(licenseUrl, customerId) {
var t = this;
if (this.DocInfo && this.DocInfo.get_Id()) {
CheckLicense(licenseUrl, customerId, this.DocInfo.get_UserId(), this.DocInfo.get_UserName2(), function(err, res) {
var sUserFirstName = null, sUserLastName = null;
var oUserInfo = this.DocInfo.get_UserInfo();
if(oUserInfo){
sUserFirstName = oUserInfo.get_FirstName();
sUserLastName = oUserInfo.get_LastName();
}
CheckLicense(licenseUrl, customerId, this.DocInfo.get_UserId(), sUserFirstName, sUserLastName, function(err, res) {
t._onCheckLicenseEnd(err, res);
});
} 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