1 #include "../../include/http/identityexportxml.h"
\r
7 IdentityExportXML::IdentityExportXML()
\r
12 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)
\r
14 m_identities.push_back(identity(name,publickey,privatekey,singleuse,publishtrustlist,publishboardlist,publishfreesite));
\r
17 const std::string IdentityExportXML::GetName(const long index)
\r
19 if(index>=0 && index<GetCount())
\r
21 return m_identities[index].m_name;
\r
29 const std::string IdentityExportXML::GetPrivateKey(const long index)
\r
31 if(index>=0 && index<GetCount())
\r
33 return m_identities[index].m_privatekey;
\r
41 const std::string IdentityExportXML::GetPublicKey(const long index)
\r
43 if(index>=0 && index<GetCount())
\r
45 return m_identities[index].m_publickey;
\r
53 const bool IdentityExportXML::GetPublishBoardList(const long index)
\r
55 if(index>=0 && index<GetCount())
\r
57 return m_identities[index].m_publishboardlist;
\r
65 const bool IdentityExportXML::GetPublishFreesite(const long index)
\r
67 if(index>=0 && index<GetCount())
\r
69 return m_identities[index].m_publishfreesite;
\r
77 const bool IdentityExportXML::GetPublishTrustList(const long index)
\r
79 if(index>=0 && index<GetCount())
\r
81 return m_identities[index].m_publishtrustlist;
\r
89 const bool IdentityExportXML::GetSingleUse(const long index)
\r
91 if(index>=0 && index<GetCount())
\r
93 return m_identities[index].m_singleuse;
\r
101 std::string IdentityExportXML::GetXML()
\r
103 Poco::AutoPtr<Poco::XML::Document> doc=new Poco::XML::Document;
\r
104 Poco::AutoPtr<Poco::XML::Element> root=doc->createElement("IdentityExport");
\r
105 Poco::AutoPtr<Poco::XML::Element> el=NULL;
\r
107 doc->appendChild(root);
\r
109 for(std::vector<identity>::iterator i=m_identities.begin(); i!=m_identities.end(); i++)
\r
111 el=doc->createElement("Identity");
\r
112 root->appendChild(el);
\r
114 el->appendChild(XMLCreateCDATAElement(doc,"Name",(*i).m_name));
\r
115 el->appendChild(XMLCreateTextElement(doc,"PublicKey",(*i).m_publickey));
\r
116 el->appendChild(XMLCreateTextElement(doc,"PrivateKey",(*i).m_privatekey));
\r
117 el->appendChild(XMLCreateBooleanElement(doc,"SingleUse",(*i).m_singleuse));
\r
118 el->appendChild(XMLCreateBooleanElement(doc,"PublishTrustList",(*i).m_publishtrustlist));
\r
119 el->appendChild(XMLCreateBooleanElement(doc,"PublishBoardList",(*i).m_publishboardlist));
\r
120 el->appendChild(XMLCreateBooleanElement(doc,"PublishFreesite",(*i).m_publishfreesite));
\r
123 return GenerateXML(doc);
\r
126 void IdentityExportXML::Initialize()
\r
128 m_identities.clear();
\r
131 const bool IdentityExportXML::ParseXML(const std::string &xml)
\r
134 Poco::XML::DOMParser dp;
\r
140 Poco::AutoPtr<Poco::XML::Document> doc=dp.parseString(FixCDATA(xml));
\r
141 Poco::XML::Element *root=XMLGetFirstChild(doc,"IdentityExport");
\r
142 Poco::XML::Element *node=XMLGetFirstChild(root,"Identity");
\r
146 std::string name="";
\r
147 std::string publickey="";
\r
148 std::string privatekey="";
\r
149 bool singleuse=false;
\r
150 bool publishtrustlist=false;
\r
151 bool publishboardlist=false;
\r
152 bool publishfreesite=false;
\r
154 Poco::XML::Element *text=XMLGetFirstChild(node,"Name");
\r
157 if(text->firstChild())
\r
159 std::string asdf=text->innerText();
\r
160 asdf=text->firstChild()->innerText();
\r
161 name=text->firstChild()->getNodeValue();
\r
164 text=XMLGetFirstChild(node,"PublicKey");
\r
167 if(text->firstChild())
\r
169 publickey=text->firstChild()->getNodeValue();
\r
172 text=XMLGetFirstChild(node,"PrivateKey");
\r
175 if(text->firstChild())
\r
177 privatekey=text->firstChild()->getNodeValue();
\r
181 singleuse=XMLGetBooleanElement(node,"SingleUse");
\r
182 publishtrustlist=XMLGetBooleanElement(node,"PublishTrustList");
\r
183 publishboardlist=XMLGetBooleanElement(node,"PublishBoardList");
\r
184 publishfreesite=XMLGetBooleanElement(node,"PublishFreesite");
\r
186 if(name!="" && publickey!="" && privatekey!="")
\r
188 m_identities.push_back(identity(name,publickey,privatekey,singleuse,publishtrustlist,publishboardlist,publishfreesite));
\r
191 node=XMLGetNextSibling(node,"Identity");
\r