Auth
[ class tree: Auth ] [ index: Auth ] [ all elements ]

Source for file Container.php

Documentation is available at Container.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP Version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2003 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | 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        |
  10. // | available at through the world-wide-web at                           |
  11. // | http://www.php.net/license/2_02.txt.                                 |
  12. // | 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          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: Martin Jansen <mj@php.net>                                  |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: Container.php,v 1.21 2006/02/28 02:19:22 aashley Exp $
  20. //
  21.  
  22. /**
  23.  * Storage class for fetching login data
  24.  *
  25.  * @author   Martin Jansen <mj@php.net>
  26.  * @author   Adam Ashley <aashley@php.net>
  27.  * @package  Auth
  28.  */
  29. {
  30.  
  31.     // {{{ properties
  32.  
  33.     /**
  34.      * User that is currently selected from the storage container.
  35.      *
  36.      * @access public
  37.      */
  38.     var $activeUser = "";
  39.  
  40.     // }}}
  41.  
  42.     // {{{ Auth_Container() [constructor]
  43.  
  44.     /**
  45.      * Constructor
  46.      *
  47.      * Has to be overwritten by each storage class
  48.      *
  49.      * @access public
  50.      */
  51.     function Auth_Container()
  52.     {
  53.     }
  54.  
  55.     // }}}
  56.     // {{{ fetchData()
  57.  
  58.     /**
  59.      * Fetch data from storage container
  60.      *
  61.      * Has to be overwritten by each storage class
  62.      *
  63.      * @access public
  64.      */
  65.     function fetchData($username$password$isChallengeResponse=false)
  66.     {
  67.     }
  68.  
  69.     // }}}
  70.     // {{{ verifyPassword()
  71.  
  72.     /**
  73.      * Crypt and verfiy the entered password
  74.      *
  75.      * @param  string Entered password
  76.      * @param  string Password from the data container (usually this password
  77.      *                 is already encrypted.
  78.      * @param  string Type of algorithm with which the password from
  79.      *                 the container has been crypted. (md5, crypt etc.)
  80.      *                 Defaults to "md5".
  81.      * @return bool   True, if the passwords match
  82.      */
  83.     function verifyPassword($password1$password2$cryptType "md5")
  84.     {
  85.         switch ($cryptType{
  86.             case "crypt" :
  87.                 return crypt($password1$password2== $password2 );
  88.                 break;
  89.             case "none" :
  90.             case "" :
  91.                 return ($password1 == $password2);
  92.                 break;
  93.             case "md5" :
  94.                 return (md5($password1== $password2);
  95.                 break;
  96.             default :
  97.                 if (function_exists($cryptType)) {
  98.                     return ($cryptType($password1== $password2);
  99.                 elseif (method_exists($this,$cryptType)) 
  100.                     return ($this->$cryptType($password1== $password2);
  101.                 else {
  102.                     return false;
  103.                 }
  104.                 break;
  105.         }
  106.     }
  107.  
  108.     // }}}
  109.     // {{{ supportsChallengeResponse()
  110.     
  111.     /**
  112.       * Returns true if the container supports Challenge Response
  113.       * password authentication
  114.       */
  115.     function supportsChallengeResponse()
  116.     {
  117.         return(false);
  118.     }
  119.  
  120.     // }}}
  121.     // {{{ getCryptType()
  122.     
  123.     /**
  124.       * Returns the crypt current crypt type of the container
  125.       *
  126.       * @return string 
  127.       */
  128.     function getCryptType()
  129.     {
  130.         return('');
  131.     }
  132.  
  133.     // }}}
  134.     // {{{ listUsers()
  135.  
  136.     /**
  137.      * List all users that are available from the storage container
  138.      */
  139.     function listUsers()
  140.     {
  141.         return AUTH_METHOD_NOT_SUPPORTED;
  142.     }
  143.  
  144.     // }}}
  145.     // {{{ getUser()
  146.  
  147.     /**
  148.      * Returns a user assoc array
  149.      *
  150.      * Containers which want should overide this
  151.      *
  152.      * @param string The username
  153.      */
  154.     function getUser($username)
  155.     {
  156.         $users $this->listUsers();
  157.         if ($users === AUTH_METHOD_NOT_SUPPORTED{
  158.             return AUTH_METHOD_NOT_SUPPORTED;
  159.         }
  160.         for ($i=0; $c count($users)$i<$c$i++{
  161.             if ($users[$i]['username'== $username{
  162.                 return $users[$i];
  163.             }
  164.         }
  165.         return false;
  166.     }
  167.  
  168.     // }}}
  169.     // {{{ addUser()
  170.  
  171.     /**
  172.      * Add a new user to the storage container
  173.      *
  174.      * @param string Username
  175.      * @param string Password
  176.      * @param array  Additional information
  177.      *
  178.      * @return boolean 
  179.      */
  180.     function addUser($username$password$additional=null)
  181.     {
  182.         return AUTH_METHOD_NOT_SUPPORTED;
  183.     }
  184.  
  185.     // }}}
  186.     // {{{ removeUser()
  187.  
  188.     /**
  189.      * Remove user from the storage container
  190.      *
  191.      * @param string Username
  192.      */
  193.     function removeUser($username)
  194.     {
  195.         return AUTH_METHOD_NOT_SUPPORTED;
  196.     }
  197.  
  198.     // }}}
  199.     // {{{ changePassword()
  200.  
  201.     /**
  202.      * Change password for user in the storage container
  203.      *
  204.      * @param string Username
  205.      * @param string The new password
  206.      */
  207.     function changePassword($username$password)
  208.     {
  209.         return AUTH_METHOD_NOT_SUPPORTED;
  210.     }
  211.  
  212.     // }}}
  213.  
  214. }
  215.  
  216. ?>

Documentation generated on Mon, 11 Mar 2019 14:37:16 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.