protected function decodeResponse($received)
 {
     $aes = new Crypt_AES();
     $aes->setKey($this->key);
     $data = $aes->decrypt(base64_decode(substr($received, 28)));
     $decoder = new XmlrpcDecoder();
     return $decoder->decodeResponse($data);
 }
Exemple #2
0
 /**
  * Uncan the provided payload
  *
  * @param string $payload
  *
  * @return mixed
  * @throws \Comodojo\Exception\RpcException
  */
 private function uncan($payload)
 {
     $decoded = null;
     if (empty($payload) || !is_string($payload)) {
         throw new RpcException("Invalid Request", -32600);
     }
     if (substr($payload, 0, 27) == 'comodojo_encrypted_request-') {
         if (empty($this->encrypt)) {
             throw new RpcException("Transport error", -32300);
         }
         $this->request_is_encrypted = true;
         $aes = new Crypt_AES();
         $aes->setKey($this->encrypt);
         $payload = $aes->decrypt(base64_decode(substr($payload, 27)));
         if ($payload == false) {
             throw new RpcException("Transport error", -32300);
         }
     }
     if ($this->protocol == 'xml') {
         $decoder = new XmlrpcDecoder();
         try {
             $decoded = $decoder->decodeCall($payload);
         } catch (XmlrpcException $xe) {
             throw new RpcException("Parse error", -32700);
         }
     } else {
         if ($this->protocol == 'json') {
             if (strtolower($this->encoding) != 'utf-8') {
                 $payload = mb_convert_encoding($payload, "UTF-8", strtoupper($this->encoding));
             }
             $decoded = json_decode($payload, false);
             if (is_null($decoded)) {
                 throw new RpcException("Parse error", -32700);
             }
         } else {
             throw new RpcException("Transport error", -32300);
         }
     }
     return $decoded;
 }
 protected function decodeResponse($received)
 {
     $decoder = new XmlrpcDecoder();
     return $decoder->decodeResponse($received);
 }
Exemple #4
0
 /**
  * Decodes response string into array.
  *
  * @param $response
  *
  * @return array
  *
  * @throws XmlrpcException
  */
 protected function decode($response)
 {
     $this->decoder = $this->decoder ?: new XmlrpcDecoder();
     return $this->decoder->decodeResponse($response);
 }