|
|
|
@ -5,12 +5,8 @@
|
|
|
|
|
#include "eetsigner.h"
|
|
|
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QFile>
|
|
|
|
|
#include <QDomNode>
|
|
|
|
|
#include <QDomDocument>
|
|
|
|
|
#include <QXmlQuery>
|
|
|
|
|
#include <QXmlResultItems>
|
|
|
|
|
#include <QNetworkConfiguration>
|
|
|
|
|
|
|
|
|
|
const QString EetSender::ms_nsDef = "declare namespace eet = \"http://fs.mfcr.cz/eet/schema/v3\";\n"
|
|
|
|
|
"declare namespace ds = \"http://www.w3.org/2000/09/xmldsig#\";\n"
|
|
|
|
@ -25,18 +21,25 @@ EetSender::EetSender(QObject *parent) : QObject(parent)
|
|
|
|
|
m_resut = nullptr;
|
|
|
|
|
m_checkSignature = true;
|
|
|
|
|
|
|
|
|
|
m_resut = new EetResult(this);
|
|
|
|
|
|
|
|
|
|
m_manager = new QNetworkAccessManager(this);
|
|
|
|
|
connect(m_manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));
|
|
|
|
|
connect(m_manager, &QNetworkAccessManager::sslErrors, [this](QNetworkReply *rep, QList<QSslError> errs){
|
|
|
|
|
emit serviceCertError();
|
|
|
|
|
connect(m_manager, &QNetworkAccessManager::sslErrors, [this](QNetworkReply *rep, QList<QSslError>){
|
|
|
|
|
m_resut->setStatus(EetResult::SSL_ERROR);
|
|
|
|
|
emit sendFinished(m_resut);
|
|
|
|
|
rep->deleteLater();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
m_serviceUrl = PRODUCTION_URL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EetSender::sendRequest(EetRequest *request)
|
|
|
|
|
{
|
|
|
|
|
if (m_signer == nullptr)
|
|
|
|
|
{
|
|
|
|
|
emit certError();
|
|
|
|
|
m_resut->setStatus(EetResult::USER_CERT_ERROR);
|
|
|
|
|
emit sendFinished(m_resut);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -60,12 +63,8 @@ void EetSender::sendRequest(EetRequest *request)
|
|
|
|
|
|
|
|
|
|
QString strRequest = tempRequest.fillTemplate(val);
|
|
|
|
|
|
|
|
|
|
QNetworkRequest req(QUrl("https://pg.eet.cz/eet/services/EETServiceSOAP/v3"));
|
|
|
|
|
QNetworkRequest req(QUrl(m_serviceUrl.toStdString().c_str()));
|
|
|
|
|
m_manager->post(req, strRequest.toUtf8());
|
|
|
|
|
|
|
|
|
|
QFile file("/home/pepa/Dokumenty/dev/eet/req.xml");
|
|
|
|
|
file.open(QIODevice::WriteOnly);
|
|
|
|
|
file.write(strRequest.toUtf8());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EetSender::setupSigner(const QString &certPath, const QString &passwd)
|
|
|
|
@ -89,6 +88,11 @@ bool EetSender::checkSignature() const
|
|
|
|
|
return m_checkSignature;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EetSender::setPlayground(bool pg)
|
|
|
|
|
{
|
|
|
|
|
m_serviceUrl = pg ? PLAYGROUND_URL : PRODUCTION_URL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EetResult *EetSender::resut() const
|
|
|
|
|
{
|
|
|
|
|
return m_resut;
|
|
|
|
@ -129,7 +133,7 @@ bool EetSender::verifySignature(const QByteArray &repData)
|
|
|
|
|
|
|
|
|
|
if (res != QCA::ConvertGood)
|
|
|
|
|
{
|
|
|
|
|
emit serviceCertError();
|
|
|
|
|
m_resut->setStatus(EetResult::SERVICE_CERT_ERROR);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -137,7 +141,7 @@ bool EetSender::verifySignature(const QByteArray &repData)
|
|
|
|
|
|
|
|
|
|
if (!pubKey.canVerify())
|
|
|
|
|
{
|
|
|
|
|
emit serviceCertError();
|
|
|
|
|
m_resut->setStatus(EetResult::SERVICE_CERT_ERROR);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -145,7 +149,7 @@ bool EetSender::verifySignature(const QByteArray &repData)
|
|
|
|
|
|
|
|
|
|
if (!signValid)
|
|
|
|
|
{
|
|
|
|
|
emit signInvalid();
|
|
|
|
|
m_resut->setStatus(EetResult::INVALID_SIGNATURE);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -156,19 +160,17 @@ void EetSender::replyFinished(QNetworkReply *reply)
|
|
|
|
|
{
|
|
|
|
|
if (reply->error() != QNetworkReply::NoError)
|
|
|
|
|
{
|
|
|
|
|
emit sendError();
|
|
|
|
|
m_resut->setStatus(EetResult::SERVER_ERROR);
|
|
|
|
|
emit sendFinished(m_resut);
|
|
|
|
|
reply->deleteLater();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QByteArray repData = reply->readAll();
|
|
|
|
|
|
|
|
|
|
/*QFile file("/home/pepa/Dokumenty/dev/eet/reply.xml");
|
|
|
|
|
file.open(QIODevice::ReadOnly);
|
|
|
|
|
repData = file.readAll();*/
|
|
|
|
|
|
|
|
|
|
if (m_checkSignature && !verifySignature(repData))
|
|
|
|
|
{
|
|
|
|
|
emit sendFinished(m_resut);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -181,11 +183,6 @@ void EetSender::replyFinished(QNetworkReply *reply)
|
|
|
|
|
q.evaluateTo(&result);
|
|
|
|
|
result = result.trimmed();
|
|
|
|
|
|
|
|
|
|
if (m_resut == nullptr)
|
|
|
|
|
{
|
|
|
|
|
m_resut = new EetResult(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_resut->setUuid(QUuid(result));
|
|
|
|
|
|
|
|
|
|
queryString = "//senv:Envelope/senv:Body/eet:Odpoved/eet:Hlavicka/@dat_prij/data(.)";
|
|
|
|
@ -262,7 +259,7 @@ void EetSender::replyFinished(QNetworkReply *reply)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_resut->setErrors(errors);
|
|
|
|
|
emit responseRecieved(m_resut);
|
|
|
|
|
emit sendFinished(m_resut);
|
|
|
|
|
|
|
|
|
|
reply->deleteLater();
|
|
|
|
|
}
|
|
|
|
|