<%@ page class="TestUserGenerator" %> <%@ page form="true" %> <%@ page baseClass="PageRequestMessagedHandler" %> <%@ header include="HTTPInterface/PageRequestMessagedHandler.h" %> <%! #include "Crypto/SecretKeyCryptography.h" #include "Crypto/KeyPairEd25519.h" #include "ServerConfig.h" #include "lib/DataTypeConverter.h" #include "controller/User.h" %> <%% const char* pageName = "Test User Generator"; // needed for header_large auto user = controller::User::create(); std::string email; std::string password_hashed; std::string pubkey_hex; std::string privkey_hex_encrypted; std::string passphrase_str; bool user_created = false; // add if(!form.empty()) { email = form.get("email", ""); auto password = form.get("password", ""); if(email == "") { addError(new Error("Create User", "E-Mail is empty!")); } else if(password == "") { addError(new Error("Create User", "Password is empty!")); } else { auto passphrase = Passphrase::generate(&ServerConfig::g_Mnemonic_WordLists[ServerConfig::MNEMONIC_BIP0039_SORTED_ORDER]); passphrase_str = passphrase->getString(); auto key_pair = KeyPairEd25519::create(passphrase); Poco::AutoPtr secret_key = new SecretKeyCryptography; secret_key->createKey(email, password); password_hashed = std::to_string(secret_key->getKeyHashed()); auto privkey_encrypted = key_pair->getCryptedPrivKey(secret_key); privkey_hex_encrypted = DataTypeConverter::binToHex(privkey_encrypted); pubkey_hex = key_pair->getPublicKeyHex(); user_created = true; delete key_pair; } } // select all auto groups = controller::Group::listAll(); //auto groups = controller::Group::load("gdd1"); //std::vector> groups; %><%@ include file="include/header_large.cpsp" %> <%= getErrorsHtml() %>

Einen neuen User anlegen

<% if(user_created) { %>

Generierte Daten

E-Mail
<%= email %>
Password hash
<%= password_hashed %>
public key
0x<%= pubkey_hex %>
private key encrypted
0x<%= privkey_hex_encrypted %>
Passphrase
<%= passphrase_str %>
'<%= email %>', <%= password_hashed %>, 0x<%= pubkey_hex %>, 0x<%= privkey_hex_encrypted %>
<% } %>
<%@ include file="include/footer.cpsp" %>