AclSecurityHandlerInterface.php 3.9 KB

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