1<?php 2/** 3 * Copyright 2015-2017 Horde LLC (http://www.horde.org/) 4 * 5 * See the enclosed file COPYING for license information (LGPL). If you did 6 * not receive this file, see http://opensource.org/licenses/lgpl-2.1.php 7 * 8 * @author Jan Schneider <jan@horde.org> 9 * @category Horde 10 * @license http://opensource.org/licenses/lgpl-2.1.php LGPL 11 * @package Core 12 */ 13 14/** 15 * The Horde_Core_Auth_UsernameHook class wraps another authentication driver 16 * but converts all user names through the user name hooks where necessary. 17 * 18 * @author Jan Schneider <jan@horde.org> 19 * @category Horde 20 * @license http://opensource.org/licenses/lgpl-2.1.php LGPL 21 * @package Core 22 */ 23class Horde_Core_Auth_UsernameHook extends Horde_Auth_Base 24{ 25 /** 26 * The wrapped authentication driver. 27 * 28 * @var Horde_Auth_Base 29 */ 30 protected $_base; 31 32 /** 33 * Constructor. 34 * 35 * @param array $params Required parameters: 36 * - base: (Horde_Auth_Base) The base Horde_Auth driver. 37 * 38 * @throws InvalidArgumentException 39 */ 40 public function __construct(array $params = array()) 41 { 42 if (!isset($params['base'])) { 43 throw new InvalidArgumentException('Missing base parameter.'); 44 } 45 46 $this->_base = $params['base']; 47 unset($params['base']); 48 49 parent::__construct($params); 50 } 51 52 /** 53 */ 54 protected function _authenticate($userId, $credentials) 55 { 56 } 57 58 /** 59 */ 60 public function authenticate($userId, $credentials, $login = true) 61 { 62 return $this->_base->authenticate($userId, $credentials, $login); 63 } 64 65 66 /** 67 */ 68 public function validateAuth() 69 { 70 return $this->_base->validateAuth(); 71 } 72 73 /** 74 */ 75 public function addUser($userId, $credentials) 76 { 77 return $this->_base->addUser( 78 $GLOBALS['registry']->convertUsername($userId, true), 79 $credentials 80 ); 81 } 82 83 /** 84 */ 85 public function lockUser($userId, $time = 0) 86 { 87 return $this->_base->lockUser( 88 $GLOBALS['registry']->convertUsername($userId, true), 89 $time 90 ); 91 } 92 93 /** 94 */ 95 public function unlockUser($userId, $resetBadLogins = false) 96 { 97 return $this->_base->unlockUser( 98 $GLOBALS['registry']->convertUsername($userId, true), 99 $resetBadLogins 100 ); 101 } 102 103 /** 104 */ 105 public function isLocked($userId, $show_details = false) 106 { 107 return $this->_base->isLocked( 108 $GLOBALS['registry']->convertUsername($userId, true), 109 $show_details 110 ); 111 } 112 113 /** 114 */ 115 public function updateUser($oldID, $newID, $credentials) 116 { 117 return $this->_base->updateUser($oldID, $newID, $credentials); 118 } 119 120 /** 121 */ 122 public function removeUser($userId) 123 { 124 return $this->_base->removeUser($userId); 125 } 126 127 /** 128 */ 129 public function listUsers($sort = false) 130 { 131 return $this->_base->listUsers($sort); 132 } 133 134 /** 135 */ 136 public function exists($userId) 137 { 138 return $this->_base->exists($userId); 139 } 140 141 /** 142 */ 143 public function transparent() 144 { 145 return $this->_base->transparent(); 146 } 147 148 /** 149 */ 150 public function resetPassword($userId) 151 { 152 return $this->_base->resetPassword($userId); 153 } 154 155 /** 156 */ 157 public function hasCapability($capability) 158 { 159 return $this->_base->hasCapability($capability); 160 } 161 162 /** 163 */ 164 public function getParam($param) 165 { 166 return $this->_base->getParam($param); 167 } 168 169 /** 170 */ 171 public function getCredential($name = null) 172 { 173 return $this->_base->getCredential($name); 174 } 175 176 /** 177 */ 178 public function setCredential($type, $value) 179 { 180 return $this->_base->setCredential($type, $value); 181 } 182 183 /** 184 */ 185 public function setError($type, $msg = null) 186 { 187 return $this->_base->setError($type, $msg); 188 } 189 190 /** 191 */ 192 public function getError($msg = false) 193 { 194 return $this->_base->getError($msg); 195 } 196}