/ Permissions ///
548157
public function canCreate($member) {
        if (!$this->owner->isCreatable()) {
            return false;
        }

        if (!$member) {
            $member = Member::currentUserID();
        }

        if ($member && is_numeric($member)) {
            $member = DataObject::get_by_id('Member', $member);
        }

        $cachedPermission = self::cache_permission_check('create', $member, $this->owner->ID);
        if (isset($cachedPermission)) {
            return $cachedPermission;
        }

        if ($member && Permission::checkMember($member, "ADMIN")) {
            return true;
        }

        $extended = $this->owner->extendedCan('canCreateLocations', $member);
        if ($extended !== null) {
            return $extended;
        }

        return false;
    }
399181
public function Permission() {
      if ($this->DeliveryMethod() == DELIVERY_METHOD_XHTML) {
         header("HTTP/1.0 401", TRUE, 401);
         $this->Render();
      } else
         $this->RenderException(PermissionException());
   }
468449
public void setUserPermission(String userName, List<Permission> permissions){
        getServiceDirectoryClient().setACL(new ACL(AuthScheme.DIRECTORY, userName, PermissionUtil.permissionList2Id(permissions)));
    }
1322673
function access(permission, account, callback) {
  // User #1 has all privileges:
  if (account.uid === 1) {
    callback(null, true);
    return;
  }

  // If permissions is already loaded, use them.
  if (account.permissions) {
    callback(null, account.permissions.indexOf(permission) > -1);
    return;
  }

  role_permissions(account.roles, function (err, permissions) {
    if (err) {
      callback(err);
      return;
    }

    callback(null, permissions.indexOf(permission) > -1);
  });
}
980510
def perform_permissions_check(self, user, obj, perms):
        
        return self.request.forum_permission_handler.can_edit_post(obj, user)
1153054
private void setRWPermissions(File f) {
    if (!f.setReadable(true, false) || !f.setWritable(true, false)) {
      LOG.info("Could not set permissions for file : "
          + f + " probably because user : " + System.getProperty("user.name")
          + " is not the owner");
    }
  }
588243
def set_content_permissions(self, user, obj, payload):
        """"""
        for entity in obj.entity_set.all():
            if user.has_perm('share_entity', entity):
                update_permission(entity, payload)

        # Data doesn't have "ADD" permission, so it has to be removed
        payload = remove_permission(payload, 'add')

        for data in obj.data.all():
            if user.has_perm('share_data', data):
                update_permission(data, payload)
466908
public boolean hasPermissionsById(String id, Permission... permissions) {
        return hasPermissionsById(id, Arrays.asList(permissions));
    }
1157871
def has_permission(user, permission_name):
    """"""
    if user and user.is_superuser:
        return True

    return permission_name in available_perm_names(user)
317087
def _permission_trees(permissions):
        """"""
        treecache = PermissionTreeCache()
        cached = treecache.get()
        if not cached:
            tree = PermissionTreeBuilder()
            for permission in permissions:
                tree.insert(permission)
            result = tree.serialize()
            treecache.set(result)
            return result
        return cached
822458
def permissions(self):
        """"""
        perms = set()
        for r in self.roles:
            perms = perms | set(r.permissions)
        return perms
1313028
def check_permissions(self, request):
        

        for permission in self.get_permissions():
            if not permission.has_permission(request, self):
                self.permission_denied(request, message=getattr(permission, 'message', None))
457686
function(permission, negative) {
            if (!negative) {
              negative = false;
            }
            if (permission !== null && !Array.isArray(permission)) {
              var p = (negative) ? this.permissions.exclude : this.permissions.include;
              p.push(permission);
            }
          }
1150122
protected boolean hasPermission(final String permission) {
        if (getPrincipal() == null) {
            return false;
        }
        try (AlpineQueryManager qm = new AlpineQueryManager()) {
            boolean hasPermission = false;
            if (getPrincipal() instanceof ApiKey) {
                hasPermission = qm.hasPermission((ApiKey)getPrincipal(), permission);
            } else if (getPrincipal() instanceof UserPrincipal) {
                hasPermission = qm.hasPermission((UserPrincipal)getPrincipal(), permission, true);
            }
            return hasPermission;
        }
    }
24743
protected function initPermissions()
    {
        if (isset($this->settings) && $this->settings->exists('permissions') && !self::$init_stages[$this->name]['permissions']) {

            $permissions = [
                'admin'
            ];

            if ($this->settings->exists('config')) {
                $permissions[] = 'config';
            }

            $permissions = array_merge($permissions, $this->settings->get('permissions'));

            $this->permissions = new Permissions();
            $this->permissions->set($permissions);

            // Set flat that permission init is done
            self::$init_stages[$this->name]['perms'] = true;
        }
    }
1313119
def perform_permissions_check(self, user, obj, perms):
        
        return self.request.forum_permission_handler.can_download_files(obj, user)
1272980
public static boolean hasPermission(final String permission) {
        final SecurityContext context = SecurityContextHolder.getContext();
        if (context != null) {
            final Authentication authentication = context.getAuthentication();
            if (authentication != null) {
                for (final GrantedAuthority authority : authentication.getAuthorities()) {
                    if (authority.getAuthority().equals(permission)) {
                        return true;
                    }
                }
            }
        }
        return false;
    }