Add a single Permission to the Role's Permission Collection

@param trans
@param role
@param perm
@param type
@param action
@return
963163
public Result<Void> addPerm(AuthzTrans trans, RoleDAO.Data role, PermDAO.Data perm) {
		// Note: Prepared Statements for Collection updates aren't supported
		String pencode = perm.encode();
		try {
			getSession(trans).execute(UPDATE_SP + TABLE + " SET perms = perms + {'" + 
				pencode + "'} WHERE " +
				"ns = '" + role.ns + "' AND name = '" + role.name + "';");
		} catch (DriverException | APIException | IOException e) {
			reportPerhapsReset(trans,e);
			return Result.err(Result.ERR_Backend, CassAccess.ERR_ACCESS_MSG);
		}

		wasModified(trans, CRUD.update, role, "Added permission " + pencode + " to role " + role.fullName());
		return Result.ok();
	}
1157226
@Override
	public boolean addPermission(Permission permission)
	{
		if(permissions.contains(permission))
			return false;
		
		return this.permissions.add(permission);
	}
50756
public Permission createPermission(final String name, final String description) {
        pm.currentTransaction().begin();
        final Permission permission = new Permission();
        permission.setName(name);
        permission.setDescription(description);
        pm.makePersistent(permission);
        pm.currentTransaction().commit();
        return getObjectById(Permission.class, permission.getId());
    }
664016
@Override
    public java.util.concurrent.Future<AddPermissionResult> addPermissionAsync(String topicArn, String label, java.util.List<String> aWSAccountIds,
            java.util.List<String> actionNames, com.amazonaws.handlers.AsyncHandler<AddPermissionRequest, AddPermissionResult> asyncHandler) {

        return addPermissionAsync(
                new AddPermissionRequest().withTopicArn(topicArn).withLabel(label).withAWSAccountIds(aWSAccountIds).withActionNames(actionNames), asyncHandler);
    }
1207160
@Override
	public void addPermissions(Collection<Permission> aPermssions)
	{
		if (aPermssions == null)
			throw new IllegalArgumentException(
			"aPermssions required in SecurityAccessControl");

		// SecurityPermission element = null;
		for (Iterator<Permission> i = aPermssions.iterator(); i.hasNext();)
		{
			addPermission((SecurityPermission) i.next());
		}
	}
1279472
private void moveRoles(AuthzTrans trans, NsDAO.Data parent,
			StringBuilder sb, Result<List<RoleDAO.Data>> rrdc) {

		Result<Void> rv;
		Result<RoleDAO.Data> rd;

		if (rrdc.isOKhasData()) {
			for (RoleDAO.Data rdd : rrdc.value) {
				String delP2 = rdd.name;
				if ("admin".equals(delP2) || "owner".equals(delP2)) {
				    continue;
				}
				// Remove old Role from Perms, save them off
				List<PermDAO.Data> lpdd = new ArrayList<PermDAO.Data>();
				for(String p : rdd.perms(false)) {
					Result<PermDAO.Data> rpdd = PermDAO.Data.decode(trans,q,p);
					if(rpdd.isOKhasData()) {
						PermDAO.Data pdd = rpdd.value;
						lpdd.add(pdd);
						q.permDAO.delRole(trans, pdd, rdd);
					} else{
						trans.error().log(rpdd.errorString());
					}
				}
				
				// Save off Old keys
				String delP1 = rdd.ns;

				NsSplit nss = new NsSplit(parent, rdd.fullName());
				rdd.ns = nss.ns;
				rdd.name = nss.name;
				// Use direct Create/Delete, because switching namespaces
				if ((rd = q.roleDAO.create(trans, rdd)).isOK()) {
					// Put Role back into Perm, with correct info
					for(PermDAO.Data pdd : lpdd) {
						q.permDAO.addRole(trans, pdd, rdd);
					}

					rdd.ns = delP1;
					rdd.name = delP2;
					if ((rv = q.roleDAO.delete(trans, rdd, true)).notOK()) {
						sb.append(rv.details);
						sb.append('\n');
						// } else {
						// Need to invalidate directly, because we're switching
						// places in NS, not normal cache behavior
						// q.roleDAO.invalidate(trans,rdd);
					}
				} else {
					sb.append(rd.details);
					sb.append('\n');
				}
			}
		}
	}
