+\r
+ // check if last part of UUID matches first part of public key of identity who inserted it\r
+ st=m_db->Prepare("SELECT PublicKey FROM tblIdentity WHERE IdentityID=?;");\r
+ st.Bind(0,identityid);\r
+ st.Step();\r
+ if(st.RowReturned())\r
+ {\r
+ std::vector<std::string> uuidparts;\r
+ std::vector<std::string> keyparts;\r
+ std::string keypart="";\r
+ std::string publickey="";\r
+\r
+ st.ResultText(0,publickey);\r
+\r
+ StringFunctions::SplitMultiple(publickey,"@,",keyparts);\r
+ StringFunctions::SplitMultiple(xml.GetUUID(),"@",uuidparts);\r
+\r
+ if(uuidparts.size()>1 && keyparts.size()>1)\r
+ {\r
+ keypart=StringFunctions::Replace(StringFunctions::Replace(keyparts[1],"-",""),"~","");\r
+ if(keypart!=uuidparts[1])\r
+ {\r
+ m_log->error("IntroductionPuzzleRequester::HandleAllData UUID in IntroductionPuzzle doesn't match public key of identity : "+message["Identifier"]);\r
+ validmessage=false;\r
+ }\r
+ }\r
+ else\r
+ {\r
+ m_log->error("IntroductionPuzzleRequester::HandleAllData Error with identity's public key or UUID : "+message["Identifier"]);\r
+ validmessage=false;\r
+ }\r
+\r
+ }\r
+ else\r
+ {\r
+ m_log->error("IntroductionPuzzleRequester::HandleAllData Error couldn't find identity : "+message["Identifier"]);\r
+ validmessage=false;\r
+ }\r
+\r
+ // we can only validate bitmaps for now\r
+ BitmapValidator val;\r
+ val.SetMax(200,200);\r
+ std::vector<unsigned char> puzzledata;\r
+ Base64::Decode(xml.GetPuzzleData(),puzzledata);\r
+ if(xml.GetMimeType()!="image/bmp" || val.Validate(puzzledata)==false)\r
+ {\r
+ m_log->error("IntroductionPuzzleRequester::HandleAllData received bad mime type and/or data for "+message["Identifier"]);\r
+ validmessage=false;\r
+ }\r
+\r