Added PKP and BKP codes to EetResult. Added doxygen comments to EetSender class.

master
Josef Rokos 8 years ago
parent f7abd0b228
commit ae7eb57115

@ -65,6 +65,26 @@ void EetResult::setReciveDate(const QDateTime &reciveDate)
m_reciveDate = 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) EetMessage::EetMessage(QObject *parent)
:QObject(parent) :QObject(parent)
{ {

@ -63,11 +63,19 @@ public:
QDateTime reciveDate() const; QDateTime reciveDate() const;
void setReciveDate(const QDateTime &reciveDate); void setReciveDate(const QDateTime &reciveDate);
QString pkp() const;
void setPkp(const QString &pkp);
QString bkp() const;
void setBkp(const QString &bkp);
private: private:
ResponseStatus m_status; ResponseStatus m_status;
QUuid m_uuid; QUuid m_uuid;
QDateTime m_reciveDate; QDateTime m_reciveDate;
QString m_fik; QString m_fik;
QString m_pkp;
QString m_bkp;
EetMessageList m_warnings; EetMessageList m_warnings;
EetMessageList m_errors; EetMessageList m_errors;
}; };

@ -47,6 +47,7 @@ void EetSender::sendRequest(EetRequest *request)
EetTemplate tempBody(BODY_TEMPLATE); EetTemplate tempBody(BODY_TEMPLATE);
tempBody.setSigner(m_signer); tempBody.setSigner(m_signer);
tempBody.setResult(m_resut);
QString strBody = tempBody.fillTemplate(request); QString strBody = tempBody.fillTemplate(request);
QByteArray digest = m_signer->sha256HashData(strBody.toUtf8()); QByteArray digest = m_signer->sha256HashData(strBody.toUtf8());
@ -259,6 +260,7 @@ void EetSender::replyFinished(QNetworkReply *reply)
} }
m_resut->setErrors(errors); m_resut->setErrors(errors);
m_resut->setReciveDate(QDateTime::currentDateTime());
emit sendFinished(m_resut); emit sendFinished(m_resut);
reply->deleteLater(); reply->deleteLater();

@ -14,20 +14,48 @@
class QNetworkAccessManager; class QNetworkAccessManager;
class QNetworkReply; class QNetworkReply;
/**
* @brief The EetSender class Performs send actions.
*/
class EETCPPSHARED_EXPORT EetSender : public QObject class EETCPPSHARED_EXPORT EetSender : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit EetSender(QObject *parent = 0); explicit EetSender(QObject *parent = 0);
/**
* @brief Sends request to EET web service
* @param request EET data
*/
void sendRequest(EetRequest *request); 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); 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); void setCheckSignature(bool checkSignature);
/**
* @brief Returns signature verifing state.
* @return true if verify.
*/
bool checkSignature() const; 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); void setPlayground(bool pg);
/**
* @brief Returns comunication result.
* @return result
*/
EetResult *resut() const; EetResult *resut() const;
private: private:

@ -1,3 +1,4 @@
#include "eetresult.h"
#include "eettemplate.h" #include "eettemplate.h"
#include <QFile> #include <QFile>
@ -5,6 +6,7 @@
EetTemplate::EetTemplate(QObject *parent) : QObject(parent) EetTemplate::EetTemplate(QObject *parent) : QObject(parent)
{ {
m_result = nullptr;
} }
EetTemplate::EetTemplate(const QString &tmp, QObject *parent) : QObject(parent) 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); QTextStream stream(&tmpFile);
m_template = stream.readAll(); m_template = stream.readAll();
m_result = nullptr;
} }
QString EetTemplate::fillTemplate(EetRequest *request) QString EetTemplate::fillTemplate(EetRequest *request)
@ -39,6 +42,12 @@ QString EetTemplate::fillTemplate(EetRequest *request)
splitedBkp += base16bkp[i]; splitedBkp += base16bkp[i];
} }
if (m_result != nullptr)
{
m_result->setPkp(base64Sign);
m_result->setBkp(splitedBkp.toUpper());
}
QMap<QString, QString> varMap; QMap<QString, QString> varMap;
varMap["pkp"] = base64Sign; varMap["pkp"] = base64Sign;
varMap["bkp"] = splitedBkp.toUpper(); varMap["bkp"] = splitedBkp.toUpper();
@ -131,3 +140,8 @@ QString EetTemplate::getPkpString(EetRequest *request)
request->property("celk_trzba").toString()); request->property("celk_trzba").toString());
return ret; return ret;
} }
void EetTemplate::setResult(EetResult *result)
{
m_result = result;
}

@ -12,6 +12,8 @@
#define REQUEST_TEMPLATE ":/res/template_request.txt" #define REQUEST_TEMPLATE ":/res/template_request.txt"
#define SIGNATURE_TEMPLATE ":/res/template_signature.txt" #define SIGNATURE_TEMPLATE ":/res/template_signature.txt"
class EetResult;
class EetTemplate : public QObject class EetTemplate : public QObject
{ {
Q_OBJECT Q_OBJECT
@ -22,6 +24,7 @@ public:
QString fillTemplate(EetRequest *request); QString fillTemplate(EetRequest *request);
QString fillTemplate(QMap<QString, QString> map); QString fillTemplate(QMap<QString, QString> map);
void setSigner(EetSigner *signer) { m_signer = signer; } void setSigner(EetSigner *signer) { m_signer = signer; }
void setResult(EetResult *result);
signals: signals:
@ -32,6 +35,7 @@ private:
QString fillTemplateInternal(EetRequest *request, QMap<QString, QString> *map); QString fillTemplateInternal(EetRequest *request, QMap<QString, QString> *map);
QString getPkpString(EetRequest *request); QString getPkpString(EetRequest *request);
EetSigner *m_signer; EetSigner *m_signer;
EetResult *m_result;
}; };
#endif // EETTEMPLATE_H #endif // EETTEMPLATE_H

Loading…
Cancel
Save