/** * decryptes username and password * * @param Tinebase_Model_CredentialCache $_cache * @return void */ protected function _decrypt($_cache) { $encryptedData = base64_decode($_cache->cache); $td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', 'cbc', ''); mcrypt_generic_init($td, $_cache->key, substr($_cache->getId(), 0, 16)); $cacheData = Zend_Json::decode(trim(mdecrypt_generic($td, $encryptedData))); $_cache->username = $cacheData['username']; $_cache->password = $cacheData['password']; mcrypt_generic_deinit($td); mcrypt_module_close($td); }
/** * decrypts username and password * * @param Tinebase_Model_CredentialCache $_cache * @throws Tinebase_Exception_NotFound * @throws Tinebase_Exception_SystemGeneric */ protected function _decrypt($_cache) { if (!extension_loaded('mcrypt')) { throw new Tinebase_Exception_SystemGeneric('mcrypt extension required'); } $encryptedData = base64_decode($_cache->cache); $td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', 'cbc', ''); mcrypt_generic_init($td, $_cache->key, substr($_cache->getId(), 0, 16)); $jsonEncodedData = trim(mdecrypt_generic($td, $encryptedData)); $cacheData = Tinebase_Helper::jsonDecode($jsonEncodedData); mcrypt_generic_deinit($td); mcrypt_module_close($td); if (!isset($cacheData['username']) && !isset($cacheData['password'])) { throw new Tinebase_Exception_NotFound('could not find valid credential cache'); } $_cache->username = $cacheData['username']; $_cache->password = $cacheData['password']; }