[ Index ] |
|
Code source de Horde 3.1.3 |
1 <?php 2 /** 3 * The Net_IMSP_Auth_imtest class for IMSP authentication. 4 * 5 * Required parameters:<pre> 6 * 'username' Username to logon to IMSP server as. 7 * 'password' Password for current user. 8 * 'server' The hostname of the IMSP server. 9 * 'port' The port of the IMSP server. 10 * 'socket' The named socket to use for connection 11 * 'command' Path to the imtest command on localhost 12 * 'auth_mechanism' Authentication method to use with imtest</pre> 13 * 14 * $Horde: framework/Net_IMSP/IMSP/Auth/imtest.php,v 1.12.2.4 2006/01/01 21:28:28 jan Exp $ 15 * 16 * Copyright 2005-2006 Liam Hoekenga <liamr@umich.edu> 17 * Copyright 2003-2006 Michael Rubinsky <mrubinsk@horde.org> 18 * 19 * See the enclosed file COPYING for license information (LGPL). If you 20 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. 21 * 22 * @author Liam Hoekenga <liamr@umich.edu> 23 * @author Michael Rubinsky <mrubinsk@horde.org> 24 * @package Net_IMSP 25 */ 26 class Net_IMSP_Auth_imtest extends Net_IMSP_Auth { 27 28 /** 29 * Private authentication function. Provides actual 30 * authentication code. 31 * 32 * @access private 33 * @param mixed $params Hash of IMSP parameters. 34 * 35 * @return mixed Net_IMSP object connected to server if successful, 36 * PEAR_Error on failure. 37 */ 38 function &_authenticate($params) 39 { 40 $imsp = &Net_IMSP::singleton('none', $params); 41 $command = ''; 42 $error_return = ''; 43 44 if (strtolower($params['auth_mechanism']) == 'gssapi' && 45 isset($_SERVER['KRB5CCNAME'])) { 46 $command .= 'KRB5CCNAME=' . $_SERVER['KRB5CCNAME']; 47 } 48 49 $command .= ' ' . $params['command']. 50 ' -m ' . $params['auth_mechanism'] . 51 ' -u ' . escapeshellarg($params['username']) . 52 ' -a ' . escapeshellarg($params['username']) . 53 ' -w ' . escapeshellarg($params['password']). 54 ' -p ' . $params['port'] . 55 ' -X ' . $params['socket'] . 56 ' ' . $params['server']; 57 58 $conn_attempts = 0; 59 while ($conn_attempts++ < 4) { 60 $attempts = 0; 61 if (!file_exists($params['socket'])) { 62 exec($command . ' > /dev/null 2>&1'); 63 sleep(1); 64 while (!file_exists($params['socket'])) { 65 usleep(200000); 66 if ($attempts++ > 5) { 67 $error_return = ': No socket after 10 seconds of trying!'; 68 continue 2; 69 } 70 } 71 } 72 $fp = @fsockopen($params['socket'], 0, $error_number, $error_string, 30); 73 $error_return = $error_string; 74 if ($fp) break; 75 unlink($params['socket']); 76 77 } 78 //Failure? 79 if (!empty($error_return)) { 80 return $imsp->imspError('Connection to IMSP host failed.' . ': ' . $error_return, __FILE__, __LINE__); 81 } 82 //Success 83 $imsp->_stream = $fp; 84 return $imsp; 85 } 86 87 /** 88 * Force a logout command to the imsp stream. 89 * 90 */ 91 function logout() 92 { 93 $this->_imsp->logout(); 94 } 95 96 /** 97 * Returns the driver type. 98 * 99 * @return string The type of this IMSP_Auth driver. 100 */ 101 function getDriverType() 102 { 103 return 'imtest'; 104 } 105 }
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 |