Commit 4d3eae86 authored by Martin Straka's avatar Martin Straka

Added autenticate message soap xml.

parent f23d705b
......@@ -36,6 +36,18 @@ XmlLayer::XmlLayer(QObject *parent)
{
}
QByteArray XmlLayer::xmlCreateAuthenticateMessageSoapRequest(
const QByteArray &msg)
{
QString xmlContent("<AuthenticateMessage xmlns=\"");
xmlContent.append(ISDS_NS);
xmlContent.append("\"><dmMessage>");
xmlContent.append(msg);
xmlContent.append("</dmMessage>");
xmlContent.append("</AuthenticateMessage>");
return xmlCreateSoapEnvelope(xmlContent);
}
QByteArray XmlLayer::xmlCreateDownloadMessageSoapRequest(qint64 msgId,
enum Messages::MessageType msgDirect)
{
......@@ -1506,3 +1518,93 @@ bool XmlLayer::parseFindDataBoxSoapResponse(const QByteArray &xmlData,
return ret;
}
bool XmlLayer::parseZFO(const QByteArray &content, MsgEnvelope &msg,
QList<AttachmentData> &fileList, QString &txt)
{
qDebug("%s()", __func__);
QByteArray cmsData = content;
/* decode cms and obtain message xml data - used openssl */
void *xmlContent = NULL;
size_t xmlContentLen = 0;
if (extract_cms_data(cmsData.data(), cmsData.length(), &xmlContent,
&xmlContentLen) != 0) {
txt = tr("ZFO format invalid.");
return false;
}
if (xmlContentLen == 0) {
free(xmlContent); xmlContent = NULL;
txt = tr("ZFO format invalid.");
return false;
}
QByteArray soap((char*)xmlContent, xmlContentLen);
free(xmlContent); xmlContent = NULL;
/* add xml SOAP header anf footer */
soap.prepend("<?xml version='1.0' encoding='utf-8'?>"
"<SOAP-ENV:Envelope "
"xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" "
"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">"
"<SOAP-ENV:Body>");
soap.append("</SOAP-ENV:Body></SOAP-ENV:Envelope>");
/* Parse XML */
QXmlStreamReader xml;
xml.addData(soap);
while(!xml.atEnd() && !xml.hasError()) {
QXmlStreamReader::TokenType token = xml.readNext();
if (xml.error() != QXmlStreamReader::NoError) {
return false;
}
if (token == QXmlStreamReader::StartDocument) {
continue;
}
if (token == QXmlStreamReader::StartElement) {
if (xml.name() == "dmReturnedMessage") {
foreach (const QXmlStreamAttribute &attr, xml.attributes()) {
if (attr.name() == "dmType") {
msg.setDmType(attr.value().toString());
}
}
}
if (xml.name() == "dmDm") {
completeMessageParse(xml, msg, fileList);
}
}
}
return true;
}
bool XmlLayer::parseAuthenticateMessage(const QByteArray &xmlData, QString &txt)
{
qDebug("%s()", __func__);
if (!parseDmStatusFromXml(xmlData, txt)) {
return false;
}
QXmlStreamReader xml;
xml.addData(xmlData);
bool isValid = false;
while(!xml.atEnd() && !xml.hasError()){
QXmlStreamReader::TokenType token = xml.readNext();
if (token == QXmlStreamReader::StartDocument) {
continue;
}
if (token == QXmlStreamReader::StartElement) {
if (xml.name() == "dmAuthResult") {
xml.readNext();
if (xml.text().toString() == "true") {
isValid = true;
}
}
}
}
return isValid;
}
......@@ -45,6 +45,16 @@ public:
*/
XmlLayer(QObject *parent = Q_NULLPTR);
/*!
* @brief Create authenticate message soap request.
*
* @param[in] msg Message content.
* @return Soap request string as byte array.
*/
static
QByteArray xmlCreateAuthenticateMessageSoapRequest(
const QByteArray &msg);
/*!
* @brief Create download message soap request.
*
......@@ -443,6 +453,29 @@ public:
static
bool parseFindDataBoxSoapResponse(const QByteArray &xmlData,
QString &dbInfo, QString &txt);
/*!
* @brief Parse ZFO file xml data .
*
* @param[in] content ZFO content for parsing.
* @param[out] msg Message enevelope structure.
* @param[out] fileList List of attachments.
* @param[out] txt Error description.
* @return true if success.
*/
static
bool parseZFO(const QByteArray &content,
MsgEnvelope &msg, QList<AttachmentData> &fileList, QString &txt);
/*!
* @brief Parse authenticate messagee xml data.
*
* @param[in] xmlData Xml Data for parsing.
* @param[out] txt Error description if something failed.
* @return true if success.
*/
static
bool parseAuthenticateMessage(const QByteArray &xmlData, QString &txt);
};
#endif /* _XML_LAYER_H_ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment