AclSecurityHandlerInterface.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. * @author Thomas Rabaix <thomas.rabaix@sonata-project.org>
  16. */
  17. interface AclSecurityHandlerInterface extends SecurityHandlerInterface
  18. {
  19. /**
  20. * Set the permissions not related to an object instance and also to be available when objects do not exist.
  21. *
  22. * @abstract
  23. *
  24. * @param array $permissions
  25. */
  26. public function setAdminPermissions(array $permissions);
  27. /**
  28. * Return the permissions not related to an object instance and also to be available when objects do not exist.
  29. *
  30. * @abstract
  31. *
  32. * @return array
  33. */
  34. public function getAdminPermissions();
  35. /**
  36. * Set the permissions related to an object instance.
  37. *
  38. * @abstract
  39. *
  40. * @param array $permissions
  41. */
  42. public function setObjectPermissions(array $permissions);
  43. /**
  44. * Return the permissions related to an object instance.
  45. *
  46. * @abstract
  47. *
  48. * @return array
  49. */
  50. public function getObjectPermissions();
  51. /**
  52. * Get the ACL for the passed object identity.
  53. *
  54. * @abstract
  55. *
  56. * @param ObjectIdentityInterface $objectIdentity
  57. *
  58. * @return null|AclInterface or NULL if not found
  59. */
  60. public function getObjectAcl(ObjectIdentityInterface $objectIdentity);
  61. /**
  62. * Find the ACLs for the passed object identities.
  63. *
  64. * @abstract
  65. *
  66. * @param \Traversable $oids a collection of ObjectIdentityInterface implementations
  67. * @param array $sids an array of SecurityIdentityInterface implementations
  68. *
  69. * @throws \Exception
  70. *
  71. * @return \SplObjectStorage mapping the passed object identities to ACLs
  72. */
  73. public function findObjectAcls(\Traversable $oids, array $sids = array());
  74. /**
  75. * Add an object owner ACE to the object ACL.
  76. *
  77. * @abstract
  78. *
  79. * @param AclInterface $acl
  80. * @param UserSecurityIdentity $securityIdentity
  81. */
  82. public function addObjectOwner(AclInterface $acl, UserSecurityIdentity $securityIdentity = null);
  83. /**
  84. * Add the object class ACE's to the object ACL.
  85. *
  86. * @param AclInterface $acl
  87. * @param array $roleInformation
  88. */
  89. public function addObjectClassAces(AclInterface $acl, array $roleInformation = array());
  90. /**
  91. * Create an object ACL.
  92. *
  93. * @abstract
  94. *
  95. * @param ObjectIdentityInterface $objectIdentity
  96. *
  97. * @return AclInterface
  98. */
  99. public function createAcl(ObjectIdentityInterface $objectIdentity);
  100. /**
  101. * Update the ACL.
  102. *
  103. * @abstract
  104. *
  105. * @param AclInterface $acl
  106. */
  107. public function updateAcl(AclInterface $acl);
  108. /**
  109. * Delete the ACL.
  110. *
  111. * @abstract
  112. *
  113. * @param ObjectIdentityInterface $objectIdentity
  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. }