当前位置: 首页>>代码示例>>PHP>>正文


PHP Tinebase_Core::getUserCredentialCache方法代码示例

本文整理汇总了PHP中Tinebase_Core::getUserCredentialCache方法的典型用法代码示例。如果您正苦于以下问题:PHP Tinebase_Core::getUserCredentialCache方法的具体用法?PHP Tinebase_Core::getUserCredentialCache怎么用?PHP Tinebase_Core::getUserCredentialCache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tinebase_Core的用法示例。


在下文中一共展示了Tinebase_Core::getUserCredentialCache方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: resolveCredentials

 /**
  * resolve imap or smtp credentials
  *
  * @param boolean $_onlyUsername
  * @param boolean $_throwException
  * @param boolean $_smtp
  * @return boolean
  */
 public function resolveCredentials($_onlyUsername = TRUE, $_throwException = FALSE, $_smtp = FALSE)
 {
     if ($_smtp) {
         $passwordField = 'smtp_password';
         $userField = 'smtp_user';
         $credentialsField = 'smtp_credentials_id';
     } else {
         $passwordField = 'password';
         $userField = 'user';
         $credentialsField = 'credentials_id';
     }
     if (!$this->{$userField} || !($this->{$passwordField} && !$_onlyUsername)) {
         $credentialsBackend = Tinebase_Auth_CredentialCache::getInstance();
         $userCredentialCache = Tinebase_Core::getUserCredentialCache();
         if ($userCredentialCache !== NULL) {
             try {
                 $credentialsBackend->getCachedCredentials($userCredentialCache);
             } catch (Exception $e) {
                 return FALSE;
             }
         } else {
             Tinebase_Core::getLogger()->crit(__METHOD__ . '::' . __LINE__ . ' Something went wrong with the CredentialsCache');
             return FALSE;
         }
         if ($this->type == self::TYPE_USER) {
             if (!$this->{$credentialsField}) {
                 if ($_throwException) {
                     throw new Felamimail_Exception('Could not get credentials, no ' . $credentialsField . ' given.');
                 } else {
                     return FALSE;
                 }
             }
             try {
                 // NOTE: cache cleanup process might have removed the cache
                 $credentials = $credentialsBackend->get($this->{$credentialsField});
                 $credentials->key = substr($userCredentialCache->password, 0, 24);
                 $credentialsBackend->getCachedCredentials($credentials);
             } catch (Exception $e) {
                 if ($_throwException) {
                     throw $e;
                 } else {
                     return FALSE;
                 }
             }
         } else {
             // just use tine user credentials to connect to mailserver / or use credentials from config if set
             $imapConfig = Tinebase_Config::getInstance()->get(Tinebase_Config::IMAP, new Tinebase_Config_Struct())->toArray();
             $credentials = $userCredentialCache;
             // allow to set credentials in config
             if ((isset($imapConfig['user']) || array_key_exists('user', $imapConfig)) && (isset($imapConfig['password']) || array_key_exists('password', $imapConfig)) && !empty($imapConfig['user'])) {
                 if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
                     Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Using credentials from config for system account.');
                 }
                 $credentials->username = $imapConfig['user'];
                 $credentials->password = $imapConfig['password'];
             }
             // allow to set pw suffix in config
             if ((isset($imapConfig['pwsuffix']) || array_key_exists('pwsuffix', $imapConfig)) && !preg_match('/' . preg_quote($imapConfig['pwsuffix']) . '$/', $credentials->password)) {
                 if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
                     Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Appending configured pwsuffix to system account password.');
                 }
                 $credentials->password .= $imapConfig['pwsuffix'];
             }
             if (!empty($imapConfig['domain']) && strpos($credentials->username, $imapConfig['domain']) === false) {
                 $credentials->username .= '@' . $imapConfig['domain'];
             }
         }
         if (!$this->{$userField}) {
             $this->{$userField} = $credentials->username;
         }
         $this->{$passwordField} = $credentials->password;
     }
     return TRUE;
 }
开发者ID:bitExpert,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:82,代码来源:Account.php

示例2: updateCredentialCache

 /**
  * update user credential cache
  *
  * - fires Tinebase_Event_User_ChangeCredentialCache
  *
  * @param string $password
  * @return array
  */
 public function updateCredentialCache($password)
 {
     $oldCredentialCache = Tinebase_Core::getUserCredentialCache();
     $credentialCache = Tinebase_Auth_CredentialCache::getInstance()->cacheCredentials(Tinebase_Core::getUser()->accountLoginName, $password);
     Tinebase_Core::set(Tinebase_Core::USERCREDENTIALCACHE, $credentialCache);
     $success = $this->_setCredentialCacheCookie();
     if ($success) {
         // close session to allow other requests
         Tinebase_Session::writeClose(true);
         $event = new Tinebase_Event_User_ChangeCredentialCache($oldCredentialCache);
         Tinebase_Event::fireEvent($event);
     }
     return array('success' => $success);
 }
