AclSecurityHandlerInterface.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <?php
  2. /*
  3. * This file is part of the Sonata Project package.
  4. *
  5. * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  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 Sonata\AdminBundle\Security\Handler;
  11. use Symfony\Component\Security\Acl\Domain\UserSecurityIdentity;
  12. use Symfony\Component\Security\Acl\Model\AclInterface;
  13. use Symfony\Component\Security\Acl\Model\ObjectIdentityInterface;
  14. /**
  15. * Interface AclSecurityHandlerInterface.
  16. *
  17. * @author Thomas Rabaix <thomas.rabaix@sonata-project.org>
  18. */
  19. interface AclSecurityHandlerInterface extends SecurityHandlerInterface
  20. {
  21. /**
  22. * Set the permissions not related to an object instance and also to be available when objects do not exist.
  23. *
  24. * @abstract
  25. *
  26. * @param array $permissions
  27. */
  28. public function setAdminPermissions(array $permissions);
  29. /**
  30. * Return the permissions not related to an object instance and also to be available when objects do not exist.
  31. *
  32. * @abstract
  33. *
  34. * @return array
  35. */
  36. public function getAdminPermissions();
  37. /**
  38. * Set the permissions related to an object instance.
  39. *
  40. * @abstract
  41. *
  42. * @param array $permissions
  43. */
  44. public function setObjectPermissions(array $permissions);
  45. /**
  46. * Return the permissions related to an object instance.
  47. *
  48. * @abstract
  49. *
  50. * @return array
  51. */
  52. public function getObjectPermissions();
  53. /**
  54. * Get the ACL for the passed object identity.
  55. *
  56. * @abstract
  57. *
  58. * @param ObjectIdentityInterface $objectIdentity
  59. *
  60. * @return null|AclInterface or NULL if not found
  61. */
  62. public function getObjectAcl(ObjectIdentityInterface $objectIdentity);
  63. /**
  64. * Find the ACLs for the passed object identities.
  65. *
  66. * @abstract
  67. *
  68. * @param \Traversable $oids a collection of ObjectIdentityInterface implementations
  69. * @param array $sids an array of SecurityIdentityInterface implementations
  70. *
  71. * @throws \Exception
  72. *
  73. * @return \SplObjectStorage mapping the passed object identities to ACLs
  74. */
  75. public function findObjectAcls(\Traversable $oids, array $sids = array());
  76. /**
  77. * Add an object owner ACE to the object ACL.
  78. *
  79. * @abstract
  80. *
  81. * @param AclInterface $acl
  82. * @param UserSecurityIdentity $securityIdentity
  83. */
  84. public function addObjectOwner(AclInterface $acl, UserSecurityIdentity $securityIdentity = null);
  85. /**
  86. * Add the object class ACE's to the object ACL.
  87. *
  88. * @param AclInterface $acl
  89. * @param array $roleInformation
  90. */
  91. public function addObjectClassAces(AclInterface $acl, array $roleInformation = array());
  92. /**
  93. * Create an object ACL.
  94. *
  95. * @abstract
  96. *
  97. * @param ObjectIdentityInterface $objectIdentity
  98. *
  99. * @return AclInterface
  100. */
  101. public function createAcl(ObjectIdentityInterface $objectIdentity);
  102. /**
  103. * Update the ACL.
  104. *
  105. * @abstract
  106. *
  107. * @param AclInterface $acl
  108. */
  109. public function updateAcl(AclInterface $acl);
  110. /**
  111. * Delete the ACL.
  112. *
  113. * @abstract
  114. *
  115. * @param ObjectIdentityInterface $objectIdentity
  116. */
  117. public function deleteAcl(ObjectIdentityInterface $objectIdentity);
  118. /**
  119. * Helper method to find the index of a class ACE for a role.
  120. *
  121. * @param AclInterface $acl
  122. * @param string $role
  123. *
  124. * @return mixed index if found, FALSE if not found
  125. */
  126. public function findClassAceIndexByRole(AclInterface $acl, $role);
  127. /**
  128. * Helper method to find the index of a class ACE for a username.
  129. *
  130. * @param AclInterface $acl
  131. * @param string $username
  132. *
  133. * @return mixed index if found, FALSE if not found
  134. */
  135. public function findClassAceIndexByUsername(AclInterface $acl, $username);
  136. }