当前位置: 首页>>代码示例>>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;未经允许,请勿转载。