开发者ID:hernot,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:22,代码来源:Json.php

示例3: _setCredentials

 /**
  * set new password & credentials
  * 
  * @param string $_username
  * @param string $_password
  */
 protected function _setCredentials($_username, $_password)
 {
     Tinebase_User::getInstance()->setPassword(Tinebase_Core::getUser(), $_password, true, false);
     $oldCredentialCache = Tinebase_Core::getUserCredentialCache();
     // update credential cache
     $credentialCache = Tinebase_Auth_CredentialCache::getInstance()->cacheCredentials($_username, $_password);
     Tinebase_Core::set(Tinebase_Core::USERCREDENTIALCACHE, $credentialCache);
     $event = new Tinebase_Event_User_ChangeCredentialCache($oldCredentialCache);
     Tinebase_Event::fireEvent($event);
     $this->_pwChanged = true;
 }
开发者ID:bitExpert,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:17,代码来源:AccountTest.php

示例4: loginFromPost

 /**
  * login from HTTP post 
  * 
  * redirects the tine main screen if authentication is successful
  * otherwise redirects back to login url 
  */
 public function loginFromPost($username, $password)
 {
     Tinebase_Core::startCoreSession();
     if (!empty($username)) {
         // try to login user
         $success = Tinebase_Controller::getInstance()->login($username, $password, Tinebase_Core::get(Tinebase_Core::REQUEST), self::REQUEST_TYPE) === TRUE;
     } else {
         $success = FALSE;
     }
     if ($success === TRUE) {
         $this->_setJsonKeyCookie();
         $ccAdapter = Tinebase_Auth_CredentialCache::getInstance()->getCacheAdapter();
         if (Tinebase_Core::isRegistered(Tinebase_Core::USERCREDENTIALCACHE)) {
             $ccAdapter->setCache(Tinebase_Core::getUserCredentialCache());
         } else {
             Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' Something went wrong with the CredentialCache / no CC registered.');
             $success = FALSE;
             $ccAdapter->resetCache();
         }
     }
     $request = new Sabre\HTTP\Request();
     $redirectUrl = str_replace('index.php', '', $request->getAbsoluteUri());
     // authentication failed
     if ($success !== TRUE) {
         $_SESSION = array();
         Tinebase_Session::destroyAndRemoveCookie();
         // redirect back to loginurl if needed
         $redirectUrl = Tinebase_Config::getInstance()->get(Tinebase_Config::REDIRECTURL, $redirectUrl);
     }
     // load the client with GET
     header('Location: ' . $redirectUrl);
 }
开发者ID:hernot,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:38,代码来源:Http.php

示例5: _connect

 /**
  * connects to request tracker
  *
  * @return void
  */
 protected function _connect()
 {
     if (!$this->_config->rest || $this->_config->rest->url) {
         throw new Tinebase_Exception_NotFound('Could not connect to RequestTracker: No REST url given!');
     }
     $config = array('url' => $this->_config->rest->url, 'useragent' => 'Tine 2.0 remote client (rv: 0.2)', 'keepalive' => true);
     $this->_httpClient = new Zend_Http_Client($this->_config->rest->url, $config);
     $this->_httpClient->setCookieJar();
     // login
     $this->_httpClient->setMethod(Zend_Http_Client::POST);
     $this->_httpClient->setUri($this->_config->rest->url . "/REST/1.0/ticket/");
     $loginName = Tinebase_Core::getUser()->accountLoginName;
     if ($this->_config->useCustomCredendials) {
         $this->_httpClient->setAuth($this->_config->customCredentials->{$loginName}->username, $this->_config->customCredentials->{$loginName}->password);
     } else {
         $credentialCache = Tinebase_Core::getUserCredentialCache();
         Tinebase_Auth_CredentialCache::getInstance()->getCachedCredentials($credentialCache);
         $this->_httpClient->setAuth(Tinebase_Core::getUser()->accountLoginName, $credentialCache->password);
     }
     $response = $this->_httpClient->request();
     if ($response->getStatus() != 200) {
         throw new Tinebase_Exception_Record_NotAllowed($response->getMessage(), $response->getStatus());
     }
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:29,代码来源:Rest.php

示例6: _createCredentials

 /**
  * create account credentials and return new credentials id
  *
  * @param string $_username
  * @param string $_password
  * @return string
  */
 protected function _createCredentials($_username = NULL, $_password = NULL, $_userCredentialCache = NULL)
 {
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         $message = 'Create new account credentials';
         if ($_username !== NULL) {
             $message .= ' for username ' . $_username;
         }
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . $message);
     }
     if (Tinebase_Core::isRegistered(Tinebase_Core::USERCREDENTIALCACHE)) {
         $userCredentialCache = Tinebase_Core::getUserCredentialCache();
         Tinebase_Auth_CredentialCache::getInstance()->getCachedCredentials($userCredentialCache);
     } else {
         Tinebase_Core::getLogger()->crit(__METHOD__ . '::' . __LINE__ . ' Something went wrong with the CredentialsCache / use given username/password instead.');
         $userCredentialCache = new Tinebase_Model_CredentialCache(array('username' => $_username, 'password' => $_password));
     }
     $accountCredentials = Tinebase_Auth_CredentialCache::getInstance()->cacheCredentials($_username !== NULL ? $_username : $userCredentialCache->username, $_password !== NULL ? $_password : $userCredentialCache->password, $userCredentialCache->password, TRUE);
     return $accountCredentials->getId();
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:26,代码来源:Account.php

