Commit ffb56f1e authored by Jan Möbius's avatar Jan Möbius

More work on License manager

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@6679 383ad7c9-94d9-4d36-a494-682f7c89f535
parent c140f301
......@@ -297,11 +297,16 @@ bool LicenseManager::authenticate() {
else {
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 += "Send the following Information to " + CONTACTMAIL + "\n\n";
text += pluginFileName() +"\n";
text += coreHash +"\n";
text += pluginHash +"\n";
text += macHash +"\n";
QString keyRequest = saltPre + pluginFileName() + coreHash+pluginHash+macHash +saltPost;
QString requestSig = QCryptographicHash::hash ( keyRequest.toAscii() , QCryptographicHash::Sha1 ).toHex();
text += requestSig + "\n";
QMessageBox::warning ( 0, "Plugin License check failed", text );
std::cerr << "Authentication failed" << std::endl;
authenticated_ = false;
......
#include <qapplication.h>
#include <QtGui>
#include <QFile>
#include <QMessageBox>
#include <iostream>
#include <OpenFlipper/LicenseManager/keyGen/keygenWidget.hh>
#include "salt.hh"
int main(int argc, char **argv)
{
QApplication a( argc, argv );
if (argc == 2) {
std::cerr << " Call ./keygen <InfoFile> <Expiry date>" << std::endl;
std::cerr << "Date is of the form: YYYY-MM-DD" << std::endl;
exit(1);
}
// Get license information
QString name;
QString coreHash;
QString pluginHash;
QString macHash;
QString requestSig;
QFile file(argv[1]);
if (argc == 3) {
QFile file(argv[1]);
if (!file.open(QIODevice::ReadOnly|QIODevice::Text)) {
std::cerr << "Unable to open file " << std::endl;
return 1;
}
if (!file.open(QIODevice::ReadOnly|QIODevice::Text)) {
std::cerr << "Unable to open file " << std::endl;
std::cerr << " Call ./keygen <InfoFile> <Expiry date>" << std::endl;
std::cerr << "Date is of the form: YYYY-MM-DD" << std::endl;
return 1;
}
// Get license information
QString name = file.readLine().simplified();
QString coreHash = file.readLine().simplified();
QString pluginHash = file.readLine().simplified();
QString macHash = file.readLine().simplified();
// Get license information
name = file.readLine().simplified();
coreHash = file.readLine().simplified();
pluginHash = file.readLine().simplified();
macHash = file.readLine().simplified();
requestSig = file.readLine().simplified();
file.close();
file.close();
std::cerr << "Generating key for Plugin : " << name.toStdString() << std::endl;
std::cerr << "Core Hash : " << coreHash.toStdString() << std::endl;
std::cerr << "Plugin Hash : " << pluginHash.toStdString() << std::endl;
std::cerr << "macHash is : " << macHash.toStdString() << std::endl;
} else {
MainWindow* mainWindow = new MainWindow();
mainWindow->show();
a.exec();
QString inputData = mainWindow->textEdit_->toPlainText();
QStringList data = inputData.split('\n');
if ( data.size() != 5 ) {
std::cerr << "Request data has to containe 5 lines!" << std::endl;
exit(1);
}
// Clean strings
name = data[0].simplified();
coreHash = data[1].simplified();
pluginHash = data[2].simplified();
macHash = data[3].simplified();
requestSig = data[4].simplified();
}
std::cerr << "Generating key for Plugin : " << name.toStdString() << std::endl;
std::cerr << "Core Hash : " << coreHash.toStdString() << std::endl;
std::cerr << "Plugin Hash : " << pluginHash.toStdString() << std::endl;
std::cerr << "macHash is : " << macHash.toStdString() << std::endl;
std::cerr << "requestSignature is : " << requestSig.toStdString() << std::endl;
// Get the salts
QString saltPre;
ADD_SALT_PRE(saltPre);
QString saltPost;
ADD_SALT_POST(saltPost);
QString keyRequest = saltPre + name + coreHash + pluginHash + macHash + saltPost;
QString requestSigCheck = QCryptographicHash::hash ( keyRequest.toAscii() , QCryptographicHash::Sha1 ).toHex();
if ( requestSig != requestSigCheck ) {
QMessageBox::critical(0,"Signature of request invalid","The signature of the request is not valid");
return 1;
}
std::cerr << "Writing License file to output : " << name.toStdString() << std::endl;
QFile outFile(name + ".lic");
......@@ -56,11 +103,7 @@ int main(int argc, char **argv)
output << date.toString(Qt::ISODate) << "\n";
// Get the salts
QString saltPre;
ADD_SALT_PRE(saltPre);
QString saltPost;
ADD_SALT_POST(saltPost);
// Sign the license file
QString license = saltPre + name + coreHash + pluginHash + macHash + date.toString(Qt::ISODate) + saltPost;
......
#include <QtGui>
#include "keygenWidget.hh"
MainWindow::MainWindow()
{
textEdit_ = new QTextEdit(this);
setCentralWidget(textEdit_);
}
MainWindow::~MainWindow() {
}
#include <QtGui>
#include "keygenWidget.hh"
MainWindow::MainWindow()
{
textEdit_ = new QTextEdit();
setCentralWidget(textEdit_);
}
MainWindow::~MainWindow() {
}
#ifndef KEYGENWINDOW_HH
#define KEYGENWINDOW_HH
#include <QMainWindow>
#include <QTextEdit>
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow();
virtual ~MainWindow();
QTextEdit* textEdit_;
};
#endif // KEYGENWINDOW_HH
\ No newline at end of file
#ifndef KEYGENWINDOW_HH
#define KEYGENWINDOW_HH
#include <ui_keyWindow.hh>
#include <QTextEdit>
class MainWindow : public keyWindow
{
Q_OBJECT
public:
MainWindow();
virtual ~MainWindow();
QTextEdit* textEdit_;
// private slots:
// void open();
// bool save();
// private:
// void loadFile(const QString &fileName);
// bool saveFile(const QString &fileName);
};
#endif // KEYGENWINDOW_HH
\ No newline at end of file
......@@ -121,8 +121,16 @@ macro (_plugin_licensemanagement)
acg_append_files (keygen_hdr "*.hh" "${CMAKE_SOURCE_DIR}/OpenFlipper/LicenseManager/keyGen")
acg_append_files (keygen_src "*.cc" "${CMAKE_SOURCE_DIR}/OpenFlipper/LicenseManager/keyGen")
# acg_append_files (keygen_ui "*.ui" "${CMAKE_SOURCE_DIR}/OpenFlipper/LicenseManager/keyGen")
acg_qt4_automoc (keygen_moc ${keygen_hdr})
add_executable (Plugin-${plugin}-keygen ${keygen_hdr} ${keygen_src})
# acg_qt4_autouic (keygen_uic ${keygen_ui})
#message(STATUS ${keygen_uic})
add_executable (Plugin-${plugin}-keygen ${keygen_hdr} ${keygen_src} ${keygen_moc})
target_link_libraries (
Plugin-${plugin}-keygen
......
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