XmlType getXmlTypeNoThrow(const XmlDoc& doc) //throw() { if (doc.root().getNameAs<std::string>() == "FreeFileSync") { std::string type; if (doc.root().getAttribute("XmlType", type)) { if (type == "GUI") return XML_TYPE_GUI; else if (type == "BATCH") return XML_TYPE_BATCH; else if (type == "GLOBAL") return XML_TYPE_GLOBAL; } } return XML_TYPE_OTHER; }
void setXmlType(XmlDoc& doc, XmlType type) //throw() { switch (type) { case XML_TYPE_GUI: doc.root().setAttribute("XmlType", "GUI"); break; case XML_TYPE_BATCH: doc.root().setAttribute("XmlType", "BATCH"); break; case XML_TYPE_GLOBAL: doc.root().setAttribute("XmlType", "GLOBAL"); break; case XML_TYPE_OTHER: assert(false); break; } }
void XmlSignature::sign(XmlDoc &xml, const Sec::Key &key) { try { XmlElementPtr rootNode{ xml.root() }; XmlElementPtr sigNode{ std::make_shared<XmlElement>( *_signature->createBlankSignature(xml, CANON_C14N_COM, SIGNATURE_RSA, HASH_SHA1)) }; rootNode->add(*sigNode); DSIGReference * ref = _signature->createReference(MAKE_UNICODE_STRING("")); ref->appendEnvelopedSignatureTransform(); _signature->setSigningKey(key); _signature->sign(); _signed = true; } catch (XSECException &ex) { rethrowWithMessage(ex, "An error occured while signing xml"); } }