/[dolibarr]/dolibarr/htdocs/includes/pear/Auth/Container.php
ViewVC logotype

Diff of /dolibarr/htdocs/includes/pear/Auth/Container.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by rodolphe, Wed Jun 30 16:28:15 2004 UTC revision 1.2 by eldy, Sun Sep 4 19:10:19 2005 UTC
# Line 1  Line 1 
1  <?php  <?php
2  //  //
3  // +----------------------------------------------------------------------+  // +----------------------------------------------------------------------+
4  // | PHP Version 4                                                        |  // | PHP Version 4                                                        |
5  // +----------------------------------------------------------------------+  // +----------------------------------------------------------------------+
6  // | Copyright (c) 1997-2003 The PHP Group                                |  // | Copyright (c) 1997-2003 The PHP Group                                |
7  // +----------------------------------------------------------------------+  // +----------------------------------------------------------------------+
8  // | This source file is subject to version 2.02 of the PHP license,      |  // | This source file is subject to version 2.02 of the PHP license,      |
9  // | that is bundled with this package in the file LICENSE, and is        |  // | that is bundled with this package in the file LICENSE, and is        |
10  // | available at through the world-wide-web at                           |  // | available at through the world-wide-web at                           |
11  // | http://www.php.net/license/2_02.txt.                                 |  // | http://www.php.net/license/2_02.txt.                                 |
12  // | If you did not receive a copy of the PHP license and are unable to   |  // | If you did not receive a copy of the PHP license and are unable to   |
13  // | obtain it through the world-wide-web, please send a note to          |  // | obtain it through the world-wide-web, please send a note to          |
14  // | license@php.net so we can mail you a copy immediately.               |  // | license@php.net so we can mail you a copy immediately.               |
15  // +----------------------------------------------------------------------+  // +----------------------------------------------------------------------+
16  // | Authors: Martin Jansen <mj@php.net>                                  |  // | Authors: Martin Jansen <mj@php.net>                                  |
17  // +----------------------------------------------------------------------+  // +----------------------------------------------------------------------+
18  //  //
19  // $Id$  // $Id$
20  //  //
21    
22  define("AUTH_METHOD_NOT_SUPPORTED", -4);  define("AUTH_METHOD_NOT_SUPPORTED", -4);
23    
24  /**  /**
25   * Storage class for fetching login data   * Storage class for fetching login data
26   *   *
27   * @author   Martin Jansen <mj@php.net>   * @author   Martin Jansen <mj@php.net>
28   * @package  Auth   * @package  Auth
29   */   */
30  class Auth_Container  class Auth_Container
31  {  {
32    
33      /**      /**
34       * User that is currently selected from the storage container.       * User that is currently selected from the storage container.
35       *       *
36       * @access public       * @access public
37       */       */
38      var $activeUser = "";      var $activeUser = "";
39    
40      // {{{ Constructor      // {{{ Constructor
41    
42      /**      /**
43       * Constructor       * Constructor
44       *       *
45       * Has to be overwritten by each storage class       * Has to be overwritten by each storage class
46       *       *
47       * @access public       * @access public
48       */       */
49      function Auth_Container()      function Auth_Container()
50      {      {
51      }      }
52    
53      // }}}      // }}}
54      // {{{ fetchData()      // {{{ fetchData()
55    
56      /**      /**
57       * Fetch data from storage container       * Fetch data from storage container
58       *       *
59       * Has to be overwritten by each storage class       * Has to be overwritten by each storage class
60       *       *
61       * @access public       * @access public
62       */       */
63      function fetchData()      function fetchData()
64      {      {
65      }      }
66    
67      // }}}      // }}}
68      // {{{ verifyPassword()      // {{{ verifyPassword()
69    
70      /**      /**
71       * Crypt and verfiy the entered password       * Crypt and verfiy the entered password
72       *       *
73       * @param  string Entered password       * @param  string Entered password
74       * @param  string Password from the data container (usually this password       * @param  string Password from the data container (usually this password
75       *                is already encrypted.       *                is already encrypted.
76       * @param  string Type of algorithm with which the password from       * @param  string Type of algorithm with which the password from
77       *                the container has been crypted. (md5, crypt etc.)       *                the container has been crypted. (md5, crypt etc.)
78       *                Defaults to "md5".       *                Defaults to "md5".
79       * @return bool   True, if the passwords match       * @return bool   True, if the passwords match
80       */       */
81      function verifyPassword($password1, $password2, $cryptType = "md5")      function verifyPassword($password1, $password2, $cryptType = "md5")
82      {      {
83          switch ($cryptType) {          switch ($cryptType) {
84          case "crypt" :          case "crypt" :
85              return (($password2 == "**" . $password1) ||              return (($password2 == "**" . $password1) ||
86                      (crypt($password1, $password2) == $password2)                      (crypt($password1, $password2) == $password2)
87                      );                      );
88              break;              break;
89    
90          case "none" :          case "none" :
91              return ($password1 == $password2);              return ($password1 == $password2);
92              break;              break;
93    
94          case "md5" :          case "md5" :
95              return (md5($password1) == $password2);              return (md5($password1) == $password2);
96              break;              break;
97    
98          default :          default :
99              if (function_exists($cryptType)) {              if (function_exists($cryptType)) {
100                  return ($cryptType($password1) == $password2);                  return ($cryptType($password1) == $password2);
101              } else {              } else {
102                  return false;                  return false;
103              }              }
104              break;              break;
105          }          }
106      }      }
107    
108      // }}}      // }}}
109      // {{{ listUsers()      // {{{ listUsers()
110    
111      /**      /**
112       * List all users that are available from the storage container       * List all users that are available from the storage container
113       */       */
114      function listUsers()      function listUsers()
115      {      {
116          return AUTH_METHOD_NOT_SUPPORTED;          return AUTH_METHOD_NOT_SUPPORTED;
117      }      }
118    
119      // }}}      // }}}
120      // {{{ addUser()      // {{{ addUser()
121    
122      /**      /**
123       * Add a new user to the storage container       * Add a new user to the storage container
124       *       *
125       * @param string Username       * @param string Username
126       * @param string Password       * @param string Password
127       * @param array  Additional information       * @param array  Additional information
128       *       *
129       * @return boolean       * @return boolean
130       */       */
131      function addUser($username, $password, $additional=null)      function addUser($username, $password, $additional=null)
132      {      {
133          return AUTH_METHOD_NOT_SUPPORTED;          return AUTH_METHOD_NOT_SUPPORTED;
134      }      }
135    
136      // }}}      // }}}
137      // {{{ removeUser()      // {{{ removeUser()
138    
139      /**      /**
140       * Remove user from the storage container       * Remove user from the storage container
141       *       *
142       * @param string Username       * @param string Username
143       */       */
144      function removeUser($username)      function removeUser($username)
145      {      {
146          return AUTH_METHOD_NOT_SUPPORTED;          return AUTH_METHOD_NOT_SUPPORTED;
147      }      }
148    
149      // }}}      // }}}
150    
151  }  }
152  ?>  ?>

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26