From f4b1b562dd940d27a96acb18f54730d513233960 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 21 Jul 2009 22:49:59 -0600 Subject: [PATCH] Add Horde_Auth_Application::setCredential(). --- framework/Auth/lib/Horde/Auth/Application.php | 36 +++++++++++++++++++++------ 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/framework/Auth/lib/Horde/Auth/Application.php b/framework/Auth/lib/Horde/Auth/Application.php index a6c544f38..d15550327 100644 --- a/framework/Auth/lib/Horde/Auth/Application.php +++ b/framework/Auth/lib/Horde/Auth/Application.php @@ -9,12 +9,6 @@ * 'app' - (string) The application which is providing authentication. * * - * Optional parameters: - *
- * 'params' - (array) Parameters to pass to the application's authenticate
- *            method.
- * 
- * * Copyright 2002-2009 The Horde Project (http://www.horde.org/) * * See the enclosed file COPYING for license information (LGPL). If you did @@ -86,7 +80,8 @@ class Horde_Auth_Application extends Horde_Auth_Base * Find out if a set of login credentials are valid. * * @param string $userId The userId to check. - * @param array $credentials The credentials to use. + * @param array $credentials The credentials to use. This object will + * always be available in the 'auth_ob' key. * * @throws Horde_Auth_Exception */ @@ -98,6 +93,8 @@ class Horde_Auth_Application extends Horde_Auth_Base $registry = Horde_Registry::singleton(); + $credentials['auth_ob'] = $this; + try { $result = $registry->callByPackage($this->_params['app'], $this->_apiMethods['authenticate'], array($userId, $credentials)); $this->_credentials['params']['app'] = $this->_params['app']; @@ -234,4 +231,29 @@ class Horde_Auth_Application extends Horde_Auth_Base return $registry->callByPackage($this->_params['app'], $this->_apiMethods['loginparams']); } + /** + * Provide method to set internal credential values. Necessary as the + * application API does not have direct access to the protected member + * variables of this class. + * + * @param string $name The credential name to set. + * @param mixed $value The credential value to set. If $name is 'userId', + * this must be a text value. If $name is + * 'credentials' or 'params', this is an array of + * values to be merged in. + */ + public function setCredential($type, $value) + { + switch ($type) { + case 'userId': + $this->_credentials['userId'] = $value; + break; + + case 'credentials': + case 'params': + $this->_credentials[$type] = array_merge($this->_credentials[$type], $value); + break; + } + } + } -- 2.11.0