Entry.php 4.6 KB

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