Access only by subjects with Create/Update/Delete permission and by trusted
    infrastructure (CNs).
186584
def assert_create_update_delete_permission(request):
    """"""
    if not has_create_update_delete_permission(request):
        raise d1_common.types.exceptions.NotAuthorized(
            0,
            'Access allowed only for subjects with Create/Update/Delete '
            'permission. active_subjects="{}"'.format(format_active_subjects(request)),
        )
1088631
def CheckPermissions(self, username, subject):
    """"""

    if subject in self.authorized_users:
      return ((username in self.authorized_users[subject]) or
              self.group_access_manager.MemberOfAuthorizedGroup(
                  username, subject))

    # In case the subject is not found, the safest thing to do is to raise.
    # It's up to the users of this class to handle this exception and
    # grant/not grant permissions to the user in question.
    raise InvalidSubject("Subject %s was not found." % subject)
1055641
def clean(self, user=None):
        """"""
        doc = self._resource
        internal_fields = deepcopy(self.internal_fields)
        if user is None or not user.is_user(self.organisation_id):
            internal_fields.append('permissions')

        result = {k: v for k, v in doc.iteritems() if k not in internal_fields}

        return result
1351427
def revoke_access(self):
        """"""
        reading = PERMISSIONS['user']['execute'] + PERMISSIONS['group']['execute'] + PERMISSIONS['other']['execute']
        os.chmod(self.file_path, reading)
774269
def permission_required(perm, login_url=None):
    

    return user_passes_test(lambda u: u.has_perm(perm), login_url=login_url)
1309234
def perform_permissions_check(self, user, obj, perms):
        
        return self.request.forum_permission_handler.can_subscribe_to_topic(obj, user)
1170141
def permission_required_with_403(perm, login_url=None):
    
    return user_passes_test_with_403(lambda u: u.has_perm(perm), login_url=login_url)
1289201
protected Acl collectAcl(CmsObject cms, CmsResource resource, boolean onlyBasic) throws CmsException {

        AccessControlListImpl cmisAcl = new AccessControlListImpl();
        List<Ace> cmisAces = new ArrayList<Ace>();
        List<CmsAccessControlEntry> aces = cms.getAccessControlEntries(resource.getRootPath(), true);
        for (CmsAccessControlEntry ace : aces) {
            boolean isDirect = ace.getResource().equals(resource.getResourceId());
            CmsUUID principalId = ace.getPrincipal();
            String principalName = getAcePrincipalName(cms, principalId);
            AccessControlEntryImpl cmisAce = new AccessControlEntryImpl();
            AccessControlPrincipalDataImpl cmisPrincipal = new AccessControlPrincipalDataImpl();
            cmisPrincipal.setId(principalName);
            cmisAce.setPrincipal(cmisPrincipal);
            cmisAce.setPermissions(onlyBasic ? getCmisPermissions(ace) : getNativePermissions(ace));
            cmisAce.setDirect(isDirect);
            cmisAces.add(cmisAce);
        }
        cmisAcl.setAces(cmisAces);
        cmisAcl.setExact(Boolean.FALSE);
        return cmisAcl;
    }
380689
def perform_permissions_check(self, user, obj, perms):
        
        return self.request.forum_permission_handler.can_move_topics(obj, user)
980510
def perform_permissions_check(self, user, obj, perms):
        
        return self.request.forum_permission_handler.can_edit_post(obj, user)
177073
def access_storage_rm(name, yes, **kwargs):
    
    if name is None:
        if not yes:
            click.confirm('Are you sure you want to remove all ACL?', abort=True)

    ctx = Context(**kwargs)
    ctx.execute_action('access:storage:rm', **{
        'storage': ctx.repo.create_secure_service('storage'),
        'name': name,
    })
1037269
public Map<String, Map<String, List<String>>> resourcePermissions(String subjectid) {
		return getEntity(invokeGet(Utils.formatMessage("_permissions/{0}", subjectid), null), Map.class);
	}
887814
def global_permission_set(self):
        ''''''
        only_admins_create_admins = Or(
            AllowAdmin,
            And(
                ObjAttrTrue(
                    lambda r, _: r.data.get('admin') is not True),
                Or(
                    AllowPermission('org:admin')
                )
            )
        )

        return And(
            AllowOnlyAuthenticated,
            Or(
                Not(AllowCreate),
                only_admins_create_admins
            )
        )
384687
@Override
    public void removePermissions(IPermission[] permissions) throws AuthorizationException {
        if (permissions.length > 0) {
            getPermissionStore().delete(permissions);
            if (this.cachePermissions) {
                removeFromPermissionsCache(permissions);
            }
        }
    }
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)
1335229
def CheckDataStoreAccess(self, token, subjects, requested_access="r"):
    """"""
    if any(not x for x in subjects):
      raise ValueError("Subjects list can't contain empty URNs.")
    subjects = list(map(rdfvalue.RDFURN, subjects))

    return (ValidateAccessAndSubjects(requested_access, subjects) and
            ValidateToken(token, subjects) and
            (token.supervisor or
             self._CheckAccessWithHelpers(token, subjects, requested_access)))
1001854
def cli(ctx, user, organism, administrate=False, write=False, export=False, read=False):
    
    return ctx.gi.users.update_organism_permissions(user, organism, administrate=administrate, write=write, export=export, read=read)