[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /* 4 * This file is part of the Symfony package. 5 * 6 * (c) Fabien Potencier <[email protected]> 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12 namespace Symfony\Component\Ldap\Security; 13 14 use Symfony\Component\Ldap\Entry; 15 use Symfony\Component\Security\Core\User\EquatableInterface; 16 use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface; 17 use Symfony\Component\Security\Core\User\UserInterface; 18 19 /** 20 * @author Robin Chalas <[email protected]> 21 * 22 * @final 23 */ 24 class LdapUser implements UserInterface, PasswordAuthenticatedUserInterface, EquatableInterface 25 { 26 private $entry; 27 private $username; 28 private $password; 29 private $roles; 30 private $extraFields; 31 32 public function __construct(Entry $entry, string $username, ?string $password, array $roles = [], array $extraFields = []) 33 { 34 if (!$username) { 35 throw new \InvalidArgumentException('The username cannot be empty.'); 36 } 37 38 $this->entry = $entry; 39 $this->username = $username; 40 $this->password = $password; 41 $this->roles = $roles; 42 $this->extraFields = $extraFields; 43 } 44 45 public function getEntry(): Entry 46 { 47 return $this->entry; 48 } 49 50 /** 51 * {@inheritdoc} 52 */ 53 public function getRoles(): array 54 { 55 return $this->roles; 56 } 57 58 /** 59 * {@inheritdoc} 60 */ 61 public function getPassword(): ?string 62 { 63 return $this->password; 64 } 65 66 /** 67 * {@inheritdoc} 68 */ 69 public function getSalt(): ?string 70 { 71 return null; 72 } 73 74 /** 75 * {@inheritdoc} 76 */ 77 public function getUsername(): string 78 { 79 trigger_deprecation('symfony/ldap', '5.3', 'Method "%s()" is deprecated and will be removed in 6.0, use getUserIdentifier() instead.', __METHOD__); 80 81 return $this->username; 82 } 83 84 public function getUserIdentifier(): string 85 { 86 return $this->username; 87 } 88 89 /** 90 * {@inheritdoc} 91 */ 92 public function eraseCredentials() 93 { 94 $this->password = null; 95 } 96 97 public function getExtraFields(): array 98 { 99 return $this->extraFields; 100 } 101 102 public function setPassword(string $password) 103 { 104 $this->password = $password; 105 } 106 107 /** 108 * {@inheritdoc} 109 */ 110 public function isEqualTo(UserInterface $user): bool 111 { 112 if (!$user instanceof self) { 113 return false; 114 } 115 116 if ($this->getPassword() !== $user->getPassword()) { 117 return false; 118 } 119 120 if ($this->getSalt() !== $user->getSalt()) { 121 return false; 122 } 123 124 if ($this->getUserIdentifier() !== $user->getUserIdentifier()) { 125 return false; 126 } 127 128 return true; 129 } 130 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |