From 229a8b4c23ff6cc73bd7834a390deb73fde4661c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Tue, 28 Jul 2009 12:49:53 +0000 Subject: [PATCH] Work on License Manager git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@6650 383ad7c9-94d9-4d36-a494-682f7c89f535 --- LicenseManager/LicenseManager.cc | 24 +++++++++++++++++++++- LicenseManager/LicenseManager.hh | 35 ++++++++++++++++++++++++++++---- 2 files changed, 54 insertions(+), 5 deletions(-) diff --git a/LicenseManager/LicenseManager.cc b/LicenseManager/LicenseManager.cc index 9ea84cc2..da3befbf 100644 --- a/LicenseManager/LicenseManager.cc +++ b/LicenseManager/LicenseManager.cc @@ -227,24 +227,46 @@ bool LicenseManager::authenticate() { std::cerr << "Core Hash : " << coreHash.toStdString() << std::endl; std::cerr << "Plugin Hash : " << pluginHash.toStdString() << std::endl; + QString mac; // Get all Network Interfaces QList interfaces = QNetworkInterface::allInterfaces(); foreach ( QNetworkInterface interface, interfaces ) { std::cerr << "Name : " << interface.name().toStdString() << std::endl; std::cerr << "Found Interface : " << interface.hardwareAddress().toStdString() << std::endl; + mac = mac + interface.hardwareAddress().remove(":"); } + QString macHash = QCryptographicHash::hash ( mac.toAscii() , QCryptographicHash::Sha1 ).toHex(); std::cerr << "CPUID Supported : " << CpuIDSupported() << std::endl; std::cerr << "GenuineIntel : " << GenuineIntel() << std::endl; + + QString saltPre; + ADD_SALT_PRE(saltPre); + + QString saltPost; + ADD_SALT_POST(saltPost); + + QString key = coreHash + saltPre + pluginHash + saltPost + macHash; + + std::cerr << "Key is: " << key.toStdString() << std::endl; + if ( authenticated_ ) std::cerr << "Authentication succcessfull" << std::endl; else { - QMessageBox::warning ( 0, "Plugin License check failed", "License check for plugin has failed. Please get a valid License!" ); + QString text = "License check for plugin has failed.\n"; + text += "Please get a valid License!\n"; + text += "Send the following Information to contact@openflipper.org:\n"; + text += pluginFileName() +"\n"; + text += coreHash +"\n"; + text += pluginHash +"\n"; + text += macHash +"\n"; + QMessageBox::warning ( 0, "Plugin License check failed", text ); std::cerr << "Authentication failed" << std::endl; + authenticated_ = false; } // authenticated_ = true; diff --git a/LicenseManager/LicenseManager.hh b/LicenseManager/LicenseManager.hh index 6f2fea7a..114e7d22 100644 --- a/LicenseManager/LicenseManager.hh +++ b/LicenseManager/LicenseManager.hh @@ -44,7 +44,12 @@ #ifndef LICENSEMANAGER_HH #define LICENSEMANAGER_HH -#include "OpenFlipper/BasePlugin/SecurityInterface.hh" +#include + +/** 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 { @@ -58,21 +63,43 @@ Q_INTERFACES(SecurityInterface) public : + /** This function is overloaded and will not allow to unblock signals + if the plugin is not authenticated + */ void blockSignals( bool _state); + + /** Return if the plugin has successfully passed the authentication + */ bool authenticated(); - virtual QString name() = 0; - public slots: + /** Call this function for plugin authentication. If it returns true, + the authentication has been successfull. Otherwise the core will + stop loading the plugin. Additionally the plugin will make itself + unusable by not allowing any signal slot connections. + */ bool authenticate(); private: - bool authenticated_; + /** This is used to get the plugins Name from derived classes + The glugin name is the usual name of the glugin + */ + virtual QString name() = 0; + /** This function is special to the LicenseManager. It is used to + find the plugin when checking its hash value + */ virtual QString pluginFileName(); + /// This flag is true if authentication was successfull + bool authenticated_; + protected : + /** This function is overloaded in the security interface. If the + plugin is not authenticated, all connections will be automatically + removed again. + */ void connectNotify ( const char * /*signal*/ ); }; -- GitLab