| [ Index ] |
|
Code source de Horde 3.1.3 |
1 <?php 2 /** 3 * The Net_IMSP_Auth_plaintext 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.</pre> 10 * 11 * $Horde: framework/Net_IMSP/IMSP/Auth/plaintext.php,v 1.7.10.11 2006/01/01 21:28:28 jan Exp $ 12 * 13 * Copyright 2003-2006 Michael Rubinsky <mrubinsk@horde.org> 14 * 15 * See the enclosed file COPYING for license information (LGPL). If you 16 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. 17 * 18 * @author Michael Rubinsky <mrubinsk@horde.org> 19 * @package Net_IMSP 20 */ 21 class Net_IMSP_Auth_plaintext extends Net_IMSP_Auth { 22 23 /** 24 * Private authentication function. Provides actual 25 * authentication code. 26 * 27 * @access private 28 * @param mixed $params Hash of IMSP parameters. 29 * 30 * @return mixed Net_IMSP object connected to server if successful, 31 * PEAR_Error on failure. 32 */ 33 function &_authenticate($params) 34 { 35 $imsp = &Net_IMSP::singleton('none', $params); 36 $result = $imsp->init(); 37 if (is_a($result, 'PEAR_Error')) { 38 return $result; 39 } 40 41 $userId = $params['username']; 42 $credentials = $params['password']; 43 44 /* Start the command. */ 45 $result = $imsp->imspSend('LOGIN ', true, false); 46 if (is_a($result, 'PEAR_Error')) { 47 return $result; 48 } 49 50 /* Username as a {}? */ 51 if (preg_match(IMSP_MUST_USE_LITERAL, $userId)) { 52 $biUser = sprintf('{%d}', strlen($userId)); 53 $result = $imsp->imspSend($biUser, false, true); 54 if (is_a($result, 'PEAR_Error')) { 55 return $result; 56 } 57 58 if (!preg_match("/^\+/", 59 $imsp->imspReceive())) { 60 61 return $imsp->imspError('Did not receive expected command continuation response from IMSP server.', 62 __FILE__, __LINE__); 63 } 64 } 65 66 $result = $imsp->imspSend($userId . ' ', false, false); 67 if (is_a($result, 'PEAR_Error')) { 68 return $result; 69 } 70 71 /* Don't want to log the password! */ 72 $logValue = $imsp->logEnabled; 73 $imsp->logEnabled = false; 74 75 /* Pass as {}? */ 76 if (preg_match(IMSP_MUST_USE_LITERAL, $credentials)) { 77 $biPass = sprintf('{%d}', strlen($credentials)); 78 $result = $imsp->imspSend($biPass, false, true); 79 if (is_a($result, 'PEAR_Error')) { 80 return $result; 81 } 82 83 if (!preg_match("/^\+/", 84 $imsp->imspReceive())) { 85 return $imsp->imspError('Did not receive expected command continuation response from IMSP server.', 86 __FILE__, __LINE__); 87 } 88 } 89 90 $result = $imsp->imspSend($credentials, false, true); 91 if (is_a($result, 'PEAR_Error')) { 92 return $result; 93 } 94 95 /* Restore the logging boolean. */ 96 $imsp->logEnabled = $logValue; 97 98 $server_response = $imsp->imspReceive(); 99 if (is_a($server_response, 'PEAR_Error')) { 100 return $server_response; 101 } 102 103 if ($server_response != 'OK') { 104 return $imsp->imspError('Login to IMSP host failed.', __FILE__, __LINE__); 105 } 106 107 return $imsp; 108 } 109 110 /** 111 * Force a logout command to the imsp stream. 112 * 113 */ 114 function logout() 115 { 116 $this->_imsp->logout(); 117 } 118 119 /** 120 * Return the driver type 121 * 122 * @return string the type of this IMSP_Auth driver 123 */ 124 function getDriverType() 125 { 126 return 'plaintext'; 127 } 128 129 }
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 |