207630
public Result<Void> extendUserRole(AuthzTrans trans, UserRoleDAO.Data urData, boolean checkForExist) {
		// Check if record still exists
		if (checkForExist && q.userRoleDAO.read(trans, urData).notOKorIsEmpty()) {
			return Result.err(Status.ERR_UserRoleNotFound,
					"User Role does not exist");
		}
		if (q.roleDAO.read(trans, urData.ns, urData.rname).notOKorIsEmpty()) {
			return Result.err(Status.ERR_RoleNotFound,
					"Role [%s.%s] does not exist", urData.ns,urData.rname);
		}
		// Special case for "Admin" roles. Issue brought forward with Prod
		// problem 9/26

		urData.expires = trans.org().expiration(null, Expiration.UserInRole).getTime(); // get
																				// Full
																				// time
																				// starting
																				// today
		return q.userRoleDAO.update(trans, urData);
	}
67089
private void addPrincipalPermissionsToForm(IPortletDefinition def, PortletDefinitionForm form) {
        final String portletTargetId = PermissionHelper.permissionTargetIdForPortletDefinition(def);

        final Set<JsonEntityBean> principalBeans = new HashSet<>();
        Map<String, IPermissionManager> permManagers = new HashMap<>();
        for (PortletPermissionsOnForm perm : PortletPermissionsOnForm.values()) {
            if (!permManagers.containsKey(perm.getOwner())) {
                permManagers.put(
                        perm.getOwner(),
                        authorizationService.newPermissionManager(perm.getOwner()));
            }
            final IPermissionManager pm = permManagers.get(perm.getOwner());
            /* Obtain the principals that have permission for the activity on this portlet */
            final IAuthorizationPrincipal[] principals =
                    pm.getAuthorizedPrincipals(perm.getActivity(), portletTargetId);

            for (IAuthorizationPrincipal principal : principals) {
                JsonEntityBean principalBean;

                // first assume this is a group
                final IEntityGroup group = GroupService.findGroup(principal.getKey());
                if (group != null) {
                    // principal is a group
                    principalBean = new JsonEntityBean(group, EntityEnum.GROUP);
                } else {
                    // not a group, so it must be a person
                    final IGroupMember member = authorizationService.getGroupMember(principal);
                    principalBean = new JsonEntityBean(member, EntityEnum.PERSON);
                    // set the name
                    final String name = groupListHelper.lookupEntityName(principalBean);
                    principalBean.setName(name);
                }

                principalBeans.add(principalBean);

                form.addPermission(principalBean.getTypeAndIdHash() + "_" + perm.getActivity());
            }
        }
        form.setPrincipals(principalBeans, false);
    }
906332
public Permission createPermissionObject(String permissionClass, String target, String action, String credential, String principalType, String principalName, String fileName) {
        Permission permission = null;
        if ((target != null) && (target.equals("ALL FILES") || target.contains("ALL FILES"))) {
            target = "<<ALL FILES>>";
        }
        try {
            if (permissionClass != null && !permissionClass.equalsIgnoreCase("null")) {
                // If this is a PrivateCredentialPermission
                if (permissionClass.equalsIgnoreCase("javax.security.auth.PrivateCredentialPermission")) {
                    if (target == null || target.equalsIgnoreCase("null")) {
                        // Create target from the credential and principal details
                        StringBuilder targetString = new StringBuilder();
                        targetString.append(credential);
                        targetString.append(" ");
                        targetString.append(principalType);
                        targetString.append(" \"");
                        targetString.append(principalName);
                        targetString.append("\"");

                        permission = (Permission) getPermissionClass(permissionClass).getConstructor(String.class, String.class).newInstance(targetString.toString(), "read");
                    } else {
                        permission = (Permission) getPermissionClass(permissionClass).getConstructor(String.class, String.class).newInstance(target, "read");
                    }
                } else {
                    if (action == null || action.equalsIgnoreCase("null")) {
                        if (target == null || target.equalsIgnoreCase("null")) {
                            permission = (Permission) getPermissionClass(permissionClass).newInstance();
                        } else {
                            permission = (Permission) getPermissionClass(permissionClass).getConstructor(String.class).newInstance(target);
                        }
                    } else {
                        permission = (Permission) getPermissionClass(permissionClass).getConstructor(String.class, String.class).newInstance(target, action);
                    }
                }
            }
        } catch (Exception e) {
            if (tc.isWarningEnabled()) {
                String rootCause = null;

                if (e.getCause() != null) {
                    rootCause = e.getCause().getClass().getName() + "[" + e.getCause().getMessage() + "]";
                } else if (e.getMessage() != null) {
                    rootCause = e.getClass().getName() + "[" + e.getMessage() + "]";
                }

                if (rootCause == null) {
                    rootCause = "unknown reasons";
                }
                if (e instanceof java.lang.ClassNotFoundException) {
                    Tr.warning(tc, PERMISSION_CLASSNOTFOUND, permissionClass, rootCause, fileName);
                } else {
                    Tr.warning(tc, INCORRECT_PERMISSION_CONFIGURATION, permissionClass, rootCause, fileName);
                }
            }
            if (e instanceof java.lang.ClassNotFoundException) {
                permission = new UnresolvedPermission(permissionClass, target, action, null);
            }
        }

        return permission;
    }