示例7: resolveCredentials

 /**
  * resolve imap or smtp credentials
  *
  * @param boolean $_onlyUsername
  * @param boolean $_throwException
  * @param boolean $_smtp
  * @return boolean
  */
 public function resolveCredentials($_onlyUsername = TRUE, $_throwException = FALSE, $_smtp = FALSE)
 {
     if ($_smtp) {
         $passwordField = 'smtp_password';
         $userField = 'smtp_user';
         $credentialsField = 'smtp_credentials_id';
     } else {
         $passwordField = 'password';
         $userField = 'user';
         $credentialsField = 'credentials_id';
     }
     if (!$this->{$userField} || !($this->{$passwordField} && !$_onlyUsername)) {
         $credentialsBackend = Tinebase_Auth_CredentialCache::getInstance();
         $userCredentialCache = Tinebase_Core::getUserCredentialCache();
         if ($userCredentialCache !== NULL) {
             try {
                 $credentialsBackend->getCachedCredentials($userCredentialCache);
             } catch (Exception $e) {
                 return FALSE;
             }
         } else {
             Tinebase_Core::getLogger()->crit(__METHOD__ . '::' . __LINE__ . ' Something went wrong with the CredentialsCache / use given imap username/password instead.');
             $userCredentialCache = new Tinebase_Model_CredentialCache(array('username' => $this->user, 'password' => $this->password));
         }
         if ($this->type == self::TYPE_USER) {
             if (!$this->{$credentialsField}) {
                 if ($_throwException) {
                     throw new Expressomail_Exception('Could not get credentials, no ' . $credentialsField . ' given.');
                 } else {
                     return FALSE;
                 }
             }
             try {
                 // NOTE: cache cleanup process might have removed the cache
                 $credentials = $credentialsBackend->get($this->{$credentialsField});
                 $credentials->key = substr($userCredentialCache->password, 0, 24);
                 $credentialsBackend->getCachedCredentials($credentials);
             } catch (Exception $e) {
                 if ($_throwException) {
                     throw $e;
                 } else {
                     return FALSE;
                 }
             }
         } else {
             // just use tine user credentials to connect to mailserver / or use credentials from config if set
             $imapConfig = Tinebase_Config::getInstance()->get(Tinebase_Config::IMAP, new Tinebase_Config_Struct())->toArray();
             $credentials = $userCredentialCache;
             if (array_key_exists('user', $imapConfig) && array_key_exists('password', $imapConfig) && !empty($imapConfig['user'])) {
                 $credentials->username = $imapConfig['user'];
                 $credentials->password = $imapConfig['password'];
             }
         }
         $this->{$userField} = $credentials->username;
         $this->{$passwordField} = $credentials->password;
     }
     return TRUE;
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:66,代码来源:Account.php

示例8: getAdapterBackend

 /**
  * get an adapter instance according to the path
  *
  * pathParts:
  * [0] =>
  * [1] => external
  * [2] => accountLogin
  * [3] => adapterName
  * [4..] => path in backend
  *
  * @param string $_path
  * @return Expressodriver_Backend_Adapter_Interface
  * @throws Expressodriver_Exception
  */
 public function getAdapterBackend($_path)
 {
     $pathParts = explode('/', $_path);
     $adapterName = $pathParts[1];
     if (!isset(self::$_backends[$adapterName])) {
         $adapter = null;
         $config = Expressodriver_Controller::getInstance()->getConfigSettings();
         foreach ($config['adapters'] as $adapterConfig) {
             if ($adapterName === $adapterConfig['name']) {
                 $adapter = $adapterConfig;
             }
         }
         if (!is_null($adapter)) {
             $credentialsBackend = Tinebase_Auth_CredentialCache::getInstance();
             $userCredentialCache = Tinebase_Core::getUserCredentialCache();
             $credentialsBackend->getCachedCredentials($userCredentialCache);
             $username = $adapter['useEmailAsLoginName'] ? Tinebase_Core::getUser()->accountEmailAddress : Tinebase_Core::getUser()->accountLoginName;
             $options = array('host' => $adapter['url'], 'user' => $username, 'password' => $userCredentialCache->password, 'root' => '/', 'name' => $adapter['name'], 'useCache' => $config['default']['useCache'], 'cacheLifetime' => $config['default']['cacheLifetime']);
             self::$_backends[$adapterName] = Expressodriver_Backend_Storage_Abstract::factory($adapter['adapter'], $options);
         } else {
             throw new Expressodriver_Exception('Adapter config does not exists');
         }
     }
     return self::$_backends[$adapterName];
 }
开发者ID:bitExpert,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:39,代码来源:Node.php

示例9: _convertVevent


//.........这里部分代码省略.........
                     //
                     //       2. server send his managed id (we are client)
                     //          * we need to download the attachment (here?)
                     //          * we need to have a mapping externalid / internalid (where?)
                     if (!$attachment) {
                         $readFromURL = true;
                         $url = $property->getValue();
                     } else {
                         $attachments->addRecord($attachment);
                     }
                 } elseif ('URI' === $value) {
                     /*
                     * ATTACH;VALUE=URI:https://server.com/calendars/__uids__/0AA0
                      3A3B-F7B6-459A-AB3E-4726E53637D0/dropbox/4971F93F-8657-412B-841A-A0FD913
                      9CD61.dropbox/Canada.png
                     */
                     $url = $property->getValue();
                     $urlParts = parse_url($url);
                     $host = $urlParts['host'];
                     $name = pathinfo($urlParts['path'], PATHINFO_BASENAME);
                     // iCal 10.7 places URI before uploading
                     if (parse_url(Tinebase_Core::getHostname(), PHP_URL_HOST) != $host) {
                         $readFromURL = true;
                     }
                 } else {
                     // @TODO: implement (check if add / update / update is needed)
                     if (Tinebase_Core::isLogLevel(Zend_Log::WARN)) {
                         Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' attachment found that could not be imported due to missing managed id');
                     }
                 }
                 if ($readFromURL) {
                     if (preg_match('#^(https?://)(.*)$#', str_replace(array("\n", "\r"), '', $url), $matches)) {
                         // we are client and found an external hosted attachment that we need to import
                         $userCredentialCache = Tinebase_Core::getUserCredentialCache();
                         $url = $matches[1] . $userCredentialCache->username . ':' . $userCredentialCache->password . '@' . $matches[2];
                         $attachmentInfo = $matches[1] . $matches[2] . ' ' . $name . ' ' . $managedId;
                         if (Tinebase_Helper::urlExists($url)) {
                             if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
                                 Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Downloading attachment: ' . $attachmentInfo);
                             }
                             $stream = fopen($url, 'r');
                             $attachment = new Tinebase_Model_Tree_Node(array('name' => rawurldecode($name), 'type' => Tinebase_Model_Tree_Node::TYPE_FILE, 'contenttype' => (string) $property['FMTTYPE'], 'tempFile' => $stream), true);
                             $attachments->addRecord($attachment);
                         } else {
                             if (Tinebase_Core::isLogLevel(Zend_Log::WARN)) {
                                 Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' Url not found (got 404): ' . $attachmentInfo . ' - Skipping attachment');
                             }
                         }
                     } else {
                         if (Tinebase_Core::isLogLevel(Zend_Log::WARN)) {
                             Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' Attachment found with malformed url: ' . $url);
                         }
                     }
                 }
                 break;
             case 'X-MOZ-LASTACK':
                 $lastAck = $this->_convertToTinebaseDateTime($property);
                 break;
             case 'X-MOZ-SNOOZE-TIME':
                 $snoozeTime = $this->_convertToTinebaseDateTime($property);
                 break;
             default:
                 // thunderbird saves snooze time for recurring event occurrences in properties with names like this -
                 // we just assume that the event/recur series has only one snooze time
                 if (preg_match('/^X-MOZ-SNOOZE-TIME-[0-9]+$/', $property->name)) {
                     $snoozeTime = $this->_convertToTinebaseDateTime($property);
开发者ID:bitExpert,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:67,代码来源:Abstract.php


注:本文中的Tinebase_Core::getUserCredentialCache方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。