Add rights to ACL for specified entity (collection, path, etc.).

    Creates if necessary.
760423
def access_grant(tp, name, cid, uid, perm, **kwargs):
    
    ctx = Context(**kwargs)
    ctx.execute_action('access:edit:grant', **{
        'unicat': ctx.repo.create_secure_service('unicat'),
        'tp': tp,
        'name': name,
        'cids': cid,
        'uids': uid,
        'perm': perm,
    })
886245
def insert_default_acl
      self.class.default_acl.each do |acl|
        unless rights[acl[:acl]]
          Puppet.info _("Inserting default '%{acl}' (auth %{auth}) ACL") % { acl: acl[:acl], auth: acl[:authenticated] }
          mk_acl(acl)
        end
      end
      # queue an empty (ie deny all) right for every other path
      # actually this is not strictly necessary as the rights system
      # denies not explicitly allowed paths
      unless rights["/"]
        rights.newright("/").restrict_authenticated(:any)
      end
    end
1306586
function templ_rights($attrib)
    {
        // Get supported rights
        $supported = $this->rights_supported();

        // give plugins the opportunity to adjust this list
        $data = $this->rc->plugins->exec_hook('acl_rights_supported',
            array('rights' => $supported, 'folder' => $this->mbox, 'labels' => array()));
        $supported = $data['rights'];

        // depending on server capability either use 'te' or 'd' for deleting msgs
        $deleteright = implode(array_intersect(str_split('ted'), $supported));

        $out = '';
        $ul  = '';
        $input = new html_checkbox();

        // Advanced rights
        $attrib['id'] = 'advancedrights';
        foreach ($supported as $key => $val) {
            $id = "acl$val";
            $ul .= html::tag('li', null,
                $input->show('', array(
                    'name' => "acl[$val]", 'value' => $val, 'id' => $id))
                . html::label(array('for' => $id, 'title' => $this->gettext('longacl'.$val)),
                    $this->gettext('acl'.$val)));
        }

        $out = html::tag('ul', $attrib, $ul, html::$common_attrib);

        // Simple rights
        $ul = '';
        $attrib['id'] = 'simplerights';
        $items = array(
            'read' => 'lrs',
            'write' => 'wi',
            'delete' => $deleteright,
            'other' => preg_replace('/[lrswi'.$deleteright.']/', '', implode($supported)),
        );

        // give plugins the opportunity to adjust this list
        $data = $this->rc->plugins->exec_hook('acl_rights_simple',
            array('rights' => $items, 'folder' => $this->mbox, 'labels' => array(), 'titles' => array()));

        foreach ($data['rights'] as $key => $val) {
            $id = "acl$key";
            $ul .= html::tag('li', null,
                $input->show('', array(
                    'name' => "acl[$val]", 'value' => $val, 'id' => $id))
                . html::label(array('for' => $id, 'title' => $data['titles'][$key] ?: $this->gettext('longacl'.$key)),
                    $data['labels'][$key] ?: $this->gettext('acl'.$key)));
        }

        $out .= "\n" . html::tag('ul', $attrib, $ul, html::$common_attrib);

        $this->rc->output->set_env('acl_items', $data['rights']);

        return $out;
    }
1112769
def authorize(self):
        '''
        
        '''
        with salt.utils.files.fopen(self.path, 'w+') as fp_:
            fp_.write(str(int(time.time())))  # future lint: disable=blacklisted-function
        return True
97205
function assignPermissions (done) {
  async.map(defaults.permissions, function (pair, callback) {
    Role.addScopes(pair[0], pair[1], function (err, result) {
      callback(err, result)
    })
  }, function (err, results) {
    done(err, results)
  })
}
23526
public void add(Group group, AccessLevel accessLevel) {
        getAccessList().add(new Access(group, accessLevel));
    }
1282590
def set_object_acl(self, obj):
        
        if not obj._acl:
            from nefertari_guards import engine as guards_engine
            acl = self._factory(self.request).generate_item_acl(obj)
            obj._acl = guards_engine.ACLField.stringify_acl(acl)
141799
public void addPermissions(String identity, String[] perm) throws RepositoryException
   {
      for (String p : perm)
      {
         accessList.add(new AccessControlEntry(identity, p));
      }
   }
