parent
0482d9a6a5
commit
2c0155832b
@ -1,57 +1,56 @@ |
|||||||
|
|
||||||
HEADERS += src/adaptors/UBExportAdaptor.h\ |
HEADERS += src/adaptors/UBExportAdaptor.h\ |
||||||
src/adaptors/UBExportPDF.h \ |
src/adaptors/UBExportPDF.h \ |
||||||
src/adaptors/UBExportFullPDF.h \ |
src/adaptors/UBExportFullPDF.h \ |
||||||
src/adaptors/UBExportDocument.h \ |
src/adaptors/UBExportDocument.h \ |
||||||
src/adaptors/UBSvgSubsetAdaptor.h \ |
src/adaptors/UBSvgSubsetAdaptor.h \ |
||||||
src/adaptors/UBMetadataDcSubsetAdaptor.h \ |
src/adaptors/UBMetadataDcSubsetAdaptor.h \ |
||||||
src/adaptors/UBImportAdaptor.h \ |
src/adaptors/UBImportAdaptor.h \ |
||||||
src/adaptors/UBImportDocument.h \ |
src/adaptors/UBImportDocument.h \ |
||||||
src/adaptors/UBThumbnailAdaptor.h \ |
src/adaptors/UBThumbnailAdaptor.h \ |
||||||
src/adaptors/UBImportPDF.h \ |
src/adaptors/UBImportPDF.h \ |
||||||
src/adaptors/UBImportImage.h \ |
src/adaptors/UBImportImage.h \ |
||||||
src/adaptors/UBIniFileParser.h \ |
src/adaptors/UBIniFileParser.h \ |
||||||
src/adaptors/UBExportWeb.h \ |
src/adaptors/UBExportWeb.h \ |
||||||
src/adaptors/UBWebPublisher.h \ |
src/adaptors/UBWebPublisher.h \ |
||||||
src/adaptors/UBImportCFF.h \ |
src/adaptors/UBImportCFF.h \ |
||||||
src/adaptors/UBCFFSubsetAdaptor.h |
src/adaptors/UBCFFSubsetAdaptor.h |
||||||
|
|
||||||
HEADERS += src/adaptors/publishing/UBDocumentPublisher.h \ |
HEADERS += src/adaptors/publishing/UBDocumentPublisher.h \ |
||||||
src/adaptors/publishing/UBAbstractPublisher.h \ |
src/adaptors/publishing/UBSvgSubsetRasterizer.h |
||||||
src/adaptors/publishing/UBSvgSubsetRasterizer.h |
|
||||||
|
HEADERS += src/adaptors/voting/UBAbstractVotingSystem.h |
||||||
HEADERS += src/adaptors/voting/UBAbstractVotingSystem.h |
|
||||||
|
|
||||||
|
SOURCES += src/adaptors/UBExportAdaptor.cpp\ |
||||||
SOURCES += src/adaptors/UBExportAdaptor.cpp\ |
src/adaptors/UBExportPDF.cpp \ |
||||||
src/adaptors/UBExportPDF.cpp \ |
src/adaptors/UBExportFullPDF.cpp \ |
||||||
src/adaptors/UBExportFullPDF.cpp \ |
src/adaptors/UBExportDocument.cpp \ |
||||||
src/adaptors/UBExportDocument.cpp \ |
src/adaptors/UBSvgSubsetAdaptor.cpp \ |
||||||
src/adaptors/UBSvgSubsetAdaptor.cpp \ |
src/adaptors/UBMetadataDcSubsetAdaptor.cpp \ |
||||||
src/adaptors/UBMetadataDcSubsetAdaptor.cpp \ |
src/adaptors/UBImportAdaptor.cpp \ |
||||||
src/adaptors/UBImportAdaptor.cpp \ |
src/adaptors/UBImportDocument.cpp \ |
||||||
src/adaptors/UBImportDocument.cpp \ |
src/adaptors/UBThumbnailAdaptor.cpp \ |
||||||
src/adaptors/UBThumbnailAdaptor.cpp \ |
src/adaptors/UBImportPDF.cpp \ |
||||||
src/adaptors/UBImportPDF.cpp \ |
src/adaptors/UBImportImage.cpp \ |
||||||
src/adaptors/UBImportImage.cpp \ |
src/adaptors/UBIniFileParser.cpp \ |
||||||
src/adaptors/UBIniFileParser.cpp \ |
src/adaptors/UBExportWeb.cpp \ |
||||||
src/adaptors/UBExportWeb.cpp \ |
src/adaptors/UBWebPublisher.cpp \ |
||||||
src/adaptors/UBWebPublisher.cpp \ |
src/adaptors/UBImportCFF.cpp \ |
||||||
src/adaptors/UBImportCFF.cpp \ |
src/adaptors/UBCFFSubsetAdaptor.cpp \ |
||||||
src/adaptors/UBCFFSubsetAdaptor.cpp |
src/adaptors/publishing/UBDocumentPublisher.cpp |
||||||
|
|
||||||
SOURCES += src/adaptors/publishing/UBDocumentPublisher.cpp \ |
SOURCES += \ |
||||||
src/adaptors/publishing/UBAbstractPublisher.cpp \ |
src/adaptors/publishing/UBSvgSubsetRasterizer.cpp |
||||||
src/adaptors/publishing/UBSvgSubsetRasterizer.cpp |
|
||||||
|
SOURCES += src/adaptors/voting/UBAbstractVotingSystem.cpp |
||||||
SOURCES += src/adaptors/voting/UBAbstractVotingSystem.cpp |
|
||||||
|
|
||||||
|
win32 { |
||||||
win32 { |
|
||||||
|
SOURCES += src/adaptors/voting/UBReply2005VotingSystem.cpp \ |
||||||
SOURCES += src/adaptors/voting/UBReply2005VotingSystem.cpp \ |
src/adaptors/voting/UBReplyWRS970VotingSystem.cpp |
||||||
src/adaptors/voting/UBReplyWRS970VotingSystem.cpp |
|
||||||
|
HEADERS += src/adaptors/voting/UBReply2005VotingSystem.h \ |
||||||
HEADERS += src/adaptors/voting/UBReply2005VotingSystem.h \ |
src/adaptors/voting/UBReplyWRS970VotingSystem.h |
||||||
src/adaptors/voting/UBReplyWRS970VotingSystem.h |
} |
||||||
} |
|
||||||
|
@ -1,148 +0,0 @@ |
|||||||
/*
|
|
||||||
* This program is free software: you can redistribute it and/or modify |
|
||||||
* it under the terms of the GNU General Public License as published by |
|
||||||
* the Free Software Foundation, either version 3 of the License, or |
|
||||||
* (at your option) any later version. |
|
||||||
* |
|
||||||
* This program is distributed in the hope that it will be useful, |
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||||
* GNU General Public License for more details. |
|
||||||
* |
|
||||||
* You should have received a copy of the GNU General Public License |
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/ |
|
||||||
#include "UBAbstractPublisher.h" |
|
||||||
|
|
||||||
#include <QtXml> |
|
||||||
|
|
||||||
#include <openssl/aes.h> |
|
||||||
#include <openssl/evp.h> |
|
||||||
|
|
||||||
#include "core/UBSettings.h" |
|
||||||
#include "core/UBApplication.h" |
|
||||||
|
|
||||||
#include "network/UBNetworkAccessManager.h" |
|
||||||
#include "network/UBServerXMLHttpRequest.h" |
|
||||||
|
|
||||||
#include "core/memcheck.h" |
|
||||||
|
|
||||||
UBAbstractPublisher::UBAbstractPublisher(QObject *parent) |
|
||||||
: QObject(parent) |
|
||||||
, mTokenRequest(0) |
|
||||||
{ |
|
||||||
// NOOP
|
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
void UBAbstractPublisher::authenticate() |
|
||||||
{ |
|
||||||
sendAuthenticationTokenRequest(); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
void UBAbstractPublisher::sendAuthenticationTokenRequest() |
|
||||||
{ |
|
||||||
QUrl publishingEndpoint = QUrl(UBSettings::settings()->publishingAuthenticationUrl); |
|
||||||
|
|
||||||
mTokenRequest = new UBServerXMLHttpRequest(UBNetworkAccessManager::defaultAccessManager()); |
|
||||||
|
|
||||||
mTokenRequest->setVerbose(true); |
|
||||||
|
|
||||||
UBApplication::showMessage(tr("Contacting %1").arg(UBSettings::settings()->uniboardWebUrl->get().toString()), true); |
|
||||||
|
|
||||||
connect(mTokenRequest, SIGNAL(finished(bool, const QByteArray&)), this, SLOT(processAuthenticationTokenResponse(bool, const QByteArray&))); |
|
||||||
|
|
||||||
mTokenRequest->get(publishingEndpoint); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
void UBAbstractPublisher::processAuthenticationTokenResponse(bool success, const QByteArray& payload) |
|
||||||
{ |
|
||||||
if (mTokenRequest) |
|
||||||
mTokenRequest->deleteLater(); |
|
||||||
|
|
||||||
if (success) |
|
||||||
{ |
|
||||||
/*
|
|
||||||
<publishing-token> |
|
||||||
... |
|
||||||
<token>iFzZIXhPxHTLhJeHWFF9BDVblMDWU546rpzoEEfxMSLrftMq444w4BuoisnNtRAjm6ht3hKUIHmMKA3xGN2Hlaof8tbYNLHmzf2R1dO439vnXFiHMPLBi7nFpSEPtBNJ</token> |
|
||||||
<uuid>26fea4c0-1319-012d-d0fc-001f5b3d920c</uuid> |
|
||||||
... |
|
||||||
</publishing-token> |
|
||||||
*/ |
|
||||||
|
|
||||||
QDomDocument doc("publishing-token"); |
|
||||||
doc.setContent(payload, false); |
|
||||||
|
|
||||||
QDomElement root = doc.documentElement(); |
|
||||||
|
|
||||||
const QString token = root.firstChildElement("token").text(); |
|
||||||
const QString uuid = root.firstChildElement("uuid").text(); |
|
||||||
|
|
||||||
if (token.length() > 0 && uuid.length() > 0) |
|
||||||
{ |
|
||||||
const QByteArray encrypted = encrypt(token); |
|
||||||
QString encryptedBase64 = QString::fromAscii(encrypted.toBase64()); |
|
||||||
|
|
||||||
UBApplication::showMessage(tr("Found %1").arg(UBSettings::settings()->uniboardWebUrl->get().toString()), false); |
|
||||||
|
|
||||||
emit authenticated(QUuid(uuid), encryptedBase64); |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
qWarning() << "Authentication failed" << QString::fromUtf8(payload); |
|
||||||
|
|
||||||
emit authenticationFailure(); |
|
||||||
|
|
||||||
UBApplication::showMessage(tr("Cannot Authenticate with %1").arg(UBSettings::settings()->uniboardWebUrl->get().toString())); |
|
||||||
} |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
qWarning() << "Authentication failed" << QString::fromUtf8(payload); |
|
||||||
|
|
||||||
emit authenticationFailure(); |
|
||||||
|
|
||||||
UBApplication::showMessage(tr("Cannot Authenticate with %1").arg(UBSettings::settings()->uniboardWebUrl->get().toString())); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
QByteArray UBAbstractPublisher::encrypt(const QString& clear) |
|
||||||
{ |
|
||||||
static const char *key = "9ecHaspud9uD9ste5erAchehefrup3ec"; |
|
||||||
|
|
||||||
EVP_CIPHER_CTX aesEncryptContext; |
|
||||||
|
|
||||||
EVP_CIPHER_CTX_init(&aesEncryptContext); |
|
||||||
|
|
||||||
EVP_EncryptInit_ex(&aesEncryptContext, EVP_aes_256_ecb(), NULL, (const unsigned char*)key, NULL); |
|
||||||
|
|
||||||
QByteArray clearData = clear.toUtf8(); |
|
||||||
|
|
||||||
int cipheredLength = clearData.length() + AES_BLOCK_SIZE; |
|
||||||
int paddingLength = 0; |
|
||||||
|
|
||||||
unsigned char *cipherText = (unsigned char *)malloc(cipheredLength); |
|
||||||
|
|
||||||
if(!EVP_EncryptInit_ex(&aesEncryptContext, NULL, NULL, NULL, NULL)) |
|
||||||
return QByteArray(); |
|
||||||
|
|
||||||
if(!EVP_EncryptUpdate(&aesEncryptContext, cipherText, &cipheredLength, (unsigned char *)clearData.data(), clearData.length())) |
|
||||||
return QByteArray(); |
|
||||||
|
|
||||||
/* update ciphertext with the final remaining bytes */ |
|
||||||
if(!EVP_EncryptFinal_ex(&aesEncryptContext, cipherText + cipheredLength, &paddingLength)) |
|
||||||
return QByteArray(); |
|
||||||
|
|
||||||
QByteArray cipheredData((const char *)cipherText, cipheredLength + paddingLength); |
|
||||||
|
|
||||||
free(cipherText); |
|
||||||
EVP_CIPHER_CTX_cleanup(&aesEncryptContext); |
|
||||||
|
|
||||||
return cipheredData; |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
|
|
@ -1,51 +0,0 @@ |
|||||||
/*
|
|
||||||
* This program is free software: you can redistribute it and/or modify |
|
||||||
* it under the terms of the GNU General Public License as published by |
|
||||||
* the Free Software Foundation, either version 3 of the License, or |
|
||||||
* (at your option) any later version. |
|
||||||
* |
|
||||||
* This program is distributed in the hope that it will be useful, |
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||||
* GNU General Public License for more details. |
|
||||||
* |
|
||||||
* You should have received a copy of the GNU General Public License |
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/ |
|
||||||
#ifndef UBABSTRACTPUBLISHER_H |
|
||||||
#define UBABSTRACTPUBLISHER_H |
|
||||||
|
|
||||||
#include <QtCore> |
|
||||||
|
|
||||||
class UBServerXMLHttpRequest; |
|
||||||
|
|
||||||
|
|
||||||
class UBAbstractPublisher : public QObject |
|
||||||
{ |
|
||||||
Q_OBJECT |
|
||||||
public: |
|
||||||
explicit UBAbstractPublisher(QObject *parent = 0); |
|
||||||
virtual ~UBAbstractPublisher(){} |
|
||||||
|
|
||||||
void authenticate(); |
|
||||||
|
|
||||||
signals: |
|
||||||
|
|
||||||
void authenticated(const QUuid&, const QString&); |
|
||||||
void authenticationFailure(); |
|
||||||
|
|
||||||
private: |
|
||||||
|
|
||||||
void sendAuthenticationTokenRequest(); |
|
||||||
|
|
||||||
QByteArray encrypt(const QString& token); |
|
||||||
|
|
||||||
UBServerXMLHttpRequest* mTokenRequest; |
|
||||||
|
|
||||||
private slots: |
|
||||||
|
|
||||||
void processAuthenticationTokenResponse(bool, const QByteArray&); |
|
||||||
|
|
||||||
}; |
|
||||||
|
|
||||||
#endif // UBABSTRACTPUBLISHER_H
|
|
Loading…
Reference in new issue