$notification->push(_("Password changed."), 'horde.success');
// reset credentials so user is not forced to relogin
- if (Horde_Auth::getCredential('password') == $info['old']) {
- Horde_Auth::setCredential('password', $info['new']);
+ if ($registry->getAuthCredential('password') == $info['old']) {
+ $registry->setAuthCredential('password', $info['new']);
$secret = $injector->getInstance('Horde_Secret');
if ($registry->getProvider() == 'imp' ||
!empty($_SESSION['imp']['pass'])) {
}
/**
- * Returns the requested credential for the currently logged in user, if
- * present.
- *
- * @param string $credential The credential to retrieve.
- * @param string $app The app to query. Defaults to Horde.
- *
- * @return mixed The requested credential, all credentials if $credential
- * is null, or false if no user is logged in.
- */
- static public function getCredential($credential = null, $app = null)
- {
- if (!$GLOBALS['registry']->getAuth()) {
- return false;
- }
-
- $credentials = self::_getCredentials($app);
-
- return is_null($credential)
- ? $credentials
- : ((is_array($credentials) && isset($credentials[$credential]))
- ? $credentials[$credential]
- : false);
- }
-
- /**
- * Sets the requested credential for the currently logged in user.
- *
- * @param string $credential The credential to set.
- * @param string $value The value to set the credential to.
- * @param string $app The app to update. Defaults to Horde.
- */
- static public function setCredential($credential, $value, $app = null)
- {
- if ($GLOBALS['registry']->getAuth()) {
- $credentials = self::_getCredentials($app);
-
- if ($credentials !== false) {
- if (is_array($credentials)) {
- $credentials[$credential] = $value;
- } else {
- $credentials = array($credential => $value);
- }
-
- $secret = $GLOBALS['injector']->getInstance('Horde_Secret');
- $_SESSION['horde_auth']['app'][$app] = $secret->write($secret->getKey('auth'), serialize($credentials));
- }
- }
- }
-
- /**
- * Get the list of credentials for a given app.
- *
- * @param string $app The application name.
- *
- * @return mixed True, false, or the credential list.
- */
- static protected function _getCredentials($app)
- {
- if (is_null($app)) {
- $app = $_SESSION['horde_auth']['credentials'];
- }
-
- if (!isset($_SESSION['horde_auth']['app'])) {
- return false;
- }
-
- $secret = $GLOBALS['injector']->getInstance('Horde_Secret');
- return @unserialize($secret->read($secret->getKey('auth'), $_SESSION['horde_auth']['app'][$app]));
- }
-
- /**
* Sets a variable in the session saying that authorization has succeeded,
* note which userId was authorized, and note when the login took place.
*
? $this->_params['default_user']
: $this->_credentials['userId'];
$credentials = empty($this->_credentials['credentials'])
- ? Horde_Auth::getCredential()
+ ? $GLOBALS['registry']->getAuthCredential()
: $this->_credentials['credentials'];
list($this->_credentials['userId'], $this->_credentials['credentials']) = Horde_Auth::runHook($userId, $credentials, $this->_app, 'preauthenticate', 'transparent');
<license uri="http://opensource.org/licenses/lgpl-2.1.php">LGPL</license>
<notes>* Removed Krb5 driver.
* Moved signup code to horde/Core.
- * Add ability to retrieve app-specific credentials via
- Horde_Auth::getCredential().
* Split Horde_Auth:: into Horde_Auth:: and Horde_Auth_Base:: components.
* Initial Horde 4 package.
</notes>
$params['auth'] &&
empty($params['username'])) {
$params['username'] = $GLOBALS['registry']->getAuth();
- $params['password'] = Horde_Auth::getCredential('password');
+ $params['password'] = $GLOBALS['registry']->getAuthCredential('password');
}
try {
$params = array(
'hostspec' => $session->getImapServer(),
'username' => $GLOBALS['registry']->getAuth(),
- 'password' => Horde_Auth::getCredential('password'),
+ 'password' => $GLOBALS['registry']->getAuthCredential('password'),
'secure' => true
);
} else {
if (!isset($GLOBALS['prefs']) ||
($GLOBALS['prefs']->getUser() != $this->getAuth())) {
- $GLOBALS['prefs'] = Horde_Prefs::factory($GLOBALS['conf']['prefs']['driver'], $app, $this->getAuth(), Horde_Auth::getCredential('password'));
+ $GLOBALS['prefs'] = Horde_Prefs::factory($GLOBALS['conf']['prefs']['driver'], $app, $this->getAuth(), $this->getAuthCredential('password'));
} else {
$GLOBALS['prefs']->retrieve($app);
}
return !empty($_SESSION['horde_auth']['change']);
}
+ /**
+ * Returns the requested credential for the currently logged in user, if
+ * present.
+ *
+ * @param string $credential The credential to retrieve.
+ * @param string $app The app to query. Defaults to Horde.
+ *
+ * @return mixed The requested credential, all credentials if $credential
+ * is null, or false if no user is logged in.
+ */
+ public function getAuthCredential($credential = null, $app = null)
+ {
+ if (!$this->getAuth()) {
+ return false;
+ }
+
+ $credentials = $this->_getAuthCredentials($app);
+
+ return is_null($credential)
+ ? $credentials
+ : ((is_array($credentials) && isset($credentials[$credential]))
+ ? $credentials[$credential]
+ : false);
+ }
+
+ /**
+ * Sets the requested credential for the currently logged in user.
+ *
+ * @param string $credential The credential to set.
+ * @param string $value The value to set the credential to.
+ * @param string $app The app to update. Defaults to Horde.
+ */
+ public function setAuthCredential($credential, $value, $app = null)
+ {
+ if (!$this->getAuth()) {
+ return;
+ }
+
+ $credentials = $this->_getAuthCredentials($app);
+
+ if ($credentials !== false) {
+ if (is_array($credentials)) {
+ $credentials[$credential] = $value;
+ } else {
+ $credentials = array($credential => $value);
+ }
+
+ $secret = $GLOBALS['injector']->getInstance('Horde_Secret');
+ $_SESSION['horde_auth']['app'][$app] = $secret->write($secret->getKey('auth'), serialize($credentials));
+ }
+ }
+
+ /**
+ * Get the list of credentials for a given app.
+ *
+ * @param string $app The application name.
+ *
+ * @return mixed True, false, or the credential list.
+ */
+ protected function _getAuthCredentials($app)
+ {
+ if (is_null($app)) {
+ $app = $_SESSION['horde_auth']['credentials'];
+ }
+
+ if (!isset($_SESSION['horde_auth']['app'])) {
+ return false;
+ }
+
+ $secret = $GLOBALS['injector']->getInstance('Horde_Secret');
+ return @unserialize($secret->read($secret->getKey('auth'), $_SESSION['horde_auth']['app'][$app]));
+ }
+
}
if ($access->user == 'manager') {
$imapc = &Horde_Kolab_IMAP::singleton($GLOBALS['conf']['kolab']['imap']['server'],
$GLOBALS['conf']['kolab']['imap']['port']);
- $result = $imapc->connect($access->user, Horde_Auth::getCredential('password'));
+ $result = $imapc->connect($access->user, $GLOBALS['registry']->getAuthCredential('password'));
if (is_a($result, 'PEAR_Error')) {
$reporter->failure($calendar->name, $result->getMessage());
continue;
//@todo: Fix!
// This part allows you to use the PHP scripts with CGI rather than as
// an apache module. This will of course slow down things but on the
- // other hand it allows you to reduce the memory footprint of the
- // apache server. The default is to use PHP as a module and the CGI
+ // other hand it allows you to reduce the memory footprint of the
+ // apache server. The default is to use PHP as a module and the CGI
// version requires specific Apache configuration.
//
- // The line you need to add to your configuration of the /freebusy
+ // The line you need to add to your configuration of the /freebusy
// location of your server looks like this:
//
// RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
'timestamp' => time(),
'remote_addr' => isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null,
);
- Auth::setCredential('password', $pass);
+ $GLOBALS['registry']->setAuthCredential('password', $pass);
}
}
}
if (!$this->_authenticated) {
- return PEAR::raiseError(sprintf(_("Invalid authentication for user %s!"),
+ return PEAR::raiseError(sprintf(_("Invalid authentication for user %s!"),
$this->user));
}
return true;
header("Location: $redirect");
} else {
header("X-Redirect-To: $redirect");
- $redirect = 'https://' . urlencode($this->user) . ':' . urlencode(Horde_Auth::getCredential('password'))
+ $redirect = 'https://' . urlencode($this->user) . ':' . urlencode($GLOBALS['registry']->getAuthCredential('password'))
. '@' . $this->freebusyserver . $path;
if (!@readfile($redirect)) {
$message = sprintf(_("Unable to read free/busy information from %s"),
*
* @return boolean|PEAR_Error True if successful.
*/
- private function _process()
+ private function _process()
{
global $conf;
} else {
$params = array(
'user' => $GLOBALS['registry']->getAuth(),
- 'pass' => Horde_Auth::getCredential('password'),
+ 'pass' => $GLOBALS['registry']->getAuthCredential('password')
);
}
'Horde_Kolab_Server_Object_Kolab_Server');
$this->server_object = $server;
} catch (Horde_Kolab_Server_Exception $e) {
- Horde::logMessage(sprintf("Failed fetching the k=kolab configuration object. Error was: %s",
+ Horde::logMessage(sprintf("Failed fetching the k=kolab configuration object. Error was: %s",
$e->getMessage()),
__FILE__, __LINE__, PEAR_LOG_ERR);
$this->server_object = null;
$idx = strpos($this->user, '@');
if($idx !== false) {
$domain = substr($this->user, $idx+1);
- Horde::logMessage(sprintf("Trying to append %s to %s",
+ Horde::logMessage(sprintf("Trying to append %s to %s",
$domain, $this->owner),
__FILE__, __LINE__, PEAR_LOG_DEBUG);
$odn = $odn = $db->uidForIdOrMail($this->owner . '@' . $domain);
*
* @return string The IMAP folder we should access.
*/
- function _getImapFolder()
+ function _getImapFolder()
{
$userdom = false;
$ownerdom = false;
$options = array_merge($options, $conf['http']['proxy']);
}
- require_once 'HTTP/Request.php';
$http = new HTTP_Request($url, $options);
- $http->setBasicAuth($GLOBALS['registry']->getAuth(), Horde_Auth::getCredential('password'));
+ $http->setBasicAuth($GLOBALS['registry']->getAuth(), $GLOBALS['registry']->getAuthCredential('password'));
@$http->sendRequest();
if ($http->getResponseCode() != 200) {
return PEAR::raiseError(sprintf(_("Unable to trigger URL %s. Response: %s"),
* array(array('jan'), array('localsql'),
* array('name', 'email')),
* array('user' => $GLOBALS['registry']->getAuth(),
- * 'pass' => Horde_Auth::getCredential('password')));
+ * 'pass' => $GLOBALS['registry']->getAuthCredential('password')));
* </code>
*
* Copyright 2002-2010 The Horde Project (http://www.horde.org/)
$ptr = &$GLOBALS['gollem_backends'][$backend_key];
if (!empty($ptr['hordeauth'])) {
$user = Gollem::getAutologinID($backend_key);
- $pass = Horde_Auth::getCredential('password');
+ $pass = $GLOBALS['registry']->getAuthCredential('password');
if (Gollem_Session::createSession($backend_key, $user, $pass)) {
$entry = sprintf('Login success for %s [%s] to {%s}',
if ($form->isValid()) {
$form->getInfo($vars, $info);
- if (Horde_Auth::getCredential('password') != $info['old_password']) {
+ if ($GLOBALS['registry']->getAuthCredential('password') != $info['old_password']) {
$notification->push(_("Old password is not correct."), 'horde.error');
} elseif ($info['password_1'] != $info['password_2']) {
$notification->push(_("New passwords don't match."), 'horde.error');
// // Uses the PECL ssh2 extension.
// $host = $_SESSION['imp']['server'];
// $user = $_SESSION['imp']['user'];
-// $pass = Horde_Auth::getCredential('password');
+// $pass = $GLOBALS['registry']->getAuthCredential('password');
// $command = $params[0];
//
// $session = ssh2_connect($host);
!empty($servers[$server_key]['hordeauth'])) {
return array(
'userId' => $GLOBALS['registry']->getAuth((strcasecmp($servers[$server_key]['hordeauth'], 'full') == 0) ? null : 'bare'),
- 'password' => Horde_Auth::getCredential('password'),
+ 'password' => $GLOBALS['registry']->getAuthCredential('password'),
'server' => $server_key
);
}
// Set authentication parameters.
if (!empty($_SESSION['ingo']['backend']['hordeauth'])) {
$params['username'] = $GLOBALS['registry']->getAuth(($_SESSION['ingo']['backend']['hordeauth'] === 'full') ? null : 'bare');
- $params['password'] = Horde_Auth::getCredential('password');
+ $params['password'] = $GLOBALS['registry']->getAuthCredential('password');
} elseif (isset($_SESSION['ingo']['backend']['params']['username']) &&
isset($_SESSION['ingo']['backend']['params']['password'])) {
$params['username'] = $_SESSION['ingo']['backend']['params']['username'];
$params['password'] = $_SESSION['ingo']['backend']['params']['password'];
} else {
$params['username'] = $GLOBALS['registry']->getAuth('bare');
- $params['password'] = Horde_Auth::getCredential('password');
+ $params['password'] = $GLOBALS['registry']->getAuthCredential('password');
}
return Ingo_Driver::factory($_SESSION['ingo']['backend']['driver'], $params);
{
if (!isset(self::$server)) {
self::$server = Horde_Kolab_Server::singleton(array('user' => $GLOBALS['registry']->getAuth(),
- 'pass' => Horde_Auth::getCredential('password')));
+ 'pass' => $GLOBALS['registry']->getAuthCredential('password')));
}
return self::$server;
exit;
}
-$key = Horde_Auth::getCredential('password');
+$key = $registry->getAuthCredential('password');
$username = $calendar['user'];
$password = $calendar['password'];
if ($key) {
$calUser = trim($ui->vars->remote_user);
$calPasswd = trim($ui->vars->remote_password);
- $key = Horde_Auth::getCredential('password');
+ $key = $GLOBALS['registry']->getAuthCredential('password');
if ($key) {
$calUser = base64_encode(Secret::write($key, $calUser));
$calPasswd = base64_encode(Secret::write($key, $calPasswd));
}
if (strlen($info['username']) || strlen($info['password'])) {
- $key = Horde_Auth::getCredential('password');
+ $key = $GLOBALS['registry']->getAuthCredential('password');
if ($key) {
$secret = $GLOBALS['injector']->getInstance('Horde_Secret');
$info['username'] = base64_encode($secret->write($key, $info['username']));
if ($cal['url'] == $calendar) {
$user = isset($cal['user']) ? $cal['user'] : '';
$password = isset($cal['password']) ? $cal['password'] : '';
- $key = Horde_Auth::getCredential('password');
+ $key = $GLOBALS['registry']->getAuthCredential('password');
if ($key && $user) {
$secret = $GLOBALS['injector']->getInstance('Horde_Secret');
$user = $secret->read($key, base64_decode($user));
}
$http = new HTTP_Request($fb_url, $options);
- $http->setBasicAuth($GLOBALS['registry']->getAuth(), Horde_Auth::getCredential('password'));
+ $http->setBasicAuth($GLOBALS['registry']->getAuth(), $GLOBALS['registry']->getAuthCredential('password'));
@$http->sendRequest();
if ($http->getResponseCode() != 200) {
throw new Horde_Exception_NotFound();
}
// Update the stored credential within the session
- Auth::setCredential('password', $new_password);
+ $GLOBALS['registry']->setAuthCredential('password', $new_password);
return true;
}
*/
function resetCredentials($old_password, $new_password)
{
- if (Auth::getCredential('password') == $old_password) {
- Auth::setCredential('password', $new_password);
+ if ($GLOBALS['registry']->getAuthCredential('password') == $old_password) {
+ $GLOBALS['registry']->setAuthCredential('password', $new_password);
if ($GLOBALS['registry']->getProvider() == 'imp') {
$_SESSION['imp']['pass'] = Secret::write(Secret::getKey('imp'),
$new_password);
// 'tls' => false,
// 'root' => 'ou=' . $_ldap_uid . ',ou=personal_addressbook,' . $_ldap_basedn,
// 'bind_dn' => 'uid=' . $_ldap_uid . ',ou=People,' . $_ldap_basedn,
-// 'bind_password' => Horde_Auth::getCredential('password'),
+// 'bind_password' => $GLOBALS['registry']->getAuthCredential('password'),
// 'dn' => array('uid'),
// 'objectclass' => array('top',
// 'person',
$_imsp_auth_pass = $GLOBALS['prefs']->getValue('imsp_auth_pass');
if (!strlen($_imsp_auth_user)) {
$_imsp_auth_user = $GLOBALS['registry']->getAuth('bare');
- $_imsp_auth_pass = Horde_Auth::getCredential('password');
+ $_imsp_auth_pass = $GLOBALS['registry']->getAuthCredential('password');
}
$cfgSources['imsp'] = array(
'title' => _("IMSP"),
}
if (empty($params['password'])) {
- $params['password'] = Horde_Auth::getCredential('password');
+ $params['password'] = $GLOBALS['registry']->getAuthCredential('password');
}
if (class_exists($class)) {