/** * Creates a new instance. * * @param string $baseUrl The base url for the request * @param string $path The request path * @param string $method The request method * @param string $cookies The session cookies * @param string $data The data to send with the request * @param string $headersOnly Whether or not to retrieve only headers (exclusive) * @param string $headers The request headers to set; */ public function __construct($baseUrl, $path, $method, $cookies = null, $data = [], $headersOnly = false, $headers = []) { parent::__construct($path, $method, $data); $this->baseUrl = $baseUrl; $this->cookies = $cookies; $this->headersOnly = $headersOnly; $this->headers = $headers; }
protected function _loadFromXml(\DOMElement $elem) { parent::_parseFromXml($elem); //SMS request specific data $elems = $elem->getElementsByTagName('service'); if ($elems->length != 1) { throw new \Exception('Sms::loadFromXml failed: service is missing', self::ERROR_LOAD_FROM_XML_SERVICE_ELEM_MISSING); } $xmlElem = $elems->item(0); $this->service = $xmlElem->nodeValue; $elems = $elem->getElementsByTagName('msisdn'); if ($elems->length == 1) { $this->msisdn = $elems->item(0)->nodeValue; } $elem = $elem; return $this; }
public static function factoryFromEncrypted($envKey, $encData, $privateKeyFilePath, $privateKeyPassword = null) { $privateKey = null; if ($privateKeyPassword == null) { $privateKey = @openssl_get_privatekey($privateKeyFilePath); if ($privateKey === false) { $privateKey = @openssl_get_privatekey("file://{$privateKeyFilePath}"); } } else { $privateKey = @openssl_get_privatekey($privateKeyFilePath, $privateKeyPassword); if ($privateKey === false) { $privateKey = @openssl_get_privatekey("file://{$privateKeyFilePath}", $privateKeyPassword); } } if ($privateKey === false) { throw new \Exception('Error loading private key', self::ERROR_CONFIRM_LOAD_PRIVATE_KEY); } $srcData = base64_decode($encData); if ($srcData === false) { @openssl_free_key($privateKey); throw new \Exception('Failed decoding data', self::ERROR_CONFIRM_FAILED_DECODING_DATA); } $srcEnvKey = base64_decode($envKey); if ($srcEnvKey === false) { throw new \Exception('Failed decoding envelope key', self::ERROR_CONFIRM_FAILED_DECODING_ENVELOPE_KEY); } $data = null; $result = @openssl_open($srcData, $data, $srcEnvKey, $privateKey); if ($result === false) { throw new \Exception('Failed decrypting data', self::ERROR_CONFIRM_FAILED_DECRYPT_DATA); } return RequestAbstract::factory($data); }