/** * Ask PDP for access. * * @return \Pdp_PolicyResponse * @throws \EngineBlock_Exception */ protected function requestAccess() { $httpClient = new Zend_Http_Client($this->baseUrl); try { $result = $httpClient->setConfig(array('timeout' => 15))->setAuth($this->username, $this->password, Zend_Http_Client::AUTH_BASIC)->setRawData($this->policyRequest->toJson())->setEncType('application/json')->request('POST'); if ($result->getStatus() != '200') { $error = "Received invalid HTTP " . $result->getStatus() . "response from PDP"; EngineBlock_ApplicationSingleton::getLog()->error($error); throw new EngineBlock_Exception($error); } } catch (Zend_Http_Client_Exception $e) { EngineBlock_ApplicationSingleton::getLog()->error($e->getMessage()); throw new EngineBlock_Exception($e->getMessage()); } $this->policyResponse = new Pdp_PolicyResponse($result->getBody()); return $this->policyResponse; }