public void CheckPermission(PermissionCategory perm, PERMISSION_MASK mask, string deniedMessage) { if (!HasPermission(perm, mask)) { throw new NoPermissionException(perm, mask, deniedMessage); } }
public UpdateBiotaPermissions(int groupId, int userId, PERMISSION_MASK mask, Taxon taxon) { this.GroupID = groupId; this.UserID = userId; this.Mask = mask; this.Taxon = taxon; }
public bool HasBiotaPermission(int taxonId, PERMISSION_MASK mask) { if (taxonId == 0) { return(true); } // system administrator has full rights to all. if (IsSysAdmin) { return(true); } // Ensure the permissions set at the user group level take precendence to the individual taxon based permissions. if (mask != PERMISSION_MASK.OWNER) { if (!HasPermission(PermissionCategory.SPIN_TAXON, mask)) { return(false); } } if (taxonId < 0) { // new items are automatically approved! return(true); } var service = new SupportService(this); //if (service.HasBiotaPermission(taxonId, mask)) { // return true; //} var perms = service.GetBiotaPermissions(Username, taxonId); if (perms == null) { return(false); } else { if (perms.PermMask1 == 0) { // If there are owners of this taxa then the user needs permissions... return(perms.NumOwners == 0); } else { return((perms.PermMask1 & (int)mask) != 0); } } }
void UpdatePermissions(object sender, RoutedEventArgs e) { if (_setting) { return; } var entity = lvw.SelectedItem as UserEntityViewModel; if (entity == null) { return; } PERMISSION_MASK mask = 0; if (optReadOnly.IsChecked.ValueOrFalse()) { mask = PERMISSION_MASK.READ; } else if (optOwnership.IsChecked.ValueOrFalse()) { mask = PERMISSION_MASK.OWNER; } else if (optModify.IsChecked.ValueOrFalse()) { mask = PERMISSION_MASK.WRITE; if (chkDelete.IsChecked.ValueOrFalse()) { mask |= PERMISSION_MASK.DELETE; } if (chkInsert.IsChecked.ValueOrFalse()) { mask |= PERMISSION_MASK.INSERT; } if (chkUpdate.IsChecked.ValueOrFalse()) { mask |= PERMISSION_MASK.UPDATE; } } try { RegisterUniquePendingChange(new UpdateBiotaPermissions(entity.GroupId, entity.UserId, mask, Taxon.Taxon)); // If we get here we have permissions. We need to update our backing model... Debug.AssertNotNull(entity.Permission); entity.Permission.PermMask1 = (int)mask; } catch (NoPermissionException ex) { entity.Permission = null; // force a reload of the entitys permissions for the current Taxa DisplayMaskForEntity(entity); throw ex; } }
public bool HasPermission(PermissionCategory perm, PERMISSION_MASK mask) { if (IsSysAdmin) { return(true); } if (_permissions != null && _permissions.ContainsKey(perm)) { var val = _permissions[perm]; return((val.Mask1 & (int)mask) != 0); } return(false); }
public UpdateBiotaPermissions(int groupId, int userId, PERMISSION_MASK mask, Taxon taxon) { this.GroupID = groupId; this.UserID = userId; this.Mask = mask; this.Taxon = taxon; }
public bool HasPermission(PermissionCategory perm, PERMISSION_MASK mask) { if (IsSysAdmin) { return true; } if (_permissions != null && _permissions.ContainsKey(perm)) { var val = _permissions[perm]; return (val.Mask1 & (int)mask) != 0; } return false; }
public NoPermissionException(PermissionCategory permissionCategory, PERMISSION_MASK mask, string deniedMessage = "") : base(String.Format("You do not have permission to perform this operation: {0} :: {1}", permissionCategory.ToString(), mask.ToString())) { this.PermissionCategory = permissionCategory; this.RequestedMask = mask; this.DeniedMessage = deniedMessage; }
public void CheckPermission(PermissionCategory perm, PERMISSION_MASK mask, string deniedMessage) { if (!HasPermission(perm, mask)) { throw new NoPermissionException(perm, mask, deniedMessage); } }
public bool HasBiotaPermission(int taxonId, PERMISSION_MASK mask) { if (taxonId == 0) { return true; } // system administrator has full rights to all. if (IsSysAdmin) { return true; } // Ensure the permissions set at the user group level take precendence to the individual taxon based permissions. if (mask != PERMISSION_MASK.OWNER) { if (!HasPermission(PermissionCategory.SPIN_TAXON, mask)) { return false; } } if (taxonId < 0) { // new items are automatically approved! return true; } var service = new SupportService(this); //if (service.HasBiotaPermission(taxonId, mask)) { // return true; //} var perms = service.GetBiotaPermissions(Username, taxonId); if (perms == null) { return false; } else { if (perms.PermMask1 == 0) { // If there are owners of this taxa then the user needs permissions... return perms.NumOwners == 0; } else { return (perms.PermMask1 & (int) mask) != 0; } } }
private bool CheckPermission(PERMISSION_MASK mask, TaxonViewModel target = null) { // system administrator has full rights to all. if (User.IsSysAdmin) { return true; } // Ensure the permissions set at the user group level take precendence to the indivual taxon based permissions. try { if (mask != PERMISSION_MASK.OWNER) { if (!User.HasPermission(PermissionCategory.SPIN_TAXON, mask)) { return false; } } if (target != null) { if (target.TaxaID.Value <= 0) { // new items are automatically approved! return true; } if (!User.HasBiotaPermission(target.TaxaID.Value, mask)) { throw new NoPermissionException(PermissionCategory.SPIN_TAXON, mask, "You do not have permission to move this item!"); } } return true; } catch (NoPermissionException npex) { string txt = npex.Message; if (!string.IsNullOrEmpty(npex.DeniedMessage)) { txt = npex.DeniedMessage; } string caption = string.Format("Permission Error [{0} {1}]", npex.PermissionCategory, npex.RequestedMask); MessageBox.Show(txt, caption, MessageBoxButton.OK, MessageBoxImage.Exclamation); return false; } }
public NoPermissionException(PermissionCategory permissionCategory, PERMISSION_MASK mask, string deniedMessage = "") : base(String.Format("You do not have permission to perform this operation: {0} :: {1}", permissionCategory.ToString(), mask.ToString())) { this.PermissionCategory = permissionCategory; this.RequestedMask = mask; this.DeniedMessage = deniedMessage; }
protected RequiredPermission(PERMISSION_MASK mask) { this.Mask = mask; }
public BasicRequiredPermission(PermissionCategory category, PERMISSION_MASK mask) : base(mask) { this.Category = category; }
public PermissionBuilder AddBiota(int taxonId, PERMISSION_MASK mask) { _required.Add(new BiotaRequiredPermission(taxonId, mask)); return(this); }
public PermissionBuilder Add(PermissionCategory category, PERMISSION_MASK mask) { _required.Add(new BasicRequiredPermission(category, mask)); return(this); }
public BiotaRequiredPermission(int taxonId, PERMISSION_MASK mask) : base(mask) { this.TaxonID = taxonId; }