AclSecurityHandlerInterface.php 3.7 KB

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