logic: Licenses with seats

This commit is contained in:
Andreas Stallinger
2017-02-27 09:53:39 +01:00
parent 0423a86a63
commit eac48596ad
7 changed files with 117 additions and 33 deletions
+29 -2
View File
@@ -124,6 +124,21 @@ std::string License::getLicenseTypeLine() const
}
}
uint License::getSeats() const
{
std::string licenseTypeLine = getLicenseTypeLine();
std::size_t found = licenseTypeLine.find(":");
if (found != std::string::npos)
{
// +2 (": ")
std::stringstream seatsStream(licenseTypeLine.substr(found+2));
int seats;
seatsStream>>seats;
return seats;
}
return 0;
}
int License::getTimeLeft() const
{
const std::string testText = "Test License - valid till ";
@@ -156,10 +171,17 @@ int License::getTimeLeft() const
void License::create(
const std::string& user, const std::string& version,
Botan::RSA_PrivateKey* privateKey, const std::string& type)
Botan::RSA_PrivateKey* privateKey, const std::string& type, const uint seats)
{
m_version = version;
createMessage(user, version, type);
if (seats > 0)
{
createMessage(user, version, type + ": " + std::to_string(seats) + " seats");
}
else
{
createMessage(user, version, type);
}
//encode message
Botan::PK_Signer signer(*privateKey, *(m_rng.get()), "EMSA4(SHA-256)");
@@ -522,6 +544,11 @@ bool License::loadFromEncodedString(const std::string& encodedLicense, const std
return true;
}
std::string License::getHashedLicense() const
{
return getEncodeKey("fakeKey");
}
std::string License::getEncodeKey(const std::string applicationLocation) const
{
if (applicationLocation.size() <= 0)