protected function getPermissionInstance($resource, $context, $action) {
    $query = new ObjectQuery($this->permissionType, __CLASS__.__METHOD__);
    $tpl = $query->getObjectTemplate($this->permissionType);
    $tpl->setValue('resource', Criteria::asValue('=', $resource));
    $tpl->setValue('context', Criteria::asValue('=', $context));
    $tpl->setValue('action', Criteria::asValue('=', $action));
    $permissions = $query->execute(BuildDepth::SINGLE);
    return (sizeof($permissions) > 0) ? $permissions[0] : null;
  }