/** * Attention, this function is NOT PUBLIC!!! The only reason it's public is due to PHP 5.3 limitations * @protected * @param $pubnubMessage * @return bool * @throws Exception */ public function notify($pubnubMessage) { $message = $pubnubMessage['message']; //TODO Since pubnub blocks everything this is probably the only place where we can intercept the process and do subscription renew //$this->renew(); if (!$this->alive()) { throw new Exception('Subscription is not alive'); } if ($this->_subscription['deliveryMode']['encryption'] && $this->_subscription['deliveryMode']['encryptionKey']) { $aes = new PubnubAES(); $message = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, base64_decode($this->_subscription['deliveryMode']['encryptionKey']), base64_decode($message), MCRYPT_MODE_ECB); $message = Utils::json_parse($aes->unPadPKCS7($message, 128), true); // PUBNUB itself always decode as array } //print 'Message received: ' . $message . PHP_EOL; $this->dispatch(self::EVENT_NOTIFICATION, new NotificationEvent($message)); return $this->_keepPolling; }
protected function decrypt($message) { if (!$this->subscribed()) { throw new Exception('No subscription'); } if ($this->_subscription['deliveryMode']['encryption'] && $this->_subscription['deliveryMode']['encryptionKey']) { $aes = new PubnubAES(); $message = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, base64_decode($this->_subscription['deliveryMode']['encryptionKey']), base64_decode($message), MCRYPT_MODE_ECB); $message = Utils::json_parse($aes->unPadPKCS7($message, 128), true); // PUBNUB itself always decode as array } return $message; }
/** * @group aes */ public function testAESunpadPKCS7() { $this->assertEquals("", $this->aes->unpadPKCS7("", 1)); }