Commit 1426fe0c authored by Jan Möbius's avatar Jan Möbius

Changed license manager (did not work on windows)

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@10523 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 10e6c7b9
......@@ -66,7 +66,11 @@ class SecurityInterface {
SecurityInterface(){};
public slots:
bool authenticate();
/// Function starting the authentication process
bool authenticate();
/// If authenticate returns fals, this string will containe the license info
QString licenseError();
private :
bool authenticated();
......
......@@ -35,7 +35,7 @@
/*===========================================================================*\
* *
* $Revision$ *
* $LastChangedBy$ *
* $LastChangedBy$ *
* $Date$ *
* *
\*===========================================================================*/
......@@ -587,7 +587,11 @@ void Core::loadPlugin(QString filename, bool silent, QString& _licenseErrors, QO
emit log(LOGINFO,tr("Plugin uses security interface. Trying to authenticate against plugin ..."));
bool success = false;
QMetaObject::invokeMethod(plugin,"authenticate", Q_RETURN_ARG( bool , success ) , Q_ARG(QString&, _licenseErrors)) ;
QMetaObject::invokeMethod(plugin,"authenticate", Q_RETURN_ARG( bool , success ) ) ;
QString message = "";
QMetaObject::invokeMethod(plugin,"licenseError", Q_RETURN_ARG( QString , message ) ) ;
_licenseErrors = message;
if ( success )
emit log(LOGINFO,tr("... ok. Loading plugin "));
......
......@@ -182,11 +182,11 @@ void LicenseManager::blockSignals( bool _state) {
}
// Plugin authentication function.
bool LicenseManager::authenticate(QString& _authstring) {
bool LicenseManager::authenticate() {
// Construct license string (will be cleaned up if license valid)
_authstring = "==\n";
_authstring += "PluginName: " + pluginFileName() + "\n";
authstring_ = "==\n";
authstring_ += "PluginName: " + pluginFileName() + "\n";
// ===============================================================================================
// Compute hash value of Core application binary
......@@ -282,24 +282,24 @@ bool LicenseManager::authenticate(QString& _authstring) {
QDate expiryDate = QDate::fromString(elements[4],Qt::ISODate);
if ( licenseHash != elements[5] ) {
_authstring += tr("License Error: The license file signature for plugin \"") + name() + tr("\" is invalid!\n\n");
authstring_ += tr("License Error: The license file signature for plugin \"") + name() + tr("\" is invalid!\n\n");
} else if ( elements[0] != pluginFileName() ) {
_authstring += tr("License Error: The license file contains plugin name\"") + elements[0] + tr("\" but this is plugin \"") + name() + "\"!\n\n";
authstring_ += tr("License Error: The license file contains plugin name\"") + elements[0] + tr("\" but this is plugin \"") + name() + "\"!\n\n";
} else if ( elements[1] != coreHash ) {
_authstring += tr("License Error: The license file for plugin \"") + name() + tr("\" is invalid for the currently running OpenFlipper Core!\n\n");
authstring_ += tr("License Error: The license file for plugin \"") + name() + tr("\" is invalid for the currently running OpenFlipper Core!\n\n");
} else if ( elements[2] != pluginHash ) {
_authstring += tr("License Error: The plugin \"") + name() + tr("\" is a different version than specified in license file!\n\n");
authstring_ += tr("License Error: The plugin \"") + name() + tr("\" is a different version than specified in license file!\n\n");
} else if ( elements[3] != macHash ) {
_authstring += "License Error: The plugin \"" + name() + "\" is not allowed to run on the current system (Changed Hardware?)!\n\n";
authstring_ += "License Error: The plugin \"" + name() + "\" is not allowed to run on the current system (Changed Hardware?)!\n\n";
} else if ( currentDate > expiryDate ) {
_authstring += tr("License Error: The license for plugin \"") + name() + tr("\" has expired on ") + elements[1] + "!\n\n";
authstring_ += tr("License Error: The license for plugin \"") + name() + tr("\" has expired on ") + elements[1] + "!\n\n";
} else {
authenticated_ = true;
}
// Clean it on success
if ( authenticated_ )
_authstring = "";
authstring_ = "";
}
}
......@@ -307,18 +307,18 @@ bool LicenseManager::authenticate(QString& _authstring) {
if ( authenticated_ ) {
blockSignals(false);
} else {
_authstring += tr("Message: License check for plugin failed.\n");
_authstring += tr("Message: Please get a valid License!\n");
_authstring += tr("Message: Send the following Information to \n");
_authstring += tr("Contact mail: ") + CONTACTMAIL + "\n\n";
_authstring += pluginFileName() +"\n";
_authstring += coreHash +"\n";
_authstring += pluginHash +"\n";
_authstring += macHash +"\n";
authstring_ += tr("Message: License check for plugin failed.\n");
authstring_ += tr("Message: Please get a valid License!\n");
authstring_ += tr("Message: Send the following Information to \n");
authstring_ += tr("Contact mail: ") + CONTACTMAIL + "\n\n";
authstring_ += pluginFileName() +"\n";
authstring_ += coreHash +"\n";
authstring_ += pluginHash +"\n";
authstring_ += macHash +"\n";
QString keyRequest = saltPre + pluginFileName() + coreHash+pluginHash+macHash +saltPost;
QString requestSig = QCryptographicHash::hash ( keyRequest.toAscii() , QCryptographicHash::Sha1 ).toHex();
_authstring += requestSig + "\n";
authstring_ += requestSig + "\n";
authenticated_ = false;
}
......@@ -326,6 +326,10 @@ bool LicenseManager::authenticate(QString& _authstring) {
return authenticated_;
}
QString LicenseManager::licenseError() {
return authstring_;
}
bool LicenseManager::authenticated() {
// Function to check if the plugin is authenticated
return authenticated_;
......
......@@ -56,13 +56,14 @@
#define LICENSEMANAGER_HH
#include <OpenFlipper/BasePlugin/SecurityInterface.hh>
#include <OpenFlipper/common/GlobalDefines.hh>
/** The salt file has to be provided for each plugin. It can be the same
for all plugins. See example for details on how this file has to be setup
*/
#include "salt.hh"
class LicenseManager : public QObject, SecurityInterface {
class DLLEXPORT LicenseManager : public QObject, SecurityInterface {
Q_OBJECT
Q_INTERFACES(SecurityInterface)
......@@ -91,7 +92,11 @@ Q_INTERFACES(SecurityInterface)
@param _authstring String returned, containing hashed license request, if something went wrong or no valid license available.
*/
bool authenticate(QString& _authstring);
bool authenticate();
/** if authenticate returns false, this string will containe the license information
*/
QString licenseError();
private:
/** This is used to get the plugins Name from derived classes
......@@ -106,6 +111,9 @@ Q_INTERFACES(SecurityInterface)
/// This flag is true if authentication was successfull
bool authenticated_;
/// License information string
QString authstring_;
protected :
......
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