From ae7eb571159dc90eff7da449bcf9c0a0141f3b3d Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Thu, 9 Feb 2017 21:35:17 +0100 Subject: [PATCH] Added PKP and BKP codes to EetResult. Added doxygen comments to EetSender class. --- libEet/eetresult.cpp | 20 ++++++++++++++++++++ libEet/eetresult.h | 8 ++++++++ libEet/eetsender.cpp | 2 ++ libEet/eetsender.h | 28 ++++++++++++++++++++++++++++ libEet/eettemplate.cpp | 14 ++++++++++++++ libEet/eettemplate.h | 4 ++++ 6 files changed, 76 insertions(+) diff --git a/libEet/eetresult.cpp b/libEet/eetresult.cpp index fa987df..700b5cf 100644 --- a/libEet/eetresult.cpp +++ b/libEet/eetresult.cpp @@ -65,6 +65,26 @@ void EetResult::setReciveDate(const QDateTime &reciveDate) m_reciveDate = reciveDate; } +QString EetResult::pkp() const +{ + return m_pkp; +} + +void EetResult::setPkp(const QString &pkp) +{ + m_pkp = pkp; +} + +QString EetResult::bkp() const +{ + return m_bkp; +} + +void EetResult::setBkp(const QString &bkp) +{ + m_bkp = bkp; +} + EetMessage::EetMessage(QObject *parent) :QObject(parent) { diff --git a/libEet/eetresult.h b/libEet/eetresult.h index b9ca65f..12ba172 100644 --- a/libEet/eetresult.h +++ b/libEet/eetresult.h @@ -63,11 +63,19 @@ public: QDateTime reciveDate() const; void setReciveDate(const QDateTime &reciveDate); + QString pkp() const; + void setPkp(const QString &pkp); + + QString bkp() const; + void setBkp(const QString &bkp); + private: ResponseStatus m_status; QUuid m_uuid; QDateTime m_reciveDate; QString m_fik; + QString m_pkp; + QString m_bkp; EetMessageList m_warnings; EetMessageList m_errors; }; diff --git a/libEet/eetsender.cpp b/libEet/eetsender.cpp index a53c7ac..9132a98 100644 --- a/libEet/eetsender.cpp +++ b/libEet/eetsender.cpp @@ -47,6 +47,7 @@ void EetSender::sendRequest(EetRequest *request) EetTemplate tempBody(BODY_TEMPLATE); tempBody.setSigner(m_signer); + tempBody.setResult(m_resut); QString strBody = tempBody.fillTemplate(request); QByteArray digest = m_signer->sha256HashData(strBody.toUtf8()); @@ -259,6 +260,7 @@ void EetSender::replyFinished(QNetworkReply *reply) } m_resut->setErrors(errors); + m_resut->setReciveDate(QDateTime::currentDateTime()); emit sendFinished(m_resut); reply->deleteLater(); diff --git a/libEet/eetsender.h b/libEet/eetsender.h index 3cd5b7b..708afac 100644 --- a/libEet/eetsender.h +++ b/libEet/eetsender.h @@ -14,20 +14,48 @@ class QNetworkAccessManager; class QNetworkReply; +/** + * @brief The EetSender class Performs send actions. + */ class EETCPPSHARED_EXPORT EetSender : public QObject { Q_OBJECT public: explicit EetSender(QObject *parent = 0); + /** + * @brief Sends request to EET web service + * @param request EET data + */ void sendRequest(EetRequest *request); + /** + * @brief Setup certificate for signing EET request data. + * @param certPath Path to certificate p12 file. File must contain private key. + * @param passwd Password for accesing p12 file. + */ void setupSigner(const QString &certPath, const QString &passwd); + /** + * @brief Sets verifing signature of response data. + * @param checkSignature true if you wish to verify. + */ void setCheckSignature(bool checkSignature); + /** + * @brief Returns signature verifing state. + * @return true if verify. + */ bool checkSignature() const; + /** + * @brief Sets comunication with playground EET portal. + * @param pg true if you wish to communicate with playground portal. + */ void setPlayground(bool pg); + /** + * @brief Returns comunication result. + * @return result + */ EetResult *resut() const; private: diff --git a/libEet/eettemplate.cpp b/libEet/eettemplate.cpp index 2734d90..7ef6761 100644 --- a/libEet/eettemplate.cpp +++ b/libEet/eettemplate.cpp @@ -1,3 +1,4 @@ +#include "eetresult.h" #include "eettemplate.h" #include @@ -5,6 +6,7 @@ EetTemplate::EetTemplate(QObject *parent) : QObject(parent) { + m_result = nullptr; } EetTemplate::EetTemplate(const QString &tmp, QObject *parent) : QObject(parent) @@ -14,6 +16,7 @@ EetTemplate::EetTemplate(const QString &tmp, QObject *parent) : QObject(parent) QTextStream stream(&tmpFile); m_template = stream.readAll(); + m_result = nullptr; } QString EetTemplate::fillTemplate(EetRequest *request) @@ -39,6 +42,12 @@ QString EetTemplate::fillTemplate(EetRequest *request) splitedBkp += base16bkp[i]; } + if (m_result != nullptr) + { + m_result->setPkp(base64Sign); + m_result->setBkp(splitedBkp.toUpper()); + } + QMap varMap; varMap["pkp"] = base64Sign; varMap["bkp"] = splitedBkp.toUpper(); @@ -131,3 +140,8 @@ QString EetTemplate::getPkpString(EetRequest *request) request->property("celk_trzba").toString()); return ret; } + +void EetTemplate::setResult(EetResult *result) +{ + m_result = result; +} diff --git a/libEet/eettemplate.h b/libEet/eettemplate.h index b2e5256..cb8c620 100644 --- a/libEet/eettemplate.h +++ b/libEet/eettemplate.h @@ -12,6 +12,8 @@ #define REQUEST_TEMPLATE ":/res/template_request.txt" #define SIGNATURE_TEMPLATE ":/res/template_signature.txt" +class EetResult; + class EetTemplate : public QObject { Q_OBJECT @@ -22,6 +24,7 @@ public: QString fillTemplate(EetRequest *request); QString fillTemplate(QMap map); void setSigner(EetSigner *signer) { m_signer = signer; } + void setResult(EetResult *result); signals: @@ -32,6 +35,7 @@ private: QString fillTemplateInternal(EetRequest *request, QMap *map); QString getPkpString(EetRequest *request); EetSigner *m_signer; + EetResult *m_result; }; #endif // EETTEMPLATE_H