/** * caches given credentials * * @param string $username * @param string $password * @param string $key [optional] * @param boolean $persist * @param Tinebase_DateTime $validUntil * @return Tinebase_Model_CredentialCache */ public function cacheCredentials($username, $password, $key = NULL, $persist = FALSE, $validUntil = null) { $key = $key !== NULL ? $key : $this->_cacheAdapter->getDefaultKey(); $cache = new Tinebase_Model_CredentialCache(array('id' => $this->_cacheAdapter->getDefaultId(), 'key' => substr($key, 0, 24), 'username' => $username, 'password' => $password, 'creation_time' => Tinebase_DateTime::now(), 'valid_until' => $validUntil ?: Tinebase_DateTime::now()->addMonth(1)), true, false); $cache->convertDates = true; $this->_encrypt($cache); $this->_saveInSession($cache); if ($persist) { $this->_persistCache($cache); } return $cache; }
/** * caches given credentials * * @param string $_username * @param string $_password * @param string $_key [optional] * @return Tinebase_Model_CredentialCache */ public function cacheCredentials($_username, $_password, $_key = NULL) { $key = $_key !== NULL ? $_key : $this->_cacheAdapter->getDefaultKey(); $cache = new Tinebase_Model_CredentialCache(array('id' => $this->_cacheAdapter->getDefaultId(), 'key' => substr($key, 0, 24), 'username' => $_username, 'password' => $_password, 'creation_time' => Tinebase_DateTime::now(), 'valid_until' => Tinebase_DateTime::now()->addMonth(1)), true, false); $cache->convertDates = true; $this->_encrypt($cache); // need to check if entry exists (some adapters can have static ids) try { $this->create($cache); } catch (Zend_Db_Statement_Exception $zdse) { $this->update($cache); } return $cache; }