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

Class: File_Passwd

Source Location: /File_Passwd-1.1.7/Passwd.php

Class Overview


The package File_Passwd provides classes and methods to handle many different kinds of passwd files.


Author(s):

Version:

  • $Revision: 1.25 $

    Usage Example:

    1.   $passwd &File_Passwd::factory('Unix');

Methods


Inherited Variables

Inherited Methods


Class Details

[line 119]
The package File_Passwd provides classes and methods to handle many different kinds of passwd files.

The File_Passwd class in certain is a factory container for its special purpose extension classes, each handling a specific passwd file format. It also provides a static method for reasonable fast user authentication. Beside that it offers some encryption methods used by the extensions.

  • Author: Michael Wallner <mike@php.net>
  • Version:

    $Revision: 1.25 $

    Usage Example:

    1.   $passwd &File_Passwd::factory('Unix');



[ Top ]


Method Detail

apiVersion   [line 128]

string apiVersion( )

Get API version
  • Return: API version
  • Access: public

[ Top ]

crypt_apr_md5   [line 233]

mixed crypt_apr_md5( string $plain, [string $salt = null])

APR compatible MD5 encryption
  • Access: public

Parameters:

string   $plain   —  plaintext to crypt
string   $salt   —  the salt to use for encryption

[ Top ]

crypt_des   [line 173]

string crypt_des( string $plain, [string $salt = null])

DES encryption
  • Return: crypted text
  • Access: public

Parameters:

string   $plain   —  plaintext to encrypt
string   $salt   —  the salt to use for encryption (2 chars)

[ Top ]

crypt_md5   [line 189]

string crypt_md5( string $plain, [string $salt = null])

MD5 encryption
  • Return: crypted text
  • Access: public

Parameters:

string   $plain   —  plaintext to encrypt
string   $salt   —  the salt to use for encryption (>2 chars starting with $1$)

[ Top ]

crypt_plain   [line 159]

string crypt_plain( string $plain)

No encryption (plaintext)
  • Return: plaintext input
  • Access: public

Parameters:

string   $plain   —  plaintext passwd

[ Top ]

crypt_sha   [line 212]

mixed crypt_sha( string $plain)

SHA1 encryption

Returns a PEAR_Error if sha1() is not available (PHP<4.3).

  • Return: crypted string or PEAR_Error
  • Throws: PEAR_Error
  • Access: public

Parameters:

string   $plain   —  plaintext to encrypt

[ Top ]

factory   [line 349]

object File_Passwd_$class &factory( string $class)

Factory for new extensions

  • Unix for standard Unix passwd files
  • CVS for CVS pserver passwd files
  • SMB for SMB server passwd files
  • Authbasic for AuthUserFiles
  • Authdigest for AuthDigestFiles
  • Custom for custom formatted passwd files
Returns a PEAR_Error if the desired class/file couldn't be loaded.

  • Return: - desired Passwd object
  • Throws: PEAR_Error
  • Access: public

Parameters:

string   $class   —  the desired subclass of File_Passwd

[ Top ]

salt   [line 141]

mixed salt( [int $length = 2])

Generate salt
  • Access: public

Parameters:

int   $length   —  salt length

[ Top ]

staticAuth   [line 406]

return staticAuth( string $type, string $file, string $user, string $pass, [mixed $opt = ''])

Fast authentication of a certain user

Though this approach should be reasonable fast, it is NOT with APR compatible MD5 encryption used for htpasswd style password files encrypted in MD5. Generating one MD5 password takes about 0.3 seconds!

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)
  • invalid $type was provided
  • invalid $opt was provided
Depending on $type, $opt should be:
  • Smb: encryption method (NT or LM)
  • Unix: encryption method (des or md5)
  • Authbasic: encryption method (des, sha or md5)
  • Authdigest: the realm the user is in
  • Cvs: n/a (empty)
  • Custom: array of 2 elements: encryption function and delimiter

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

Parameters:

string   $type   —  Unix, Cvs, Smb, Authbasic or Authdigest
string   $file   —  path to passwd file
string   $user   —  the user to authenticate
string   $pass   —  the plaintext password
mixed   $opt   — 
    • Unix: des or md5
    • Authbasic des, sha or md5
    • Authdigest realm the user is in
    • Custom encryption function and delimiter character

    [ Top ]


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