You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.3 KiB
C++

#include "eetsender.h"
#include "eetsigner.h"
#include <QDebug>
EetSender::EetSender(QObject *parent) : QObject(parent)
{
m_signer = nullptr;
}
void EetSender::sendRequest(EetRequest *request)
{
if (m_signer == nullptr)
{
emit certError();
return;
}
request->setUuidZpravy(QUuid::createUuid());
EetTemplate tempBody(BODY_TEMPLATE);
tempBody.setSigner(m_signer);
QString strBody = tempBody.fillTemplate(request);
QByteArray digest = m_signer->sha256HashData(strBody.toUtf8());
QMap<QString, QString> val;
val["digest"] = QString(digest.toBase64());
EetTemplate tempSignature(SIGNATURE_TEMPLATE);
QString strSignature = tempSignature.fillTemplate(val);
QByteArray sign = m_signer->signData(strSignature.toUtf8());
val["signature"] = QString(sign.toBase64());
val["soap:Body"] = strBody;
val["certb64"] = m_signer->getCertificate();
EetTemplate tempRequest(REQUEST_TEMPLATE);
QString strRequest = tempRequest.fillTemplate(val);
qDebug() << strRequest;
}
void EetSender::setupSigner(const QString &certPath, const QString &passwd)
{
if (m_signer != nullptr)
{
delete m_signer;
}
m_signer = new EetSigner(this);
m_signer->setup(certPath, QCA::SecureArray(passwd.toUtf8()));
}