| | |
| | | * In the pull request comment reference the issue you want to fix. |
| | | |
| | | ##### Don't |
| | | * Don't reformat the code following your personal likes, it introduce a lot of "noise" and makes very hard to merge. Use the clang-format style provided at the base of the project. |
| | | * Very large pull requests with few comments, no corresponding issue explaining what's it about will probably be rejected. |
| | | * We understand that the project is still in beta stage, however we would like to discuss it with you before we take project changing decision. Please contact the project maintainer at `contini.mailing[AT]gmail.com` if you have time and plan to do a large contribution. |
| | | * Even it it's in beta stage it's used ( _by some really courageous people!_ ) in production. We can't break current functionality, user established habits without documenting the change. |
| | | |
| | | - Don't reformat the code following your personal likes, it introduce a lot of "noise" and makes very hard to merge. Use the clang-format style provided at the base of the project. |
| | | - Very large pull requests with few comments, no corresponding issue explaining what's it about will probably be rejected. |
| | | - We understand that the project is still in beta stage, however we would like to discuss it with you before we take project changing decision. Please contact the project maintainer at `contini.mailing[AT]gmail.com` if you have time and plan to do a large contribution. |
| | | - Even it it's in beta stage it's used ( _by some really courageous people!_ ) in production. We can't break current functionality, user established habits without documenting the change. |
| | | |
| | |
| | | |
| | | ## Project Structure |
| | | The software is made by 2 main sub-components: |
| | | - a C++ library with a nice C api, `licensecc` with minimal (or no) external dependencies (the part you have to integrate in your software) that is the project you're currently in. |
| | | - a license generator lcc-license-generator `lcc` for customizing the library and generate the licenses. |
| | | - a C++ library with a nice C api, `licensecc` with minimal (or no) external dependencies (the part you have to integrate in your software) that is the project you're currently in. |
| | | - a license generator lcc-license-generator `lcc` for customizing the library and generate the licenses. |
| | | |
| | | The following modules are planned... |
| | | - a license [backoffice](../../issues/7) in php (in order to handle multiple licenses). |
| | | - a license debugger to be sent to the final customer when there are licensing problems. |
| | | - a [log descriptor](../../issues/8) in order to decrypt logs generated by the license system. |
| | | - a license [backoffice](../../issues/7) in php (in order to handle multiple licenses). |
| | | - a license debugger to be sent to the final customer when there are licensing problems. |
| | | - a [log descriptor](../../issues/8) in order to decrypt logs generated by the license system. |
| | | |
| | | # How to build |
| | | Below an overview of the basic build procedure, you can find detailed instructions for [linux](https://github.com/open-license-manager/open-license-manager/wiki/Build-the-library) or [windows](https://github.com/open-license-manager/open-license-manager/wiki/Build-the-library-windows) in the wiki. |
| | | |
| | | ## Prerequisites |
| | | - Operating system: Linux(Ubuntu, CentOS), Windows |
| | | - compilers : GCC (Linux) MINGW (Linux cross compile for Windows), MINGW or MSVC (Windows) |
| | | - tools : cmake(>3.6), git, make/ninja(linux) |
| | | - libs : If target is Linux Openssl is required. Windows depends only on system libraries. Boost is necessary to build license generator and to run the tests but it's NOT a dependency of the final `licensecc` library. |
| | | - Operating system: Linux(Ubuntu, CentOS), Windows |
| | | - compilers : GCC (Linux) MINGW (Linux cross compile for Windows), MINGW or MSVC (Windows) |
| | | - tools : cmake(>3.6), git, make/ninja(linux) |
| | | - libs : If target is Linux Openssl is required. Windows depends only on system libraries. Boost is necessary to build license generator and to run the tests but it's NOT a dependency of the final `licensecc` library. |
| | | |
| | | For a complete list of dependencies and supported environments see [the wiki](https://github.com/open-license-manager/open-license-manager/wiki/Dependencies) |
| | | |
| | |
| | | cd build |
| | | ``` |
| | | |
| | | ## on Linux |
| | | ## build on Linux |
| | | |
| | | ```console |
| | | cmake .. -DCMAKE_INSTALL_PREFIX=../install |
| | |
| | | make install |
| | | ``` |
| | | |
| | | ## on Windows (with MSVC 2015) |
| | | ## build on Windows (with MSVC 2015) |
| | | |
| | | ```console |
| | | cmake .. -G "Visual Studio 14 2015 Win64" -DBOOST_ROOT="{Folder where boost is}" -DCMAKE_INSTALL_PREFIX=../install |
| | |
| | | ## How to use |
| | | |
| | | The [examples](https://github.com/open-license-manager/examples) repository that shows various ways to integrate `open-licence-manager` into your project. |
| | | |
| | | |
| | | ## How to contribute |
| | | The project is not dead but we take our time to answer. The best interaction you can have with us is through the issue system. Have a look to the [contribution guidelines](CONTRIBUTING.md) |
| | |
| | | * |
| | | */ |
| | | |
| | | #include <cctype> //toupper |
| | | #include <cctype> //toupper |
| | | #include <iostream> |
| | | #include <string> |
| | | #include <sstream> |
| | |
| | | #include "StringUtils.h" |
| | | |
| | | #ifdef _WIN32 |
| | | #include <time.h> //mktime under windows |
| | | #include <time.h> //mktime under windows |
| | | #endif |
| | | |
| | | namespace license { |
| | |
| | | |
| | | string toupper_copy(const string &lowercase) { |
| | | string cp(lowercase); |
| | | std::transform(cp.begin(), cp.end(), cp.begin(), (int (*)(int)) toupper); |
| | | std::transform(cp.begin(), cp.end(), cp.begin(), (int (*)(int))toupper); |
| | | return cp; |
| | | } |
| | | |
| | | time_t seconds_from_epoch(const char *timeString) { |
| | | time_t seconds_from_epoch(const string &timeString) { |
| | | int year, month, day; |
| | | tm tm; |
| | | if (strlen(timeString) == 8) { |
| | | const int nfield = sscanf(timeString, "%4d%2d%2d", &year, &month, &day); |
| | | if (timeString.size() == 8) { |
| | | const int nfield = sscanf(timeString.c_str(), "%4d%2d%2d", &year, &month, &day); |
| | | if (nfield != 3) { |
| | | throw invalid_argument("Date not recognized"); |
| | | } |
| | | } else if (strlen(timeString) == 10) { |
| | | const int nfield = sscanf(timeString, "%4d-%2d-%2d", &year, &month, |
| | | &day); |
| | | } else if (timeString.size() == 10) { |
| | | const int nfield = sscanf(timeString.c_str(), "%4d-%2d-%2d", &year, &month, &day); |
| | | if (nfield != 3) { |
| | | const int nfield = sscanf(timeString, "%4d/%2d/%2d", &year, &month, |
| | | &day); |
| | | const int nfield = sscanf(timeString.c_str(), "%4d/%2d/%2d", &year, &month, &day); |
| | | if (nfield != 3) { |
| | | throw invalid_argument("Date not recognized"); |
| | | throw invalid_argument("Date [" + timeString + "] not recognized"); |
| | | } |
| | | } |
| | | } else { |
| | | throw invalid_argument("Date not recognized"); |
| | | throw invalid_argument("Date [" + timeString + "] not recognized"); |
| | | } |
| | | tm.tm_isdst = -1; |
| | | tm.tm_year = year - 1900; |
| | |
| | | return mktime(&tm); |
| | | } |
| | | |
| | | const vector<string> split_string(const string &licensePositions, |
| | | char splitchar) { |
| | | const vector<string> split_string(const string &licensePositions, char splitchar) { |
| | | std::stringstream streamToSplit(licensePositions); |
| | | std::string segment; |
| | | std::vector<string> seglist; |
| | |
| | | } |
| | | |
| | | const static regex iniSection("\\[.*?\\]"); |
| | | const static regex b64( |
| | | "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$"); |
| | | const static regex b64("^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$"); |
| | | |
| | | FILE_FORMAT identify_format(const string &license) { |
| | | FILE_FORMAT result = UNKNOWN; |
| | |
| | | return result; |
| | | } |
| | | |
| | | // strnln_s is not well supported and strlen is marked unsafe.. |
| | | size_t mstrnlen_s(const char *szptr, size_t maxsize) { |
| | | if (szptr == nullptr) { |
| | | return 0; |
| | | } |
| | | size_t count = 0; |
| | | while (*szptr++ && maxsize--) { |
| | | count++; |
| | | } |
| | | return count; |
| | | } |
| | | |
| | | } /* namespace license */ |
| | |
| | | |
| | | std::string toupper_copy(const std::string& lowercase); |
| | | |
| | | time_t seconds_from_epoch(const char* s); |
| | | time_t seconds_from_epoch(const std::string& timeString); |
| | | |
| | | /** |
| | | * Split a string on a given character |
| | | */ |
| | | const std::vector<std::string> split_string(const std::string& stringToBeSplit, const char splitchar); |
| | | |
| | | // strnln_s is not well supported and strlen is marked unsafe.. |
| | | size_t mstrnlen_s(const char* szptr, size_t maxsize); |
| | | |
| | | typedef enum { |
| | | INI, BASE64, UNKNOWN |
| | | } FILE_FORMAT; |
| | |
| | | // Copyright : BSD |
| | | //============================================================================ |
| | | |
| | | #define __STDC_WANT_LIB_EXT1__ 1 |
| | | #include <fstream> |
| | | #include <stdio.h> |
| | | #include <string.h> |
| | | #include <stdlib.h> |
| | | #include <cstring> |
| | | #include <iostream> |
| | |
| | | #include <licensecc_properties.h> |
| | | |
| | | #include "limits/license_verifier.hpp" |
| | | #include "base/StringUtils.h" |
| | | #include "LicenseReader.hpp" |
| | | #include "pc-identifiers.h" |
| | | |
| | |
| | | const license::LicenseReader lr = license::LicenseReader(licenseLocation); |
| | | vector<license::FullLicenseInfo> licenses; |
| | | string project; |
| | | if (callerInformation != nullptr && strlen(callerInformation->project_name) > 0) { |
| | | project = string(callerInformation->project_name); |
| | | size_t str_size; |
| | | if (callerInformation != nullptr && |
| | | (str_size = license::mstrnlen_s(callerInformation->project_name, sizeof callerInformation->project_name)) > 0) { |
| | | project = string(callerInformation->project_name, str_size); |
| | | } else { |
| | | project = string(LCC_PROJECT_NAME); |
| | | } |
| | |
| | | const time_t now = time(nullptr); |
| | | auto expiry = licInfo.m_limits.find(PARAM_EXPIRY_DATE); |
| | | if (expiry != licInfo.m_limits.end()) { |
| | | if (seconds_from_epoch(expiry->second.c_str()) < now) { |
| | | if (seconds_from_epoch(expiry->second) < now) { |
| | | /* |
| | | eventRegistryOut.addEvent(PRODUCT_EXPIRED, source.c_str(), |
| | | string("Expired on: " + this->to_date).c_str());*/ |
| | |
| | | } |
| | | auto start_date = licInfo.m_limits.find(PARAM_BEGIN_DATE); |
| | | if (is_valid && start_date != licInfo.m_limits.end()) { |
| | | if (seconds_from_epoch(start_date->second.c_str()) > now) { |
| | | if (seconds_from_epoch(start_date->second) > now) { |
| | | /*eventRegistryOut.addEvent(PRODUCT_EXPIRED, source.c_str(), |
| | | string("Valid from " + this->from_date).c_str());*/ |
| | | m_event_registry.addEvent(PRODUCT_EXPIRED, licInfo.source.c_str(), |
| | |
| | | if (expiry != fullLicInfo.m_limits.end()) { |
| | | strncpy(info.expiry_date, expiry->second.c_str(), sizeof(info.expiry_date)); |
| | | info.has_expiry = true; |
| | | const double secs = difftime(seconds_from_epoch(expiry->second.c_str()), time(nullptr)); |
| | | const double secs = difftime(seconds_from_epoch(expiry->second), time(nullptr)); |
| | | info.days_left = max((int)round(secs / (60 * 60 * 24)), 0); |
| | | } else { |
| | | info.has_expiry = false; |
| | |
| | | |
| | | static DWORD hashData(BCRYPT_HASH_HANDLE& hHash, const string& data, PBYTE pbHash, DWORD hashDataLenght) { |
| | | DWORD status; |
| | | bool success = false; |
| | | if (NT_SUCCESS(status = BCryptHashData(hHash, (BYTE*)data.c_str(), (ULONG)data.length(), 0))) { |
| | | status = BCryptFinishHash(hHash, pbHash, hashDataLenght, 0); |
| | | } |