Implemented SOAP message generation.
parent
1fd6bfde3e
commit
f299c8b459
@ -1,16 +1,51 @@
|
||||
#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);
|
||||
|
||||
qDebug() << strBody;
|
||||
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()));
|
||||
}
|
||||
|
Loading…
Reference in New Issue