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     Martin Jansen <mj@php.net>
17
 * @author     Martin Jansen <mj@php.net>
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: Container.php,v 1.2 2006-12-14 15:04:28 jp_milcent Exp $
21
 * @version    CVS: $Id: Container.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
 */
23
 */
Line 24... Line 24...
24
 
24
 
25
/**
25
/**
Line 29... Line 29...
29
 * @package    Auth
29
 * @package    Auth
30
 * @author     Martin Jansen <mj@php.net>
30
 * @author     Martin Jansen <mj@php.net>
31
 * @author     Adam Ashley <aashley@php.net>
31
 * @author     Adam Ashley <aashley@php.net>
32
 * @copyright  2001-2006 The PHP Group
32
 * @copyright  2001-2006 The PHP Group
33
 * @license    http://www.php.net/license/3_01.txt  PHP License 3.01
33
 * @license    http://www.php.net/license/3_01.txt  PHP License 3.01
34
 * @version    Release: 1.4.3  File: $Revision: 1.2 $
34
 * @version    Release: 1.5.4  File: $Revision: 1.3 $
35
 * @link       http://pear.php.net/package/Auth
35
 * @link       http://pear.php.net/package/Auth
36
 */
36
 */
37
class Auth_Container
37
class Auth_Container
38
{
38
{
Line 44... Line 44...
44
     *
44
     *
45
     * @access public
45
     * @access public
46
     */
46
     */
47
    var $activeUser = "";
47
    var $activeUser = "";
Line -... Line 48...
-
 
48
 
-
 
49
    /**
-
 
50
     * The Auth object this container is attached to.
-
 
51
     *
-
 
52
     * @access public
-
 
53
     */
-
 
54
    var $_auth_obj = null;
48
 
55
 
49
    // }}}
56
    // }}}
Line 50... Line 57...
50
    // {{{ Auth_Container() [constructor]
57
    // {{{ Auth_Container() [constructor]
51
 
58
 
Line 70... Line 77...
70
     *
77
     *
71
     * @access public
78
     * @access public
72
     */
79
     */
73
    function fetchData($username, $password, $isChallengeResponse=false)
80
    function fetchData($username, $password, $isChallengeResponse=false)
74
    {
81
    {
-
 
82
        $this->log('Auth_Container::fetchData() called.', AUTH_LOG_DEBUG);
75
    }
83
    }
Line 76... Line 84...
76
 
84
 
77
    // }}}
85
    // }}}
Line 88... Line 96...
88
     *                Defaults to "md5".
96
     *                Defaults to "md5".
89
     * @return bool   True, if the passwords match
97
     * @return bool   True, if the passwords match
90
     */
98
     */
91
    function verifyPassword($password1, $password2, $cryptType = "md5")
99
    function verifyPassword($password1, $password2, $cryptType = "md5")
92
    {
100
    {
-
 
101
        $this->log('Auth_Container::verifyPassword() called.', AUTH_LOG_DEBUG);
93
        switch ($cryptType) {
102
        switch ($cryptType) {
94
            case "crypt" :
103
            case "crypt" :
95
                return ((string)crypt($password1, $password2) === (string)$password2);
104
                return ((string)crypt($password1, $password2) === (string)$password2);
96
                break;
105
                break;
97
            case "none" :
106
            case "none" :
Line 102... Line 111...
102
                return ((string)md5($password1) === (string)$password2);
111
                return ((string)md5($password1) === (string)$password2);
103
                break;
112
                break;
104
            default :
113
            default :
105
                if (function_exists($cryptType)) {
114
                if (function_exists($cryptType)) {
106
                    return ((string)$cryptType($password1) === (string)$password2);
115
                    return ((string)$cryptType($password1) === (string)$password2);
107
                } elseif (method_exists($this,$cryptType)) { 
116
                } elseif (method_exists($this,$cryptType)) {
108
                    return ((string)$this->$cryptType($password1) === (string)$password2);
117
                    return ((string)$this->$cryptType($password1) === (string)$password2);
109
                } else {
118
                } else {
110
                    return false;
119
                    return false;
111
                }
120
                }
112
                break;
121
                break;
113
        }
122
        }
114
    }
123
    }
Line 115... Line 124...
115
 
124
 
116
    // }}}
125
    // }}}
117
    // {{{ supportsChallengeResponse()
126
    // {{{ supportsChallengeResponse()
118
    
127
 
119
    /**
128
    /**
120
      * Returns true if the container supports Challenge Response 
129
      * Returns true if the container supports Challenge Response
121
      * password authentication
130
      * password authentication
122
      */
131
      */
123
    function supportsChallengeResponse()
132
    function supportsChallengeResponse()
124
    {
133
    {
125
        return(false);
134
        return(false);
Line 126... Line 135...
126
    }
135
    }
127
 
136
 
128
    // }}}
137
    // }}}
129
    // {{{ getCryptType()
138
    // {{{ getCryptType()
130
    
139
 
131
    /**
140
    /**
132
      * Returns the crypt current crypt type of the container
141
      * Returns the crypt current crypt type of the container
133
      *
142
      *
Line 144... Line 153...
144
    /**
153
    /**
145
     * List all users that are available from the storage container
154
     * List all users that are available from the storage container
146
     */
155
     */
147
    function listUsers()
156
    function listUsers()
148
    {
157
    {
-
 
158
        $this->log('Auth_Container::listUsers() called.', AUTH_LOG_DEBUG);
149
        return AUTH_METHOD_NOT_SUPPORTED;
159
        return AUTH_METHOD_NOT_SUPPORTED;
150
    }
160
    }
Line 151... Line 161...
151
 
161
 
152
    // }}}
162
    // }}}
Line 159... Line 169...
159
     *
169
     *
160
     * @param string The username
170
     * @param string The username
161
     */
171
     */
162
    function getUser($username)
172
    function getUser($username)
163
    {
173
    {
-
 
174
        $this->log('Auth_Container::getUser() called.', AUTH_LOG_DEBUG);
164
        $users = $this->listUsers();
175
        $users = $this->listUsers();
165
        if ($users === AUTH_METHOD_NOT_SUPPORTED) {
176
        if ($users === AUTH_METHOD_NOT_SUPPORTED) {
166
            return AUTH_METHOD_NOT_SUPPORTED;
177
            return AUTH_METHOD_NOT_SUPPORTED;
167
        }
178
        }
168
        for ($i=0; $c = count($users), $i<$c; $i++) {
179
        for ($i=0; $c = count($users), $i<$c; $i++) {
Line 185... Line 196...
185
     *
196
     *
186
     * @return boolean
197
     * @return boolean
187
     */
198
     */
188
    function addUser($username, $password, $additional=null)
199
    function addUser($username, $password, $additional=null)
189
    {
200
    {
-
 
201
        $this->log('Auth_Container::addUser() called.', AUTH_LOG_DEBUG);
190
        return AUTH_METHOD_NOT_SUPPORTED;
202
        return AUTH_METHOD_NOT_SUPPORTED;
191
    }
203
    }
Line 192... Line 204...
192
 
204
 
193
    // }}}
205
    // }}}
Line 198... Line 210...
198
     *
210
     *
199
     * @param string Username
211
     * @param string Username
200
     */
212
     */
201
    function removeUser($username)
213
    function removeUser($username)
202
    {
214
    {
-
 
215
        $this->log('Auth_Container::removeUser() called.', AUTH_LOG_DEBUG);
203
        return AUTH_METHOD_NOT_SUPPORTED;
216
        return AUTH_METHOD_NOT_SUPPORTED;
204
    }
217
    }
Line 205... Line 218...
205
 
218
 
206
    // }}}
219
    // }}}
Line 212... Line 225...
212
     * @param string Username
225
     * @param string Username
213
     * @param string The new password
226
     * @param string The new password
214
     */
227
     */
215
    function changePassword($username, $password)
228
    function changePassword($username, $password)
216
    {
229
    {
-
 
230
        $this->log('Auth_Container::changePassword() called.', AUTH_LOG_DEBUG);
217
        return AUTH_METHOD_NOT_SUPPORTED;
231
        return AUTH_METHOD_NOT_SUPPORTED;
218
    }
232
    }
Line 219... Line 233...
219
 
233
 
-
 
234
    // }}}
-
 
235
    // {{{ log()
-
 
236
 
-
 
237
    /**
-
 
238
     * Log a message to the Auth log
-
 
239
     *
-
 
240
     * @param string The message
-
 
241
     * @param int
-
 
242
     * @return boolean
-
 
243
     */
-
 
244
    function log($message, $level = AUTH_LOG_DEBUG) {
-
 
245
 
-
 
246
        if (is_null($this->_auth_obj)) {
-
 
247
 
-
 
248
            return false;
-
 
249
 
-
 
250
        } else {
-
 
251
 
-
 
252
            return $this->_auth_obj->log($message, $level);
-
 
253
 
-
 
254
        }
-
 
255
 
-
 
256
    }
-
 
257
 
Line 220... Line 258...
220
    // }}}
258
    // }}}
Line 221... Line 259...
221
 
259