#include "TranslatePassphrase.h" #include "Poco/Net/HTTPServerRequest.h" #include "Poco/Net/HTTPServerResponse.h" #include "Poco/Net/HTMLForm.h" #include "Poco/DeflatingStream.h" #line 7 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\translatePassphrase.cpsp" #include "../Crypto/KeyPairEd25519.h" #include "../ServerConfig.h" #line 1 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header.cpsp" #include "../ServerConfig.h" TranslatePassphrase::TranslatePassphrase(Session* arg): SessionHTTPRequestHandler(arg) { } void TranslatePassphrase::handleRequest(Poco::Net::HTTPServerRequest& request, Poco::Net::HTTPServerResponse& response) { response.setChunkedTransferEncoding(true); response.setContentType("text/html"); bool _compressResponse(request.hasToken("Accept-Encoding", "gzip")); if (_compressResponse) response.set("Content-Encoding", "gzip"); Poco::Net::HTMLForm form(request, request.stream()); #line 11 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\translatePassphrase.cpsp" chooseLanguage(request); // variable needed for flags auto lang = mSession->getLanguage(); auto uri_start = ServerConfig::g_serverPath; const char* pageName = gettext("Passphrase Transformieren"); std::string passphrase; auto role = mSession->getNewUser()->getModel()->getRole(); std::string inputPassphrase; Mnemonic* wordSource = &ServerConfig::g_Mnemonic_WordLists[ServerConfig::MNEMONIC_BIP0039_SORTED_ORDER]; Mnemonic* targetSource = &ServerConfig::g_Mnemonic_WordLists[ServerConfig::MNEMONIC_GRADIDO_BOOK_GERMAN_RANDOM_ORDER_FIXED_CASES]; if(lang == LANG_DE) { wordSource = &ServerConfig::g_Mnemonic_WordLists[ServerConfig::MNEMONIC_GRADIDO_BOOK_GERMAN_RANDOM_ORDER_FIXED_CASES]; targetSource = &ServerConfig::g_Mnemonic_WordLists[ServerConfig::MNEMONIC_BIP0039_SORTED_ORDER]; } if(!form.empty()) { inputPassphrase = form.get("inputPassphrase", ""); auto localPassphrase = Passphrase::filter(inputPassphrase); auto btnGenerate = form.get("btnGenerate", ""); if("" != btnGenerate) { auto passphrase_gen = Passphrase::generate(wordSource); localPassphrase = passphrase_gen->getString(); inputPassphrase = localPassphrase; } auto passphrase_object = Passphrase::create(localPassphrase, wordSource); if(localPassphrase != "" && passphrase_object.isNull() || !passphrase_object->checkIfValid()) { addError(new Error( gettext("Fehler"), gettext("Diese Passphrase ist ungültig, bitte überprüfen oder neu generieren (lassen).") ), false); } else { if(wordSource == &ServerConfig::g_Mnemonic_WordLists[ServerConfig::MNEMONIC_BIP0039_SORTED_ORDER]) { targetSource = &ServerConfig::g_Mnemonic_WordLists[ServerConfig::MNEMONIC_GRADIDO_BOOK_GERMAN_RANDOM_ORDER_FIXED_CASES]; } else { targetSource = &ServerConfig::g_Mnemonic_WordLists[ServerConfig::MNEMONIC_BIP0039_SORTED_ORDER]; } auto transformed_passphrase_obj = passphrase_object->transform(targetSource); passphrase = transformed_passphrase_obj->getString(); } } #line 3 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header.cpsp" bool withMaterialIcons = false; std::ostream& _responseStream = response.send(); Poco::DeflatingOutputStream _gzipStream(_responseStream, Poco::DeflatingStreamBuf::STREAM_GZIP, 1); std::ostream& responseStream = _compressResponse ? _gzipStream : _responseStream; responseStream << "\n"; // begin include login_header.cpsp // begin include header.cpsp responseStream << "\n"; responseStream << "\n"; responseStream << "\n"; responseStream << "\n"; responseStream << "\n"; responseStream << "\n"; responseStream << "Gradido Login Server: "; #line 11 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header.cpsp" responseStream << ( pageName ); responseStream << "\n"; responseStream << "\n"; #line 13 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header.cpsp" if(withMaterialIcons) { responseStream << "\n"; responseStream << "\n"; #line 15 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\header.cpsp" } responseStream << "\n"; responseStream << "\n"; responseStream << "\n"; responseStream << "
\n"; responseStream << "
\n"; responseStream << " "; // end include header.cpsp responseStream << "\n"; responseStream << "
\n"; responseStream << " \n"; responseStream << "
\n"; responseStream << "
\n"; responseStream << "
\n"; responseStream << "
\n"; responseStream << " "; #line 18 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\login_header.cpsp" responseStream << ( getErrorsHtml() ); responseStream << "\n"; responseStream << "
\n"; responseStream << "
"; // end include login_header.cpsp // begin include flags.cpsp responseStream << "
\n"; responseStream << "
\n"; responseStream << "\t\n"; responseStream << "\t\n"; responseStream << "
\n"; responseStream << "
"; // end include flags.cpsp responseStream << "\n"; responseStream << "
\n"; responseStream << "\t

