Entry.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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\Component\Security\Acl\Domain;
  11. use Symfony\Component\Security\Acl\Model\AclInterface;
  12. use Symfony\Component\Security\Acl\Model\AuditableEntryInterface;
  13. use Symfony\Component\Security\Acl\Model\SecurityIdentityInterface;
  14. /**
  15. * Auditable ACE implementation.
  16. *
  17. * @author Johannes M. Schmitt <schmittjoh@gmail.com>
  18. */
  19. class Entry implements AuditableEntryInterface
  20. {
  21. private $acl;
  22. private $mask;
  23. private $id;
  24. private $securityIdentity;
  25. private $strategy;
  26. private $auditFailure;
  27. private $auditSuccess;
  28. private $granting;
  29. /**
  30. * Constructor.
  31. *
  32. * @param int $id
  33. * @param AclInterface $acl
  34. * @param SecurityIdentityInterface $sid
  35. * @param string $strategy
  36. * @param int $mask
  37. * @param bool $granting
  38. * @param bool $auditFailure
  39. * @param bool $auditSuccess
  40. */
  41. public function __construct($id, AclInterface $acl, SecurityIdentityInterface $sid, $strategy, $mask, $granting, $auditFailure, $auditSuccess)
  42. {
  43. $this->id = $id;
  44. $this->acl = $acl;
  45. $this->securityIdentity = $sid;
  46. $this->strategy = $strategy;
  47. $this->mask = $mask;
  48. $this->granting = $granting;
  49. $this->auditFailure = $auditFailure;
  50. $this->auditSuccess = $auditSuccess;
  51. }
  52. /**
  53. * {@inheritdoc}
  54. */
  55. public function getAcl()
  56. {
  57. return $this->acl;
  58. }
  59. /**
  60. * {@inheritdoc}
  61. */
  62. public function getMask()
  63. {
  64. return $this->mask;
  65. }
  66. /**
  67. * {@inheritdoc}
  68. */
  69. public function getId()
  70. {
  71. return $this->id;
  72. }
  73. /**
  74. * {@inheritdoc}
  75. */
  76. public function getSecurityIdentity()
  77. {
  78. return $this->securityIdentity;
  79. }
  80. /**
  81. * {@inheritdoc}
  82. */
  83. public function getStrategy()
  84. {
  85. return $this->strategy;
  86. }
  87. /**
  88. * {@inheritdoc}
  89. */
  90. public function isAuditFailure()
  91. {
  92. return $this->auditFailure;
  93. }
  94. /**
  95. * {@inheritdoc}
  96. */
  97. public function isAuditSuccess()
  98. {
  99. return $this->auditSuccess;
  100. }
  101. /**
  102. * {@inheritdoc}
  103. */
  104. public function isGranting()
  105. {
  106. return $this->granting;
  107. }
  108. /**
  109. * Turns on/off auditing on permissions denials.
  110. *
  111. * Do never call this method directly. Use the respective methods on the
  112. * AclInterface instead.
  113. *
  114. * @param bool $boolean
  115. */
  116. public function setAuditFailure($boolean)
  117. {
  118. $this->auditFailure = $boolean;
  119. }
  120. /**
  121. * Turns on/off auditing on permission grants.
  122. *
  123. * Do never call this method directly. Use the respective methods on the
  124. * AclInterface instead.
  125. *
  126. * @param bool $boolean
  127. */
  128. public function setAuditSuccess($boolean)
  129. {
  130. $this->auditSuccess = $boolean;
  131. }
  132. /**
  133. * Sets the permission mask.
  134. *
  135. * Do never call this method directly. Use the respective methods on the
  136. * AclInterface instead.
  137. *
  138. * @param int $mask
  139. */
  140. public function setMask($mask)
  141. {
  142. $this->mask = $mask;
  143. }
  144. /**
  145. * Sets the mask comparison strategy.
  146. *
  147. * Do never call this method directly. Use the respective methods on the
  148. * AclInterface instead.
  149. *
  150. * @param string $strategy
  151. */
  152. public function setStrategy($strategy)
  153. {
  154. $this->strategy = $strategy;
  155. }
  156. /**
  157. * Implementation of \Serializable.
  158. *
  159. * @return string
  160. */
  161. public function serialize()
  162. {
  163. return serialize(array(
  164. $this->mask,
  165. $this->id,
  166. $this->securityIdentity,
  167. $this->strategy,
  168. $this->auditFailure,
  169. $this->auditSuccess,
  170. $this->granting,
  171. ));
  172. }
  173. /**
  174. * Implementation of \Serializable.
  175. *
  176. * @param string $serialized
  177. */
  178. public function unserialize($serialized)
  179. {
  180. list($this->mask,
  181. $this->id,
  182. $this->securityIdentity,
  183. $this->strategy,
  184. $this->auditFailure,
  185. $this->auditSuccess,
  186. $this->granting
  187. ) = unserialize($serialized);
  188. }
  189. }