905584
public void addRole(Role role) {
        apiRoles.add(role);
        roles.add(role.getName());
        for (org.seedstack.seed.security.Permission permission : role.getPermissions()) {
            if (!role.getScopes().isEmpty()) {
                for (Scope scope : role.getScopes()) {
                    ScopePermission sp = new ScopePermission(permission.getPermission(), scope);
                    scopePermissions.add(sp);
                }
            } else {
                stringPermissions.add(permission.getPermission());
            }
        }
    }
1096025
public Result<List<Data>> readByRole(AuthzTrans trans, String role) {
		return psByRole.read(trans, R_TEXT + " by Role " + role, new Object[]{role});
	}
1341574
def update(self, permission):
        
        data = values.of({'Permission': serialize.map(permission, lambda e: e), })

        payload = self._version.update(
            'POST',
            self._uri,
            data=data,
        )

        return RoleInstance(
            self._version,
            payload,
            service_sid=self._solution['service_sid'],
            sid=self._solution['sid'],
        )
1187022
function addPermission(rbac, action, resource, cb) {
  rbac.getPermission(action, resource, (err, permission) => {
    if (err) {
      return cb(err);
    }

    if (!permission) {
      return cb(new Error('Permission not exists'));
    }

    if (indexOf(this.permissions, permission.name) !== -1) {
      return cb(new Error('Permission is already assigned'));
    }

    this.permissions.push(permission.name);
    return this.save((err2, user) => {
      if (err2) {
        return cb(err2);
      }

      if (!user) {
        return cb(new Error('User is undefined'));
      }

      return cb(null, true);
    });
  });

  return this;
}
1149794
@Override
	public void mergePermissions(AccessControl from, AccessControl to)
	{
		if (from == null || to == null)
			return;

		List<Permission> otherPermissions = from.getPermissions();

		if (otherPermissions == null)
			return;

		boolean changeNegative = from.isNegative() != to.isNegative();

		if (changeNegative)
			throw new SecurityException(
			"Cannot change or mixed different negative property for ACL from:" + from + " to ACL:" + to
			+ "  permission must be either all negative or all positive for a principal");

		Iterator<Permission> i = otherPermissions.iterator();

		while (i.hasNext())
		{

			to.addPermission(i.next());
		}
	}
143825
function addRolePrivilege (access, role, privilege) {
  if (role === true || access[privilege].role === true) {
    access[privilege] = {
      role: true
    }
    return
  }

  access[privilege].role = _.union(access[privilege].role, _.concat(role))
}
9866
public void addPermission(Permission permission) {
        if ((securityManager != null) && (permission != null)) {
            permissionList.add(permission);
        }
    }
671445
public function updatePermissions(Request $request, Role $role)
    {
        $this->authorize('manage_permissions', Role::class);
        $permissions = Permission::all();

        foreach ($permissions as $permission) {
            if (array_key_exists($permission->id, $request->all())) {
                $role->addPermission($permission);
            } else {
                $role->deletePermission($permission);
            }
        }

        return redirect()->route('laralum::roles.index')->with('success', __('laralum_roles::general.role_permissions_updated', ['id' => $role->id]));
    }