UserSecurityToken.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. using System.Linq;
  2. namespace InABox.Core
  3. {
  4. [UserTracking(typeof(User))]
  5. [Caption("Security Overrides")]
  6. [Unrecoverable]
  7. public class UserSecurityToken : Entity, IPersistent, IRemotable, ILicense<CoreLicense>
  8. {
  9. [NullEditor]
  10. [EntityRelationship(DeleteAction.Cascade)]
  11. public UserLink User { get; set; }
  12. [ComboLookupEditor(typeof(SecurityRestrictionGenerator))]
  13. public string Descriptor { get; set; }
  14. [CheckBoxEditor]
  15. public bool Enabled { get; set; }
  16. public override string ToString()
  17. {
  18. return Descriptor;
  19. }
  20. private class SecurityRestrictionGenerator : LookupGenerator<object>
  21. {
  22. public SecurityRestrictionGenerator(object[] items) : base(items)
  23. {
  24. foreach (var descriptor in Security.Descriptors.Where(x => x.HasScope(SecurityDescriptorScope.User)))
  25. AddValue(descriptor.Code, descriptor.Description);
  26. }
  27. }
  28. }
  29. }