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     Andrew Teixeira <ateixeira@gmail.com>
17
 * @author     Andrew Teixeira <ateixeira@gmail.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: KADM5.php,v 1.1 2006-12-14 15:04:28 jp_milcent Exp $
21
 * @version    CVS: $Id: KADM5.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.4.0
23
 * @since      File available since Release 1.4.0
24
 */
24
 */
Line 25... Line 25...
25
 
25
 
Line 46... Line 46...
46
 * @package    Auth
46
 * @package    Auth
47
 * @author     Andrew Teixeira <ateixeira@gmail.com>
47
 * @author     Andrew Teixeira <ateixeira@gmail.com>
48
 * @author     Adam Ashley <aashley@php.net>
48
 * @author     Adam Ashley <aashley@php.net>
49
 * @copyright  2001-2006 The PHP Group
49
 * @copyright  2001-2006 The PHP Group
50
 * @license    http://www.php.net/license/3_01.txt  PHP License 3.01
50
 * @license    http://www.php.net/license/3_01.txt  PHP License 3.01
51
 * @version    Release: 1.4.3  File: $Revision: 1.1 $
51
 * @version    Release: 1.5.4  File: $Revision: 1.2 $
52
 * @link       http://pear.php.net/package/Auth
52
 * @link       http://pear.php.net/package/Auth
53
 * @since      Class available since Release 1.4.0
53
 * @since      Class available since Release 1.4.0
54
 */
54
 */
55
class Auth_Container_KADM5 extends Auth_Container {
55
class Auth_Container_KADM5 extends Auth_Container {
Line 80... Line 80...
80
     */
80
     */
81
    function Auth_Container_KADM5($options) {
81
    function Auth_Container_KADM5($options) {
82
        if (!extension_loaded('kadm5')) {
82
        if (!extension_loaded('kadm5')) {
83
            return PEAR::raiseError("Cannot use Kerberos V authentication, KADM5 extension not loaded!", 41, PEAR_ERROR_DIE);
83
            return PEAR::raiseError("Cannot use Kerberos V authentication, KADM5 extension not loaded!", 41, PEAR_ERROR_DIE);
84
        }
84
        }
85
        
85
 
86
        $this->_setDefaults();
86
        $this->_setDefaults();
87
        
87
 
88
        if (isset($options['hostname'])) {
88
        if (isset($options['hostname'])) {
89
            $this->options['hostname'] = $options['hostname'];
89
            $this->options['hostname'] = $options['hostname'];
90
        }
90
        }
91
        if (isset($options['realm'])) {
91
        if (isset($options['realm'])) {
92
            $this->options['realm'] = $options['realm'];
92
            $this->options['realm'] = $options['realm'];
Line 95... Line 95...
95
            $this->options['timeout'] = $options['timeout'];
95
            $this->options['timeout'] = $options['timeout'];
96
        }
96
        }
97
        if (isset($options['checkServer'])) {
97
        if (isset($options['checkServer'])) {
98
            $this->options['checkServer'] = $options['checkServer'];
98
            $this->options['checkServer'] = $options['checkServer'];
99
        }
99
        }
100
        
100
 
101
        if ($this->options['checkServer']) {
101
        if ($this->options['checkServer']) {
102
            $this->_checkServer();
102
            $this->_checkServer();
103
        }
103
        }
104
    }
104
    }
Line 105... Line 105...
105
 
105
 
106
    // }}}
106
    // }}}
107
    // {{{ fetchData()
107
    // {{{ fetchData()
108
    
108
 
109
    /**
109
    /**
110
     * Try to login to the KADM5 server
110
     * Try to login to the KADM5 server
111
     *
111
     *
112
     * @param   string Username
112
     * @param   string Username
113
     * @param   string Password
113
     * @param   string Password
114
     * @return  boolean
114
     * @return  boolean
115
     */
115
     */
-
 
116
    function fetchData($username, $password) {
116
    function fetchData($username, $password) {
117
        $this->log('Auth_Container_KADM5::fetchData() called.', AUTH_LOG_DEBUG);
117
        if ( ($username == NULL) || ($password == NULL) ) {
118
        if ( ($username == NULL) || ($password == NULL) ) {
118
            return false;
119
            return false;
119
        }
120
        }
120
        
121
 
121
        $server = $this->options['hostname'];
122
        $server = $this->options['hostname'];
122
        $realm = $this->options['realm'];
123
        $realm = $this->options['realm'];
123
        $check = @kadm5_init_with_password($server, $realm, $username, $password);
124
        $check = @kadm5_init_with_password($server, $realm, $username, $password);
124
        
125
 
125
        if ($check == false) {
126
        if ($check == false) {
126
            return false;
127
            return false;
127
        } else {
128
        } else {
128
            return true;
129
            return true;
129
        }
130
        }
130
    }
131
    }
131
    
132
 
132
    // }}}
133
    // }}}
133
    // {{{ _setDefaults()
134
    // {{{ _setDefaults()
134
    
135
 
135
    /**
136
    /**
136
     * Set some default options
137
     * Set some default options
137
     *
138
     *
138
     * @access private
139
     * @access private
Line 141... Line 142...
141
        $this->options['hostname'] = 'localhost';
142
        $this->options['hostname'] = 'localhost';
142
        $this->options['realm'] = NULL;
143
        $this->options['realm'] = NULL;
143
        $this->options['timeout'] = 10;
144
        $this->options['timeout'] = 10;
144
        $this->options['checkServer'] = false;
145
        $this->options['checkServer'] = false;
145
    }
146
    }
146
    
147
 
147
    // }}}
148
    // }}}
148
    // {{{ _checkServer()
149
    // {{{ _checkServer()
149
    
150
 
150
    /**
151
    /**
151
     * Check if the given server and port are reachable
152
     * Check if the given server and port are reachable
152
     *
153
     *
153
     * @access private
154
     * @access private
154
     */
155
     */
Line 160... Line 161...
160
            $message = "Error connecting to Kerberos V server "
161
            $message = "Error connecting to Kerberos V server "
161
                .$this->options['hostname'].":".$this->options['port'];
162
                .$this->options['hostname'].":".$this->options['port'];
162
            return PEAR::raiseError($message, 41, PEAR_ERROR_DIE);
163
            return PEAR::raiseError($message, 41, PEAR_ERROR_DIE);
163
        }
164
        }
164
    }
165
    }
165
    
166
 
166
    // }}}
167
    // }}}
Line 167... Line 168...
167
 
168
 
Line 168... Line 169...
168
}
169
}