Subversion Repositories Applications.papyrus

Rev

Rev 1173 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1173 Rev 1713
Line 16... Line 16...
16
 * @package    Auth
16
 * @package    Auth
17
 * @author     Yavor Shahpasov <yavo@netsmart.com.cy>
17
 * @author     Yavor Shahpasov <yavo@netsmart.com.cy>
18
 * @author     Adam Ashley <aashley@php.net>
18
 * @author     Adam Ashley <aashley@php.net>
19
 * @copyright  2001-2006 The PHP Group
19
 * @copyright  2001-2006 The PHP Group
20
 * @license    http://www.php.net/license/3_01.txt  PHP License 3.01
20
 * @license    http://www.php.net/license/3_01.txt  PHP License 3.01
21
 * @version    CVS: $Id: PEAR.php,v 1.1 2006-12-14 15:04:28 jp_milcent Exp $
21
 * @version    CVS: $Id: PEAR.php,v 1.2 2007-11-19 15:11:00 jp_milcent Exp $
22
 * @link       http://pear.php.net/package/Auth
22
 * @link       http://pear.php.net/package/Auth
23
 * @since      File available since Release 1.3.0
23
 * @since      File available since Release 1.3.0
24
 */
24
 */
Line 25... Line 25...
25
 
25
 
26
/**
26
/**
27
 * Include Auth_Container base class
27
 * Include PEAR HTTP_Client.
28
 */
28
 */
29
require_once 'Auth/Container.php';
29
require_once 'HTTP/Client.php';
30
/**
30
/**
31
 * Include PEAR XML_RPC
31
 * Include Auth_Container base class
32
 */
32
 */
Line 33... Line 33...
33
require_once 'XML/RPC.php';
33
require_once 'Auth/Container.php';
34
 
34
 
35
/**
35
/**
36
 * Storage driver for authenticating against PEAR website
36
 * Storage driver for authenticating against PEAR website
Line 40... Line 40...
40
 *
40
 *
41
 * @category   Authentication
41
 * @category   Authentication
42
 * @package    Auth
42
 * @package    Auth
43
 * @author     Yavor Shahpasov <yavo@netsmart.com.cy>
43
 * @author     Yavor Shahpasov <yavo@netsmart.com.cy>
44
 * @author     Adam Ashley <aashley@php.net>
44
 * @author     Adam Ashley <aashley@php.net>
-
 
45
 * @author     Adam Harvey <aharvey@php.net>
45
 * @copyright  2001-2006 The PHP Group
46
 * @copyright  2001-2007 The PHP Group
46
 * @license    http://www.php.net/license/3_01.txt  PHP License 3.01
47
 * @license    http://www.php.net/license/3_01.txt  PHP License 3.01
47
 * @version    Release: 1.4.3  File: $Revision: 1.1 $
48
 * @version    Release: 1.5.4  File: $Revision: 1.2 $
48
 * @link       http://pear.php.net/package/Auth
49
 * @link       http://pear.php.net/package/Auth
49
 * @since      Class available since Release 1.3.0
50
 * @since      Class available since Release 1.3.0
50
 */
51
 */
51
class Auth_Container_Pear extends Auth_Container
52
class Auth_Container_Pear extends Auth_Container
52
{
53
{
Line 78... Line 79...
78
     * @param string    Password
79
     * @param string    Password
79
     * @return mixed    Error object or boolean
80
     * @return mixed    Error object or boolean
80
     */
81
     */
81
    function fetchData($username, $password)
82
    function fetchData($username, $password)
82
    {
83
    {
83
        $rpc = new XML_RPC_Client('/xmlrpc.php', 'pear.php.net');
84
        $this->log('Auth_Container_PEAR::fetchData() called.', AUTH_LOG_DEBUG);
-
 
85
 
84
        $rpc_message = new XML_RPC_Message("user.info", array(new XML_RPC_Value($username, "string")) );
86
        $client = new HTTP_Client;
Line 85... Line -...
85
        
-
 
86
        // Error Checking howto ???
-
 
87
        $result = $rpc->send($rpc_message);
-
 
88
        $value = $result->value();
-
 
89
        $userinfo = xml_rpc_decode($value);
87
 
90
        if ($userinfo['password'] == md5($password)) {
88
        $this->log('Auth_Container_PEAR::fetchData() getting salt.', AUTH_LOG_DEBUG);
91
            $this->activeUser = $userinfo['handle'];
89
        $code = $client->get('https://pear.php.net/rest-login.php/getsalt');
92
            foreach ($userinfo as $uk=>$uv) {
90
        if ($code != 200) {
93
                $this->_auth_obj->setAuthData($uk, $uv);
91
            return PEAR::raiseError('Bad response to salt request.', $code);
-
 
92
        }
94
            }
93
        $resp = $client->currentResponse();
-
 
94
        $salt = $resp['body'];
-
 
95
 
-
 
96
        $this->log('Auth_Container_PEAR::fetchData() calling validate.', AUTH_LOG_DEBUG);
-
 
97
        $code = $client->post('https://pear.php.net/rest-login.php/validate',
-
 
98
                              array('username' => $username,
-
 
99
                                    'password' => md5($salt.md5($password))));
-
 
100
        if ($code != 200) {
95
            return true;
101
            return PEAR::raiseError('Bad response to validate request.', $code);
-
 
102
        }
-
 
103
        $resp = $client->currentResponse();
-
 
104
 
-
 
105
        list($code, $message) = explode(' ', $resp['body'], 1);
-
 
106
        if ($code != 8) {
-
 
107
            return PEAR::raiseError($message, $code);
96
        }
108
        }
97
        return false;
109
        return true;
Line 98... Line 110...
98
    }
110
    }
Line 99... Line 111...
99
 
111