"; #line 61 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\translatePassphrase.cpsp" responseStream << ( gettext("Passphrase umwandeln") ); responseStream << "

\n"; responseStream << "
\n"; responseStream << "
\n"; responseStream << "
\n"; responseStream << "
\n"; responseStream << "\t
\n"; responseStream << "\t
\n"; responseStream << "\t\t
\n"; responseStream << "\t\t
"; #line 69 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\translatePassphrase.cpsp" responseStream << ( gettext("Was zu tun ist:") ); responseStream << "
\n"; responseStream << "\t\t

"; #line 70 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\translatePassphrase.cpsp" responseStream << ( gettext("Kopiere/schreibe deine Passphrase in die Textbox und du bekommst sie in die jeweils andere Sprache umgewandelt.") ); responseStream << "

\n"; responseStream << "\t\t

"; #line 71 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\translatePassphrase.cpsp" responseStream << ( gettext("Du kannst mit beiden Varianten dein Konto wiederherstellen oder dein Passwort ändern.") ); responseStream << "

\n"; responseStream << "\t\t
\n"; responseStream << "\t
\n"; responseStream << "\t
\n"; responseStream << "\t\t
\n"; responseStream << "\t\t
\n"; responseStream << "\t\t\t\n"; responseStream << "\t\t
\n"; responseStream << "\t\t \n"; responseStream << "\t\t "; #line 80 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\translatePassphrase.cpsp" if(model::table::ROLE_ADMIN == role) { responseStream << "\n"; responseStream << "\t\t\t\n"; responseStream << "\t\t "; #line 82 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\translatePassphrase.cpsp" } responseStream << "\n"; responseStream << "\t\t
\n"; responseStream << "\t
\n"; responseStream << "\t "; #line 85 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\translatePassphrase.cpsp" if(passphrase != "") { responseStream << "\n"; responseStream << "\t\t
\n"; responseStream << "\t\t\t
\n"; responseStream << "\t\t\t\t
Umgewandelte Passphrase:
\n"; responseStream << "\t\t\t\t

"; #line 89 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\translatePassphrase.cpsp" responseStream << ( passphrase ); responseStream << "

\n"; responseStream << "\t\t\t
\n"; responseStream << "\t\t
\n"; responseStream << "\t "; #line 92 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\translatePassphrase.cpsp" } responseStream << "\n"; responseStream << "\t
\n"; responseStream << "\t
\n"; responseStream << "
\n"; // begin include footer_ripple.cpsp responseStream << "\t\t\t
\n"; responseStream << "\t\t
\n"; responseStream << " \n"; responseStream << " \n"; responseStream << "
\n"; responseStream << "
\n"; responseStream << "
\n"; responseStream << " \n"; responseStream << "
\n"; responseStream << "
\n"; responseStream << " Copyright © 2020 Gradido\n"; responseStream << "
\n"; responseStream << "
\n"; responseStream << "
\n"; responseStream << " \n"; responseStream << "
\n"; responseStream << " \n"; responseStream << "
\n"; responseStream << "
\n"; responseStream << " "; #line 23 "F:\\Gradido\\gradido_login_server\\src\\cpsp\\footer_ripple.cpsp" responseStream << ( mTimeProfiler.string() ); responseStream << "\n"; responseStream << "
\n"; responseStream << " \n"; responseStream << " \n"; responseStream << " \n"; responseStream << " \n"; responseStream << " \n"; responseStream << " \n"; responseStream << " \n"; responseStream << " \n"; responseStream << " \n"; responseStream << " \n"; responseStream << " \n"; responseStream << " \n"; responseStream << " \n"; responseStream << " \n"; responseStream << " \n"; responseStream << "\n"; responseStream << " "; // end include footer_ripple.cpsp if (_compressResponse) _gzipStream.close(); }