[ Index ] |
|
Code source de Horde 3.1.3 |
1 <?php 2 /** 3 * The Auth_sasl:: class provides a SASL-based implementation of the Horde 4 * authentication system. 5 * 6 * SASL is the Simple Authentication and Security Layer (as defined by RFC 7 * 2222). It provides a system for adding plugable authenticating support to 8 * connection-based protocols. 9 * 10 * This driver relies on the PECL sasl package: 11 * 12 * http://pecl.php.net/package/sasl 13 * 14 * Optional parameters:<pre> 15 * 'app' The name of the authenticating application. 16 * DEFAULT: horde 17 * 'service' The name of the SASL service to use when authenticating. 18 * DEFAULT: php</pre> 19 * 20 * 21 * $Horde: framework/Auth/Auth/sasl.php,v 1.4.10.9 2006/01/01 21:28:07 jan Exp $ 22 * 23 * Copyright 2004-2006 Jon Parise <jon@horde.org> 24 * 25 * See the enclosed file COPYING for license information (LGPL). If you 26 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. 27 * 28 * @author Jan Parise <jon@horde.org> 29 * @since Horde 3.0 30 * @package Horde_Auth 31 */ 32 class Auth_sasl extends Auth { 33 34 /** 35 * An array of capabilities, so that the driver can report which 36 * operations it supports and which it doesn't. 37 * 38 * @var array 39 */ 40 var $capabilities = array('add' => false, 41 'update' => false, 42 'resetpassword' => false, 43 'remove' => false, 44 'list' => false, 45 'transparent' => false); 46 47 /** 48 * Constructs a new SASL authentication object. 49 * 50 * @param array $params A hash containing connection parameters. 51 */ 52 function Auth_sasl($params = array()) 53 { 54 $this->_params = $params; 55 56 if (!extension_loaded('sasl')) { 57 dl('sasl.so'); 58 } 59 60 $app = (!empty($params['app'])) ? $params['app'] : 'horde'; 61 sasl_server_init($app); 62 } 63 64 /** 65 * Find out if a set of login credentials are valid. 66 * 67 * @access private 68 * 69 * @param string $userId The userId to check. 70 * @param array $credentials An array of login credentials. 71 * 72 * @return boolean Whether or not the credentials are valid. 73 */ 74 function _authenticate($userId, $credentials) 75 { 76 if (empty($credentials['password'])) { 77 Horde::fatal(_("No password provided for Login authentication."), __FILE__, __LINE__); 78 } 79 80 if (!extension_loaded('sasl')) { 81 Horde::fatal(_("SASL authentication is not available."), __FILE__, __LINE__); 82 } 83 84 $service = (!empty($params['service'])) ? $params['service'] : 'php'; 85 $conn = sasl_server_new($service); 86 if (!is_resource($conn)) { 87 Horde::fatal(_("Failed to create new SASL connection."), __FILE__, __LINE__); 88 } 89 90 if (!sasl_checkpass($conn, $userId, $credentials['password'])) { 91 $this->_setAuthError(AUTH_REASON_MESSAGE, sasl_errdetail($conn)); 92 return false; 93 } 94 95 return true; 96 } 97 98 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 18:01:28 2007 | par Balluche grâce à PHPXref 0.7 |