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

Добавил проверку вхождения пользователя в лицензию (CheckUserInLicense)

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@64956 954022d7-b5bf-4e40-9824-e11837661b57
parent 87d194b2
......@@ -19,17 +19,35 @@ function CheckLicense(licenseUrl, userId, callback) {
salt: ""
}, CryptoJS.enc.Hex.parse(g_sAESKey), {iv: CryptoJS.enc.Hex.parse(g_sAESKey.slice(0, g_sAESKey.length / 2))});
var sJson = decrypted.toString(CryptoJS.enc.Utf8);
var oJson = JSON.parse(sJson);
var oLicense = JSON.parse(sJson);
var hSig = oJson.signature;
delete oJson.signature;
var hSig = oLicense.signature;
delete oLicense.signature;
var x509 = new X509();
x509.readCertPEM(g_sPublicRSAKey);
var isValid = x509.subjectPublicKeyRSA.verifyString(JSON.stringify(oJson), hSig);
callback(false, isValid);
var isValid = x509.subjectPublicKeyRSA.verifyString(JSON.stringify(oLicense), hSig);
callback(false, isValid ? CheckUserInLicense(userId, oLicense) : false);
} catch(e) {
callback(true, false);
}
});
}
/**
*
* @param userId
* @param oLicense
* @returns {boolean}
*/
function CheckUserInLicense(userId, oLicense) {
var res = false;
try {
if (oLicense.users && oLicense.users.hasOwnProperty(userId)) {
var endDate = new Date(oLicense.users[userId]);
res = endDate >= new Date();
}
} catch(e) {
res = false;
}
return res;
}
\ 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