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 12... Line 12...
12
 * the PHP License and are unable to obtain it through the web, please
12
 * the PHP License and are unable to obtain it through the web, please
13
 * send a note to license@php.net so we can mail you a copy immediately.
13
 * send a note to license@php.net so we can mail you a copy immediately.
14
 *
14
 *
15
 * @category   Authentication
15
 * @category   Authentication
16
 * @package    Auth
16
 * @package    Auth
17
 * @author     Michael Bretterklieber <michael@bretterklieber.com> 
17
 * @author     Michael Bretterklieber <michael@bretterklieber.com>
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: RADIUS.php,v 1.2 2006-12-14 15:04:28 jp_milcent Exp $
21
 * @version    CVS: $Id: RADIUS.php,v 1.3 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.2.0
23
 * @since      File available since Release 1.2.0
24
 */
24
 */
Line 25... Line 25...
25
 
25
 
Line 39... Line 39...
39
 * @package    Auth
39
 * @package    Auth
40
 * @author     Michael Bretterklieber <michael@bretterklieber.com>
40
 * @author     Michael Bretterklieber <michael@bretterklieber.com>
41
 * @author     Adam Ashley <aashley@php.net>
41
 * @author     Adam Ashley <aashley@php.net>
42
 * @copyright  2001-2006 The PHP Group
42
 * @copyright  2001-2006 The PHP Group
43
 * @license    http://www.php.net/license/3_01.txt  PHP License 3.01
43
 * @license    http://www.php.net/license/3_01.txt  PHP License 3.01
44
 * @version    Release: 1.4.3  File: $Revision: 1.2 $
44
 * @version    Release: 1.5.4  File: $Revision: 1.3 $
45
 * @link       http://pear.php.net/package/Auth
45
 * @link       http://pear.php.net/package/Auth
46
 * @since      Class available since Release 1.2.0
46
 * @since      Class available since Release 1.2.0
47
 */
47
 */
48
class Auth_Container_RADIUS extends Auth_Container
48
class Auth_Container_RADIUS extends Auth_Container
49
{
49
{
Line 53... Line 53...
53
    /**
53
    /**
54
     * Contains a RADIUS object
54
     * Contains a RADIUS object
55
     * @var object
55
     * @var object
56
     */
56
     */
57
    var $radius;
57
    var $radius;
58
    
58
 
59
    /**
59
    /**
60
     * Contains the authentication type
60
     * Contains the authentication type
61
     * @var string
61
     * @var string
62
     */
62
     */
63
    var $authtype;    
63
    var $authtype;
Line 64... Line 64...
64
 
64
 
65
    // }}}
65
    // }}}
Line 66... Line 66...
66
    // {{{ Auth_Container_RADIUS() [constructor]
66
    // {{{ Auth_Container_RADIUS() [constructor]
Line 87... Line 87...
87
        $classname = 'Auth_RADIUS_' . $this->authtype;
87
        $classname = 'Auth_RADIUS_' . $this->authtype;
88
        if (!class_exists($classname)) {
88
        if (!class_exists($classname)) {
89
            PEAR::raiseError("Unknown Authtype, please use one of: "
89
            PEAR::raiseError("Unknown Authtype, please use one of: "
90
                    ."PAP, CHAP_MD5, MSCHAPv1, MSCHAPv2!", 41, PEAR_ERROR_DIE);
90
                    ."PAP, CHAP_MD5, MSCHAPv1, MSCHAPv2!", 41, PEAR_ERROR_DIE);
91
        }
91
        }
92
        
92
 
93
        $this->radius = new $classname;
93
        $this->radius = new $classname;
Line 94... Line 94...
94
 
94
 
95
        if (isset($options['configfile'])) {
95
        if (isset($options['configfile'])) {
96
            $this->radius->setConfigfile($options['configfile']);
96
            $this->radius->setConfigfile($options['configfile']);
Line 105... Line 105...
105
                $timeout        = isset($server[3]) ? $server[3] : 3;
105
                $timeout        = isset($server[3]) ? $server[3] : 3;
106
                $maxtries       = isset($server[4]) ? $server[4] : 3;
106
                $maxtries       = isset($server[4]) ? $server[4] : 3;
107
                $this->radius->addServer($servername, $port, $sharedsecret, $timeout, $maxtries);
107
                $this->radius->addServer($servername, $port, $sharedsecret, $timeout, $maxtries);
108
            }
108
            }
109
        }
109
        }
