public function setAuth($authId, $credentials, array $options = array())
{
global $browser, $injector, $session;
$app = empty($options['app']) ? 'horde' : $options['app'];
if ($this->getAuth() == $authId) {
/* Store app credentials - base Horde session already exists. */
$this->setAuthCredential($credentials, null, $app);
return;
}
/* Initial authentication to Horde. */
$session->set('horde', 'auth/authId', $authId);
$session->set('horde', 'auth/browser', $browser->getAgentString());
if (!empty($options['change'])) {
$session->set('horde', 'auth/change', 1);
}
$session->set('horde', 'auth/credentials', $app);
$remote = $this->remoteHost();
$session->set('horde', 'auth/remoteAddr', $remote->addr);
$session->set('horde', 'auth/timestamp', time());
$username = trim($authId);
if (!empty($GLOBALS['conf']['auth']['lowercase'])) {
$username = Horde_String::lower($username);
}
if (empty($options['no_convert'])) {
$username = $this->convertUsername($username, true);
}
$session->set('horde', 'auth/userId', $username);
$this->_cache['auth'] = null;
$this->_cache['existing'] = $this->_cache['isauth'] = array();
$this->setAuthCredential($credentials, null, $app);
/* Reload preferences for the new user. */
unset($GLOBALS['prefs']);
$this->loadPrefs($this->getApp());
$this->setLanguageEnvironment(isset($options['language']) ? $this->preferredLang($options['language']) : null, $app);
}