AclSecurityHandlerInterface.php 3.8 KB

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