src/wcmf/lib/security/impl/AbstractPermissionManager.php
protected function matchRoles($resource, $permissions, $login) {
    if (self::$logger->isDebugEnabled()) {
      self::$logger->debug("Matching roles for ".$login);
    }
    $user = $this->principalFactory->getUser($login, true);
    if ($user != null) {
      foreach (['allow' => true, 'deny' => false] as $key => $result) {
        if (isset($permissions[$key])) {
          foreach ($permissions[$key] as $role) {
            if ($this->matchRole($user, $role, $resource)) {
              if (self::$logger->isDebugEnabled()) {
                self::$logger->debug($key." because of role ".$role);
              }
              return $result;
            }
          }
        }
      }
    }
    if (self::$logger->isDebugEnabled()) {
      self::$logger->debug("Check default ".$permissions['default']);
    }
    return (isset($permissions['default']) ? $permissions['default'] : false);
  }
protected function matchRoles($resource, $permissions, $login) {
    if (self::$logger->isDebugEnabled()) {
      self::$logger->debug("Matching roles for ".$login);
    }
    $user = $this->principalFactory->getUser($login, true);
    if ($user != null) {
      foreach (['allow' => true, 'deny' => false] as $key => $result) {
        if (isset($permissions[$key])) {
          foreach ($permissions[$key] as $role) {
            if ($this->matchRole($user, $role, $resource)) {
              if (self::$logger->isDebugEnabled()) {
                self::$logger->debug($key." because of role ".$role);
              }
              return $result;
            }
          }
        }
      }
    }
    if (self::$logger->isDebugEnabled()) {
      self::$logger->debug("Check default ".$permissions['default']);
    }
    return (isset($permissions['default']) ? $permissions['default'] : false);
  }
protected function matchRoles ( $ resource , $ permissions , $ login ) { if ( self :: $ logger -> isDebugEnabled ( ) ) { self :: $ logger -> debug ( "Matching roles for " . $ login ) ; } $ user = $ this -> principalFactory -> getUser ( $ login , true ) ; if ( $ user != null ) { foreach ( [ 'allow' => true , 'deny' => false ] as $ key => $ result ) { if ( isset ( $ permissions [ $ key ] ) ) { foreach ( $ permissions [ $ key ] as $ role ) { if ( $ this -> matchRole ( $ user , $ role , $ resource ) ) { if ( self :: $ logger -> isDebugEnabled ( ) ) { self :: $ logger -> debug ( $ key . " because of role " . $ role ) ; } return $ result ; } } } } } if ( self :: $ logger -> isDebugEnabled ( ) ) { self :: $ logger -> debug ( "Check default " . $ permissions [ 'default' ] ) ; } return ( isset ( $ permissions [ 'default' ] ) ? $ permissions [ 'default' ] : false ) ; }
Matches the roles of the user and the roles in the given permissions
@param $resource The resource string to authorize.
@param $permissions An array containing permissions as an associative array
with the keys 'default', 'allow', 'deny', where 'allow', 'deny' are arrays
itself holding roles and 'default' is a boolean value derived from the
wildcard policy (+* or -*). 'allow' overwrites 'deny' overwrites 'default'
@param $login the login of the user to match the roles for
@return Boolean whether the user is authorized according to the permissions
Matches the roles of the user and the roles in the given permissions