當前位置: 首頁>>代碼示例>>PHP>>正文


PHP AclInterface::isSidLoaded方法代碼示例

本文整理匯總了PHP中Symfony\Component\Security\Acl\Model\AclInterface::isSidLoaded方法的典型用法代碼示例。如果您正苦於以下問題:PHP AclInterface::isSidLoaded方法的具體用法?PHP AclInterface::isSidLoaded怎麽用?PHP AclInterface::isSidLoaded使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\Security\Acl\Model\AclInterface的用法示例。


在下文中一共展示了AclInterface::isSidLoaded方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: hasSufficientPermissions

 /**
  * Makes an authorization decision.
  *
  * The order of ACEs, and SIDs is significant; the order of permission masks
  * not so much. It is important to note that the more specific security
  * identities should be at the beginning of the SIDs array in order for this
  * strategy to produce intuitive authorization decisions.
  *
  * First, we will iterate over permissions, then over security identities.
  * For each combination of permission, and identity we will test the
  * available ACEs until we find one which is applicable.
  *
  * The first applicable ACE will make the ultimate decision for the
  * permission/identity combination. If it is granting, this method will return
  * true, if it is denying, the method will continue to check the next
  * permission/identity combination.
  *
  * This process is repeated until either a granting ACE is found, or no
  * permission/identity combinations are left. In the latter case, we will
  * call this method on the parent ACL if it exists, and isEntriesInheriting
  * is true. Otherwise, we will either throw an NoAceFoundException, or deny
  * access finally.
  *
  * @param AclInterface $acl
  * @param array $aces an array of ACE to check against
  * @param array $masks an array of permission masks
  * @param array $sids an array of SecurityIdentityInterface implementations
  * @param Boolean $administrativeMode true turns off audit logging
  * @return Boolean true, or false; either granting, or denying access respectively.
  */
 protected function hasSufficientPermissions(AclInterface $acl, array $aces, array $masks, array $sids, $administrativeMode)
 {
     $firstRejectedAce = null;
     foreach ($masks as $requiredMask) {
         foreach ($sids as $sid) {
             if (!$acl->isSidLoaded($sid)) {
                 throw new SidNotLoadedException(sprintf('The SID "%s" has not been loaded.', $sid));
             }
             foreach ($aces as $ace) {
                 if ($this->isAceApplicable($requiredMask, $sid, $ace)) {
                     if ($ace->isGranting()) {
                         if (!$administrativeMode && null !== $this->auditLogger) {
                             $this->auditLogger->logIfNeeded(true, $ace);
                         }
                         return true;
                     }
                     if (null === $firstRejectedAce) {
                         $firstRejectedAce = $ace;
                     }
                     break 2;
                 }
             }
         }
     }
     if (null !== $firstRejectedAce) {
         if (!$administrativeMode && null !== $this->auditLogger) {
             $this->auditLogger->logIfNeeded(false, $firstRejectedAce);
         }
         return false;
     }
     throw new NoAceFoundException('No applicable ACE was found.');
 }
開發者ID:notbrain,項目名稱:symfony,代碼行數:62,代碼來源:PermissionGrantingStrategy.php


注:本文中的Symfony\Component\Security\Acl\Model\AclInterface::isSidLoaded方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。