X-Git-Url: https://git.pterodactylus.net/?p=fms.git;a=blobdiff_plain;f=src%2Ffreenet%2Fidentityintroductionxml.cpp;h=82ed285dacbe8bcb9e07b56c1bb78ac186e64a0d;hp=f45f29db1e973f268f034c9d8b12c42dcfc9daf2;hb=dec33c63afafabf83c3039e916725cac6faef9b3;hpb=9b22dd53fe62e312c1647310b7ec43aa127090af diff --git a/src/freenet/identityintroductionxml.cpp b/src/freenet/identityintroductionxml.cpp index f45f29d..82ed285 100644 --- a/src/freenet/identityintroductionxml.cpp +++ b/src/freenet/identityintroductionxml.cpp @@ -12,19 +12,24 @@ IdentityIntroductionXML::IdentityIntroductionXML() std::string IdentityIntroductionXML::GetXML() { - TiXmlDocument td; - TiXmlDeclaration *tdec=new TiXmlDeclaration("1.0","UTF-8",""); - TiXmlElement *tid; - TiXmlPrinter tp; + Poco::AutoPtr doc=new Poco::XML::Document; + //TiXmlDocument td; + //TiXmlDeclaration *tdec=new TiXmlDeclaration("1.0","UTF-8",""); + Poco::XML::Element *root=doc->createElement("IdentityIntroduction"); + //TiXmlElement *tid; + //TiXmlPrinter tp; - td.LinkEndChild(tdec); - tid=new TiXmlElement("IdentityIntroduction"); - td.LinkEndChild(tid); + doc->appendChild(root); + //td.LinkEndChild(tdec); + //tid=new TiXmlElement("IdentityIntroduction"); + //td.LinkEndChild(tid); - tid->LinkEndChild(XMLCreateCDATAElement("Identity",m_identity)); + root->appendChild(XMLCreateCDATAElement(doc,"Identity",m_identity)); + //tid->LinkEndChild(XMLCreateCDATAElement("Identity",m_identity)); - td.Accept(&tp); - return std::string(tp.CStr()); + //td.Accept(&tp); + //return std::string(tp.CStr()); + return GenerateXML(doc); } void IdentityIntroductionXML::Initialize() @@ -35,6 +40,41 @@ void IdentityIntroductionXML::Initialize() const bool IdentityIntroductionXML::ParseXML(const std::string &xml) { FreenetSSK ssk; + bool parsed=false; + Poco::XML::DOMParser dp; + + Initialize(); + + try + { + Poco::AutoPtr doc=dp.parseString(FixCDATA(xml)); + Poco::XML::Element *root=XMLGetFirstChild(doc,"IdentityIntroduction"); + Poco::XML::Element *txt=NULL; + + txt=XMLGetFirstChild(root,"Identity"); + if(txt) + { + if(txt->firstChild()) + { + m_identity=SanitizeSingleString(txt->firstChild()->getNodeValue()); + } + } + + ssk.SetPublicKey(m_identity); + if(ssk.ValidPublicKey()==false) + { + return false; + } + + parsed=true; + } + catch(...) + { + } + + return parsed; + + /* TiXmlDocument td; td.Parse(xml.c_str()); @@ -63,5 +103,6 @@ const bool IdentityIntroductionXML::ParseXML(const std::string &xml) { return false; } + */ }