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

Class: File_Passwd_Authdigest

Source Location: /File_Passwd-1.1.7/Passwd/Authdigest.php

Class Overview

File_Passwd_Common
   |
   --File_Passwd_Authdigest

Manipulate AuthDigestFiles as used for HTTP Digest Authentication.


Author(s):

Version:

  • $Revision: 1.13 $

Methods


Inherited Variables

Inherited Methods

Class: File_Passwd_Common

File_Passwd_Common::__construct()
Constructor (ZE2)
File_Passwd_Common::delUser()
Delete a certain user
File_Passwd_Common::getFile()
Get path of passwd file
File_Passwd_Common::listUser()
List user
File_Passwd_Common::load()
Loads the file
File_Passwd_Common::parse()
Parse the content of the file
File_Passwd_Common::save()
Apply changes and rewrite passwd file
File_Passwd_Common::setFile()
Set path to passwd file
File_Passwd_Common::userExists()
Check if a certain user already exists
File_Passwd_Common::_auth()
Base method for File_Passwd::staticAuth()
File_Passwd_Common::_close()
Closes a prior opened and locked file handle
File_Passwd_Common::_open()
Opens a file, locks it exclusively and returns the filehandle
File_Passwd_Common::_save()
Save the modified content to the passwd file

Class Details

[line 60]
Manipulate AuthDigestFiles as used for HTTP Digest Authentication.

<u> Usage Example: </u>

  1.    $htd &File_Passwd::factory('Authdigest');
  2.    $htd->setFile('/www/mike/auth/.htdigest');
  3.    $htd->load();
  4.    $htd->addUser('mike''myRealm''secret');
  5.    $htd->save();

<u> Output of listUser() </u>

      array
       + user  => array
                   + realm => crypted_passwd
                   + realm => crypted_passwd
       + user  => array
                   + realm => crypted_passwd

  • Author: Michael Wallner <mike@php.net>
  • Version: $Revision: 1.13 $
  • Access: public


[ Top ]


Method Detail

File_Passwd_Authdigest (Constructor)   [line 76]

File_Passwd_Authdigest File_Passwd_Authdigest( [string $file = '.htdigest'])

Constructor
  • Access: public

Parameters:

string   $file   —  path to AuthDigestFile

[ Top ]

addUser   [line 155]

mixed addUser( string $user, string $realm, string $pass)

Add an user

Returns a PEAR_Error if:

  • the user already exists in the supplied realm
  • the user or realm contain illegal characters
$user and $realm must start with an alphabetical charachter and must NOT contain any other characters than alphanumerics, the underline and dash.

  • Return: true on success or a PEAR_Error
  • Throws: PEAR_Error
  • Access: public

Parameters:

string   $user   —  the user to add
string   $realm   —  the realm the user should be in
string   $pass   —  the plaintext password

[ Top ]

changePasswd   [line 242]

mixed changePasswd( string $user, string $realm, string $pass)

Change the password of a certain user

Returns a PEAR_Error if:

  • user doesn't exist in the supplied realm
  • user or realm contains illegal characters
This method in fact adds the user whith the new password after deleting the user.

  • Return: true on success or a PEAR_Error
  • Throws: PEAR_Error
  • Access: public

Parameters:

string   $user   —  the user whose password should be changed
string   $realm   —  the realm the user is in
string   $pass   —  the new plaintext password

[ Top ]

delUserInRealm   [line 299]

mixed delUserInRealm( string $user, string $inRealm)

Delete a certain user in a specific realm

Returns a PEAR_Error if $user doesn't exist $inRealm.

  • Return: true on success or PEAR_Error
  • Throws: PEAR_Error
  • Access: public

Parameters:

string   $user   —  the user to remove
string   $inRealm   —  the realm the user should be in

[ Top ]

generatePasswd   [line 348]

string generatePasswd( string $user, string $realm, string $pass)

Generate Password
  • Return: The crypted password.
  • Access: public

Parameters:

string   $user   —  The username.
string   $realm   —  The realm the user is in.
string   $pass   —  The plaintext password.

[ Top ]

listUserInRealm   [line 208]

array listUserInRealm( [string $inRealm = ''])

List all user of (a | all) realm(s)

Returns:

  • associative array of users of ONE realm if $inRealm was supplied
           realm1
            + user1 => pass
            + user2 => pass
            + user3 => pass
  • associative array of all realms with all users
           array
            + realm1 => array
                         + user1 => pass
                         + user2 => pass
                         + user3 => pass
            + realm2 => array
                         + user3 => pass
            + realm3 => array
                         + user1 => pass
                         + user2 => pass

  • Access: public

Parameters:

string   $inRealm   —  the realm to list users of; if omitted, you'll get all realms

[ Top ]

parse   [line 320]

mixed parse( )

Parse the AuthDigestFile

Returns a PEAR_Error if AuthDigestFile has invalid format.

  • Return: true on success or PEAR_Error
  • Throws: PEAR_Error
  • Access: public

Overrides File_Passwd_Common::parse() (Parse the content of the file)
[ Top ]

save   [line 125]

mixed save( )

Apply changes and rewrite AuthDigestFile

Returns a PEAR_Error if:

  • directory in which the file should reside couldn't be created
  • file couldn't be opened in write mode
  • file couldn't be locked exclusively
  • file couldn't be unlocked
  • file couldn't be closed

  • Return: true on success or a PEAR_Error
  • Throws: PEAR_Error
  • Access: public

Overrides File_Passwd_Common::save() (Apply changes and rewrite passwd file)
[ Top ]

staticAuth   [line 101]

mixed staticAuth( string $file, string $user, string $pass, string $realm)

Fast authentication of a certain user

Returns a PEAR_Error if:

  • file doesn't exist
  • file couldn't be opened in read mode
  • file couldn't be locked exclusively
  • file couldn't be unlocked (only if auth fails)
  • file couldn't be closed (only if auth fails)

  • Return: true if authenticated, false if not or PEAR_Error
  • Throws: PEAR_Error
  • Access: public

Parameters:

string   $file   —  path to passwd file
string   $user   —  user to authenticate
string   $pass   —  plaintext password
string   $realm   —  the realm the user is in

[ Top ]

userInRealm   [line 283]

boolean userInRealm( string $user, string $realm)

Ckeck if a certain user is in a specific realm
  • Throws: PEAR_Error
  • Access: public

Parameters:

string   $user   —  the user to check
string   $realm   —  the realm the user shuold be in

[ Top ]

verifyPasswd   [line 263]

mixed verifyPasswd( string $user, string $realm, string $pass)

Verifiy password

Returns a PEAR_Error if the user doesn't exist in the supplied realm.

  • Return: true if passwords equal, false if they don't, or PEAR_Error
  • Throws: PEAR_Error
  • Access: public

Parameters:

string   $user   —  the user whose password should be verified
string   $realm   —  the realm the user is in
string   $pass   —  the plaintext password to verify

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:28:09 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.