100250
protected function addPermissions(Node $node, &$doc)
    {
        if (!is_null($this->aclProvider)) {
            $roles = $this->getAclPermissions($node);
        } else {
            // Fallback when no ACL available / assume everything is accessible...
            $roles = array('IS_AUTHENTICATED_ANONYMOUSLY');
        }
        $doc['view_roles'] = $roles;
    }
1017555
protected function addAssignmentsToSu() : void
    {
        $roleSu = $this->authManager->getRole(Rbac::R_SU);
        $this->addRolesToSU($roleSu);
        $this->addPermissionsToSU($roleSu);
    }
404640
public void addPermissions(String rawData) throws RepositoryException
   {
      StringTokenizer listTokenizer = new StringTokenizer(rawData, AccessControlList.DELIMITER);
      if (listTokenizer.countTokens() < 1)
         throw new RepositoryException("AccessControlList " + rawData + " is empty or have a bad format");

      while (listTokenizer.hasMoreTokens())
      {
         String entry = listTokenizer.nextToken();
         try
         {
            accessList.add(AccessControlEntry.parse(entry));
         }
         catch (IllegalArgumentException e)
         {
            throw new RepositoryException("AccessControlEntry " + entry + " is empty or have a bad format", e);
         }
      }
   }
808306
private function addObjectAcl($object, UserSecurityIdentity $securityIdentity, array $rights)
    {
        $objectIdentity = ObjectIdentity::fromDomainObject($object);
        $this->addAcl($objectIdentity, $securityIdentity, $rights);
    }
358733
def create(value, options = {})
      custom_params = use_cas(@options)
      @raw = send_put_request(@conn, ['/v1/acl/create'], options, value, custom_params)
      parse_body
    end
288975
public String addLock(Session session, String path) throws LockException
   {

      String repoPath = session.getRepository().hashCode() + "/" + session.getWorkspace().getName() + "/" + path;

      if (!nullResourceLocks.containsKey(repoPath))
      {
         String newLockToken = IdGenerator.generate();
         session.addLockToken(newLockToken);
         nullResourceLocks.put(repoPath, newLockToken);
         return newLockToken;
      }

      // check if lock owned by this session
      String currentToken = nullResourceLocks.get(repoPath);
      for (String t : session.getLockTokens())
      {
         if (t.equals(currentToken))
            return t;
      }
      throw new LockException("Resource already locked " + repoPath);
   }
1219309
protected void updateAuthorizationBasedOnCacheEntries(AuthorizationEntity authorization, String userId, String groupId,
                                                        Resource resource, String resourceId) {
    DbEntityManager dbManager = Context.getCommandContext().getDbEntityManager();
    List<AuthorizationEntity> list = dbManager.getCachedEntitiesByType(AuthorizationEntity.class);
    for (AuthorizationEntity authEntity : list) {
      boolean hasSameAuthRights = hasEntitySameAuthorizationRights(authEntity, userId, groupId, resource, resourceId);
      if (hasSameAuthRights) {
        int previousPermissions = authEntity.getPermissions();
        authorization.setPermissions(previousPermissions);
        dbManager.getDbEntityCache().remove(authEntity);
        return;
      }
    }
  }
628574
private function addObjectRights($classname, array $config, UserSecurityIdentity $securityIdentity, $labelField = '_label')
    {
        $rights = $this->getActionsOnResources($config);
        foreach ((array) $rights as $resource => $actions) {
            if ('all' === $resource) {
                $this->addClassAcl($classname, $securityIdentity, $actions);
                $this->writeln(sprintf('    - Setting [%s] on all %s', implode(', ', $actions), $classname), OutputInterface::VERBOSITY_DEBUG);
                continue;
            }

            $object = $this->em->getRepository($classname)->findOneBy([$labelField => $resource]);
            if (null === $object) {
                $object = $this->em->find($classname, $resource);
            }

            if (null === $object) {
                $this->writeln(sprintf('    - Unknown %s `%s`', $classname, $resource), OutputInterface::VERBOSITY_DEBUG);
                continue;
            }

            $this->addObjectAcl($object, $securityIdentity, $actions);
            $this->writeln(sprintf('    - Setting [%s] on all %s `%s`', implode(', ', $actions), $classname, $resource), OutputInterface::VERBOSITY_DEBUG);
        }
    }
789735
public static ACL lambda(final BiFunction<Authentication, Permission, Boolean> impl) {
        return new ACL() {
            @Override
            public boolean hasPermission(Authentication a, Permission permission) {
                return impl.apply(a, permission);
            }
        };
    }