SecurityToken.cs 1.1 KB

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