AclSecurityHandlerInterface.php 3.9 KB

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