110
        
110
 
111
        if (!$this->radius->start()) {
111
        if (!$this->radius->start()) {
112
            PEAR::raiseError($this->radius->getError(), 41, PEAR_ERROR_DIE);
112
            PEAR::raiseError($this->radius->getError(), 41, PEAR_ERROR_DIE);
113
        }
113
        }
114
    }
114
    }
Line 123... Line 123...
123
     * @param  string Password
123
     * @param  string Password
124
     * @return bool   true on success, false on reject
124
     * @return bool   true on success, false on reject
125
     */
125
     */
126
    function fetchData($username, $password, $challenge = null)
126
    function fetchData($username, $password, $challenge = null)
127
    {
127
    {
-
 
128
        $this->log('Auth_Container_RADIUS::fetchData() called.', AUTH_LOG_DEBUG);
-
 
129
 
128
        switch($this->authtype) {
130
        switch($this->authtype) {
129
        case 'CHAP_MD5':
131
            case 'CHAP_MD5':
130
        case 'MSCHAPv1':
132
            case 'MSCHAPv1':
131
            if (isset($challenge)) {
133
                if (isset($challenge)) {
132
                $this->radius->challenge = $challenge;
134
                    $this->radius->challenge = $challenge;
133
                $this->radius->chapid    = 1;
135
                    $this->radius->chapid    = 1;
134
                $this->radius->response  = pack('H*', $password);
136
                    $this->radius->response  = pack('H*', $password);
135
            } else {
137
                } else {
-
 
138
                    require_once 'Crypt/CHAP.php';
-
 
139
                    $classname = 'Crypt_' . $this->authtype;
-
 
140
                    $crpt = new $classname;
-
 
141
                    $crpt->password = $password;
-
 
142
                    $this->radius->challenge = $crpt->challenge;
-
 
143
                    $this->radius->chapid    = $crpt->chapid;
-
 
144
                    $this->radius->response  = $crpt->challengeResponse();
-
 
145
                }
-
 
146
                break;
-
 
147
 
-
 
148
            case 'MSCHAPv2':
136
                require_once 'Crypt/CHAP.php';
149
                require_once 'Crypt/CHAP.php';
137
                $classname = 'Crypt_' . $this->authtype;
150
                $crpt = new Crypt_MSCHAPv2;
138
                $crpt = new $classname;
151
                $crpt->username = $username;
139
                $crpt->password = $password;
152
                $crpt->password = $password;
140
                $this->radius->challenge = $crpt->challenge;
153
                $this->radius->challenge     = $crpt->authChallenge;
-
 
154
                $this->radius->peerChallenge = $crpt->peerChallenge;
141
                $this->radius->chapid    = $crpt->chapid;
155
                $this->radius->chapid        = $crpt->chapid;
142
                $this->radius->response  = $crpt->challengeResponse();
156
                $this->radius->response      = $crpt->challengeResponse();
143
                break;
157
                break;
144
            }
-
 
Line 145... Line -...
145
 
-
 
146
        case 'MSCHAPv2':
-
 
147
            require_once 'Crypt/CHAP.php';
-
 
148
            $crpt = new Crypt_MSCHAPv2;
-
 
149
            $crpt->username = $username;
-
 
150
            $crpt->password = $password;
-
 
151
            $this->radius->challenge     = $crpt->authChallenge;
-
 
152
            $this->radius->peerChallenge = $crpt->peerChallenge;
-
 
153
            $this->radius->chapid        = $crpt->chapid;
-
 
154
            $this->radius->response      = $crpt->challengeResponse();
-
 
155
            break;
-
 
156
 
158
 
157
        default:
159
            default:
158
            $this->radius->password = $password;
160
                $this->radius->password = $password;
159
            break;
161
                break;
Line 160... Line 162...
160
        }
162
        }
Line 161... Line 163...
161
 
163