function loadElectionModules($httpRawPostData, $electionIdPlace) { // getpermission: $reqdecoded['electionId'] global $dbInfos, $numVerifyBallots, $numSignBallots, $pServerKeys, $serverkey, $numAllBallots, $numPSigsRequiered; $dbElections = new DbElections($dbInfos); $reqdecoded = json_decode($httpRawPostData, true); if ($reqdecoded == null) { WrongRequestException::throwException(7040, 'Data in JSON format expected', 'got: ' . $HTTP_RAW_POST_DATA); } // if (! isset($electionIdPlace($reqdecoded))) WrongRequestException::throwException(7010, 'Election id missing in client request' , $httpRawPostData); if (!is_string($electionIdPlace($reqdecoded))) { WrongRequestException::throwException(7050, 'Election id must be a string', 'got: ' . print_r($reqdecoded['electionId'], true)); } // load election config from database by election id $completeElectionId = $electionIdPlace($reqdecoded); $splittedElectionId = json_decode($completeElectionId); if ($splittedElectionId == null) { $mainElectionId = $completeElectionId; } else { $mainElectionId = $splittedElectionId->mainElectionId; } $elconfig = $dbElections->loadElectionConfigFromElectionId($mainElectionId); if (count($elconfig) < 1) { WrongRequestException::throwException(7000, 'Election id not found in server database', "ElectionId you sent: " . $reqdecoded['electionId']); } if (!isset($elconfig['auth'])) { WrongRequestException::throwException(7020, 'element auth not found in election config', "ElectionId you sent: " . $reqdecoded['electionId']); } $auth = LoadModules::laodAuthModule($elconfig['auth']); if (isset($elconfig['authConfig'])) { $auth->setup($elconfig["electionId"], $elconfig['authConfig']); } // TODO think about: should Election be any Election or just the blinding module? $blinder = LoadModules::loadBlinder($elconfig['blinding'], $elconfig, $auth); $blinder->tally = LoadModules::loadTally($elconfig['tally'], $blinder); // TODO use a different private key for tallying server $blinder->tally->setup($elconfig); return $blinder; }
function newElection($electionId, $subAuth, $subAuthData) { // $this->db->newElection($electionId, $subAuthModule); $this->subAuth = $subAuth; $this->subAuthData = $subAuthData; $this->subAuthModule = LoadModules::laodAuthModule($subAuth); $subAuthRet = $this->subAuthModule->handleNewElectionReq($electionId, $subAuthData); return array('auth' => $subAuth, 'authConfig' => $subAuthRet); }