FirewallConfig.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Bundle\SecurityBundle\Security;
  11. /**
  12. * @author Robin Chalas <robin.chalas@gmail.com>
  13. */
  14. final class FirewallConfig
  15. {
  16. private $name;
  17. private $userChecker;
  18. private $requestMatcher;
  19. private $securityEnabled;
  20. private $stateless;
  21. private $provider;
  22. private $context;
  23. private $entryPoint;
  24. private $accessDeniedHandler;
  25. private $accessDeniedUrl;
  26. private $listeners;
  27. private $switchUser;
  28. public function __construct(string $name, string $userChecker, string $requestMatcher = null, bool $securityEnabled = true, bool $stateless = false, string $provider = null, string $context = null, string $entryPoint = null, string $accessDeniedHandler = null, string $accessDeniedUrl = null, array $listeners = [], $switchUser = null)
  29. {
  30. $this->name = $name;
  31. $this->userChecker = $userChecker;
  32. $this->requestMatcher = $requestMatcher;
  33. $this->securityEnabled = $securityEnabled;
  34. $this->stateless = $stateless;
  35. $this->provider = $provider;
  36. $this->context = $context;
  37. $this->entryPoint = $entryPoint;
  38. $this->accessDeniedHandler = $accessDeniedHandler;
  39. $this->accessDeniedUrl = $accessDeniedUrl;
  40. $this->listeners = $listeners;
  41. $this->switchUser = $switchUser;
  42. }
  43. public function getName(): string
  44. {
  45. return $this->name;
  46. }
  47. /**
  48. * @return string|null The request matcher service id or null if neither the request matcher, pattern or host
  49. * options were provided
  50. */
  51. public function getRequestMatcher(): ?string
  52. {
  53. return $this->requestMatcher;
  54. }
  55. public function isSecurityEnabled(): bool
  56. {
  57. return $this->securityEnabled;
  58. }
  59. public function allowsAnonymous(): bool
  60. {
  61. return \in_array('anonymous', $this->listeners, true);
  62. }
  63. public function isStateless(): bool
  64. {
  65. return $this->stateless;
  66. }
  67. public function getProvider(): ?string
  68. {
  69. return $this->provider;
  70. }
  71. /**
  72. * @return string|null The context key (will be null if the firewall is stateless)
  73. */
  74. public function getContext(): ?string
  75. {
  76. return $this->context;
  77. }
  78. public function getEntryPoint(): ?string
  79. {
  80. return $this->entryPoint;
  81. }
  82. public function getUserChecker(): string
  83. {
  84. return $this->userChecker;
  85. }
  86. public function getAccessDeniedHandler(): ?string
  87. {
  88. return $this->accessDeniedHandler;
  89. }
  90. public function getAccessDeniedUrl(): ?string
  91. {
  92. return $this->accessDeniedUrl;
  93. }
  94. public function getListeners(): array
  95. {
  96. return $this->listeners;
  97. }
  98. public function getSwitchUser(): ?array
  99. {
  100. return $this->switchUser;
  101. }
  102. }