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++

8 years ago
#include "eetsender.h"
#include "eetsigner.h"
8 years ago
#include <QDebug>
EetSender::EetSender(QObject *parent) : QObject(parent)
{
m_signer = nullptr;
8 years ago
}
void EetSender::sendRequest(EetRequest *request)
{
if (m_signer == nullptr)
{
emit certError();
return;
}
request->setUuidZpravy(QUuid::createUuid());
8 years ago
EetTemplate tempBody(BODY_TEMPLATE);
tempBody.setSigner(m_signer);
8 years ago
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()));
8 years ago
}