private function renderContent() { $result = null; if (!isset($_GET['crypt'])) { return null; } $crypt_module = $_GET['crypt']; if (!isset(Config::$crypt_info[$crypt_module])) { echo sprintf(Messages::getString('GenKeyPage.EncryptionModuleNotFound'), $crypt_module); return null; } $current = intval($_GET['current']); $max = intval($_GET['max']); if ($current > $max) { echo sprintf(Messages::getString('GenKeyPage.IndexError'), $current, $max); return null; } try { //Now generate the key echo sprintf(" " . Messages::getString('GenKeyPage.Generating'), $current, $max); flush(); $db = Database::getInstance(); $project_id = $this->project->getId(); $member_id = $db->getNextMemberId($project_id); $crypt = new CryptProxy($crypt_module, $project_id, $member_id); $pw_gen = new ConfiguredPasswordGenerator(); $password = $pw_gen->generatePassword(); $crypt_data = $crypt->generateCryptData($password); if (!$db->createRkey($project_id, $member_id, $crypt_module, $crypt_data)) { echo Messages::getString('GenKeyPage.ErrorInsertingRKey'); return null; } $rkey = new RKey($project_id, $member_id); $result = array($rkey, $password); echo ' ' . Messages::getString('GenKeyPage.Finished'); flush(); } catch (Exception $e) { echo $e; return null; } return $result; }
private function renderContent() { $result = null; if (!isset($_GET['crypt'])) { return null; } $crypt_module = $_GET['crypt']; if (!isset(MainConfig::$crypt_info[$crypt_module])) { echo "Encryption module {$crypt_module} not found."; return null; } $current = intval($_GET['current']); $max = intval($_GET['max']); if ($current > $max) { echo sprintf("Index error: %d/%d", $current, $max); return null; } try { //Now generate the key echo sprintf('Generating R-Key %d of %d...', $current, $max); flush(); $db = Database::getInstance(); $project_id = $this->project->getId(); $member_id = $db->getNextMemberId($project_id); $crypt = new CryptProxy($crypt_module); $pw_gen = new ConfiguredPasswordGenerator(); $password = $pw_gen->generatePassword(); $crypt_data = $crypt->generateCryptData($password); if (!$db->createRkey($project_id, $member_id, $crypt_module, $crypt_data)) { echo "Error inserting RKey!"; return null; } $rkey = new RKey($project_id, $member_id); $result = array($rkey, $password); echo " finished."; flush(); } catch (Exception $e) { echo $e; return null; } return $result; }