X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fhttp%2Fidentityexportxml.cpp;h=521c4ca896685ae74da0ffbe4b8106b1d4e741ef;hb=76805933f794915a72b7f0a21b12af6654759f4f;hp=1f87e856650c4debe729727d62a785d7ac04559b;hpb=df316253862dc50e8e5a790d9634ef90be37badb;p=fms.git diff --git a/src/http/identityexportxml.cpp b/src/http/identityexportxml.cpp index 1f87e85..521c4ca 100644 --- a/src/http/identityexportxml.cpp +++ b/src/http/identityexportxml.cpp @@ -9,9 +9,9 @@ IdentityExportXML::IdentityExportXML() Initialize(); } -void IdentityExportXML::AddIdentity(const std::string &name, const std::string &publickey, const std::string &privatekey, const bool singleuse, const bool publishtrustlist, const bool publishboardlist) +void IdentityExportXML::AddIdentity(const std::string &name, const std::string &publickey, const std::string &privatekey, const bool singleuse, const bool publishtrustlist, const bool publishboardlist, const bool publishfreesite) { - m_identities.push_back(identity(name,publickey,privatekey,singleuse,publishtrustlist,publishboardlist)); + m_identities.push_back(identity(name,publickey,privatekey,singleuse,publishtrustlist,publishboardlist,publishfreesite)); } const std::string IdentityExportXML::GetName(const long index) @@ -62,6 +62,18 @@ const bool IdentityExportXML::GetPublishBoardList(const long index) } } +const bool IdentityExportXML::GetPublishFreesite(const long index) +{ + if(index>=0 && index=0 && index doc=new Poco::XML::Document; + Poco::AutoPtr root=doc->createElement("IdentityExport"); + Poco::AutoPtr el=NULL; - td.LinkEndChild(tdec); - tid=new TiXmlElement("IdentityExport"); - td.LinkEndChild(tid); + doc->appendChild(root); for(std::vector::iterator i=m_identities.begin(); i!=m_identities.end(); i++) { - TiXmlElement *tr=new TiXmlElement("Identity"); - tid->LinkEndChild(tr); - tr->LinkEndChild(XMLCreateCDATAElement("Name",(*i).m_name)); - tr->LinkEndChild(XMLCreateTextElement("PublicKey",(*i).m_publickey)); - tr->LinkEndChild(XMLCreateTextElement("PrivateKey",(*i).m_privatekey)); - tr->LinkEndChild(XMLCreateBooleanElement("SingleUse",(*i).m_singleuse)); - tr->LinkEndChild(XMLCreateBooleanElement("PublishTrustList",(*i).m_publishtrustlist)); - tr->LinkEndChild(XMLCreateBooleanElement("PublishBoardList",(*i).m_publishboardlist)); + el=doc->createElement("Identity"); + root->appendChild(el); + + el->appendChild(XMLCreateCDATAElement(doc,"Name",(*i).m_name)); + el->appendChild(XMLCreateTextElement(doc,"PublicKey",(*i).m_publickey)); + el->appendChild(XMLCreateTextElement(doc,"PrivateKey",(*i).m_privatekey)); + el->appendChild(XMLCreateBooleanElement(doc,"SingleUse",(*i).m_singleuse)); + el->appendChild(XMLCreateBooleanElement(doc,"PublishTrustList",(*i).m_publishtrustlist)); + el->appendChild(XMLCreateBooleanElement(doc,"PublishBoardList",(*i).m_publishboardlist)); + el->appendChild(XMLCreateBooleanElement(doc,"PublishFreesite",(*i).m_publishfreesite)); } - td.Accept(&tp); - return std::string(tp.CStr()); + return GenerateXML(doc); } void IdentityExportXML::Initialize() @@ -120,66 +130,72 @@ void IdentityExportXML::Initialize() const bool IdentityExportXML::ParseXML(const std::string &xml) { - TiXmlDocument td; - td.Parse(xml.c_str()); + bool parsed=false; + Poco::XML::DOMParser dp; - if(!td.Error()) - { - std::string name; - std::string publickey; - std::string privatekey; - bool singleuse=false; - bool publishtrustlist=false; - bool publishboardlist=false; - TiXmlText *txt; - TiXmlHandle hnd(&td); - TiXmlNode *node; + Initialize(); - Initialize(); + try + { + Poco::AutoPtr doc=dp.parseString(FixCDATA(xml)); + Poco::XML::Element *root=XMLGetFirstChild(doc,"IdentityExport"); + Poco::XML::Element *node=XMLGetFirstChild(root,"Identity"); - node=hnd.FirstChild("IdentityExport").FirstChild("Identity").ToElement(); while(node) { - name=""; - publickey=""; - privatekey=""; - singleuse=false; - publishtrustlist=false; - publishboardlist=false; - - TiXmlHandle hnd2(node); - txt=hnd2.FirstChild("Name").FirstChild().ToText(); - if(txt) + std::string name=""; + std::string publickey=""; + std::string privatekey=""; + bool singleuse=false; + bool publishtrustlist=false; + bool publishboardlist=false; + bool publishfreesite=false; + + Poco::XML::Element *text=XMLGetFirstChild(node,"Name"); + if(text) { - name=txt->ValueStr(); + if(text->firstChild()) + { + std::string asdf=text->innerText(); + asdf=text->firstChild()->innerText(); + name=text->firstChild()->getNodeValue(); + } } - txt=hnd2.FirstChild("PublicKey").FirstChild().ToText(); - if(txt) + text=XMLGetFirstChild(node,"PublicKey"); + if(text) { - publickey=txt->ValueStr(); + if(text->firstChild()) + { + publickey=text->firstChild()->getNodeValue(); + } } - txt=hnd2.FirstChild("PrivateKey").FirstChild().ToText(); - if(txt) + text=XMLGetFirstChild(node,"PrivateKey"); + if(text) { - privatekey=txt->ValueStr(); + if(text->firstChild()) + { + privatekey=text->firstChild()->getNodeValue(); + } } - singleuse=XMLGetBooleanElement(node->ToElement(),"SingleUse"); - publishtrustlist=XMLGetBooleanElement(node->ToElement(),"PublishTrustList"); - publishboardlist=XMLGetBooleanElement(node->ToElement(),"PublishBoardList"); + singleuse=XMLGetBooleanElement(node,"SingleUse"); + publishtrustlist=XMLGetBooleanElement(node,"PublishTrustList"); + publishboardlist=XMLGetBooleanElement(node,"PublishBoardList"); + publishfreesite=XMLGetBooleanElement(node,"PublishFreesite"); if(name!="" && publickey!="" && privatekey!="") { - m_identities.push_back(identity(name,publickey,privatekey,singleuse,publishtrustlist,publishboardlist)); + m_identities.push_back(identity(name,publickey,privatekey,singleuse,publishtrustlist,publishboardlist,publishfreesite)); } - - node=node->NextSibling("Identity"); + + node=XMLGetNextSibling(node,"Identity"); } - return true; + parsed=true; } - else + catch(...) { - return false; } + + return parsed; }