The license token is used to check permission of software usage, and maintains the list in table t_licensetokens. More...
#include <bpslicensetoken.h>
Public Member Functions | |
| BpsLicenseToken (BpsDatastore *aDatastore, const QString &aLicenser, const QString &aLicenseGroup, const QString &aProgram, QObject *aParent=0) | |
| Create a new license token. | |
| virtual int | checkLicense (QDate *aExpires=0) |
| This method can be overloaded to implement a check for license validity. | |
| void | clear () |
| Clears the token and releases the license for re-use. | |
| BpsDatastore * | datastore () const |
| bool | isValid () const |
| QString | licenseGroup () const |
| QString | licenser () const |
| QString | program () const |
| void | update () |
| Makes sure the token is still present and unmodified in table t_licensetokens, and updates the timestamp. | |
| QDate | validate () |
| Checks the license token. | |
| virtual | ~BpsLicenseToken () |
| The destructor clears the token and releases the license for re-use. | |
The license token is used to check permission of software usage, and maintains the list in table t_licensetokens.
It is good practice for all applications to create and validate, and regularly update license tokens, even if usage of a license group is free and unlimited. That way all activities of the system can be monitored.
A licenser who provides licensed modules can derive a class of BpsLicensToken and re-implement the checkLicense method to validate licenses with his private procedure. Licenses would usually be stored in the central system settings in the group Settings/Licenses/{LicenserName}.
| BpsLicenseToken::BpsLicenseToken | ( | BpsDatastore * | aDatastore, |
| const QString & | aLicenser, | ||
| const QString & | aLicenseGroup, | ||
| const QString & | aProgram, | ||
| QObject * | aParent = 0 |
||
| ) |
Create a new license token.
The token is initially invalid and needs to be validated before becoming effective.
| [in] | aDatastore | The current datastore connection. Should be connected and checked in. |
| [in] | aLicenser | Name of the software license granter. |
| [in] | aLicenseGroup | Name of the license group. |
| [in] | aProgram | Name of the program. |
| [in] | aParent | The parent object. |
| virtual int BpsLicenseToken::checkLicense | ( | QDate * | aExpires = 0 | ) | [virtual] |
This method can be overloaded to implement a check for license validity.
The default implementation does not check anything but returns -1 in any case.
| [out] | aExpires | Date when the licenses will expire. Only used when number of valid licenses is not 0. |
| BpsDatastore* BpsLicenseToken::datastore | ( | ) | const |
| bool BpsLicenseToken::isValid | ( | ) | const |
| QString BpsLicenseToken::licenseGroup | ( | ) | const |
| QString BpsLicenseToken::licenser | ( | ) | const |
| QString BpsLicenseToken::program | ( | ) | const |
| void BpsLicenseToken::update | ( | ) |
Makes sure the token is still present and unmodified in table t_licensetokens, and updates the timestamp.
This method should be called regularly by the application.
| Throws | BpsException when no success. |
| QDate BpsLicenseToken::validate | ( | ) |
Checks the license token.
This is the first action to do after creating the new token.
| Throws | BpsException when validation fails. |