Subversion Repositories Applications.papyrus

Rev

Rev 1173 | Go to most recent revision | Show entire file | Ignore 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 55... Line 56...
55
 
56
 
56
    /**
57
    /**
57
     * Constructor
58
     * Constructor
58
     *
59
     *
59
     * Currently does nothing
60
     * Currently does nothing
60
     * 
61
     *
61
     * @return void
62
     * @return void
62
     */
63
     */
63
    function Auth_Container_Pear()
64
    function Auth_Container_Pear()
64
    {
65
    {
65
    
66
 
Line 66... Line 67...
66
    }
67
    }
67
 
68
 
68
    // }}}
69
    // }}}
69
    // {{{ fetchData()
70
    // {{{ fetchData()
70
    
71
 
71
    /**
72
    /**
72
     * Get user information from pear.php.net
73
     * Get user information from pear.php.net
73
     *
74
     *
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;
85
        
87
 
-
 
88
        $this->log('Auth_Container_PEAR::fetchData() getting salt.', AUTH_LOG_DEBUG);
-
 
89
        $code = $client->get('https://pear.php.net/rest-login.php/getsalt');
86
        // Error Checking howto ???
90
        if ($code != 200) {
87
        $result = $rpc->send($rpc_message);
91
            return PEAR::raiseError('Bad response to salt request.', $code);
-
 
92
        }
88
        $value = $result->value();
93
        $resp = $client->currentResponse();
89
        $userinfo = xml_rpc_decode($value);
94
        $salt = $resp['body'];
-
 
95
 
90
        if ($userinfo['password'] == md5($password)) {
96
        $this->log('Auth_Container_PEAR::fetchData() calling validate.', AUTH_LOG_DEBUG);
91
            $this->activeUser = $userinfo['handle'];
97
        $code = $client->post('https://pear.php.net/rest-login.php/validate',
92
            foreach ($userinfo as $uk=>$uv) {
98
                              array('username' => $username,
93
                $this->_auth_obj->setAuthData($uk, $uv);
99
                                    'password' => md5($salt.md5($password))));
94
            }
100
        if ($code != 200) {
95
            return true;
101
            return PEAR::raiseError('Bad response to validate request.', $code);
96
        }
102
        }
-
 
103
        $resp = $client->currentResponse();
-
 
104
 
-
 
105
        list($code, $message) = explode(' ', $resp['body'], 1);
-
 
106
        if ($code != 8) {
-
 
107
            return PEAR::raiseError($message, $code);
-
 
108
        }
97
        return false;
109
        return true;
98
    }
110
    }
Line 99... Line 111...
99
 
111
 
100
    // }}}
112
    // }}}
101
    
113
 
102
}
114
}