private function _setCRL(SSLCRL &$crl, $insertMode = FALSE) { $method = "PUT"; $url = E3_PROV_URL_TRUSTSTORE . "/crls/" . rawurlencode($crl->getId()); if ($insertMode) { $method = "POST"; $url = E3_PROV_URL_TRUSTSTORE . "/crls"; } /** * Send the XML payload the the Provisioning Backend */ LoggerInterface::log(($insertMode ? "Creating" : "Updating") . " CRL: {$crl->toXML()}\nEndpoint: ({$method}) {$url}", LoggerInterface::INFO); $reply = $this->restClient->makeCall($url, $method, $crl->toXML()); $xml = simplexml_load_string($reply->getPayload()); if ($reply->getHTTPCode() === "200") { if ($insertMode) { if ($crl->getId() == NULL) { $crl->setId((string) $xml->id); } } return $crl; } else { throw new Exception(!empty($xml->error) ? $xml->error->errorText : UNDEFINED_ERROR_TEXT); } }
private function validateFormAndGetCRL(&$validationErrors) { $registry = Zend_Registry::getInstance(); $translate = $registry->get("Zend_Translate"); $validationErrors = array(); $crl = new SSLCRL(); $validate_alnum_wspace = new Zend_Validate_Alnum(array('allowWhiteSpace' => true)); // TODO: validate id field? $id = $_POST['crl_id']; $crl->setId($id); $name = $_POST['crl_name']; if (!$validate_alnum_wspace->isValid($name)) { $validationErrors['crl_name'] = $translate->translate("The CRL name must be only alpha-numeric characters"); } $crl->setDisplayName($_POST['crl_name']); if (isset($_FILES['crl_file']) && !empty($_FILES['crl_file']['name'])) { if (!$_FILES['crl_file']['error']) { $contents = file_get_contents($_FILES['crl_file']['tmp_name']); if ($contents !== false) { $crl->setContent($contents); } else { $validationErrors['crl_file'] = $translate->translate("There was an error getting contents of CRL file."); } } else { $validationErrors['crl_file'] = $translate->translate("There was an error uploading file: ") . $_FILES['content']['error']; } } else { if (empty($id)) { $validationErrors['crl_file'] = $translate->translate("Please upload a CRL file."); } } return $crl; }