Esempio n. 1
0
 public LazyPermission(SecurityPolicy <TUserSecurityContext> policy,
                       Func <IPermission <TInput> > constructor)
 {
     //TODO: get stuff from attribute
     Policy     = policy;
     Permission = new Lazy <IPermission <TInput> >(constructor);
 }
Esempio n. 2
0
 public LazyPermission(SecurityPolicy <TUserSecurityContext> policy, string name,
                       Func <TUserSecurityContext, TInput, bool> assertionFunc,
                       Func <TUserSecurityContext, TInput, string> denialMessageBuilder = null)
 {
     Policy     = policy;
     Permission = new Lazy <IPermission <TInput> >(()
                                                   => new GenericPermission <TInput>(Policy, name, assertionFunc, denialMessageBuilder));
 }
 public GenericPermission(SecurityPolicy <TUserSecurityContext> policy,
                          string name,
                          Func <TUserSecurityContext, bool> assertionFunc,
                          Func <TUserSecurityContext, string> denialMessageBuilder = null)
     : base(policy)
 {
     Name = name;
     this.assertionFunc        = assertionFunc;
     this.denialMessageBuilder = denialMessageBuilder;
 }
            internal PermissionBuilder(SecurityPolicy <TUserSecurityContext> policy, PropertyInfo PermissionProperty)
            {
                this.policy             = policy;
                this.permissionProperty = PermissionProperty;
                this.name = PermissionProperty.GetCustomAttribute <PermissionNameAttribute>()?.Name
                            ?? PermissionProperty.Name;
                var message = PermissionProperty.GetCustomAttribute <PermissionDenialMessageAttribute>()?.Message;

                if (!string.IsNullOrEmpty(message))
                {
                    messageBuilder = (TUserSecurityContext user, TInput _) => message;
                }
            }
Esempio n. 5
0
 public Permission(SecurityPolicy <TUserSecurityContext> policy) : base(policy)
 {
 }
Esempio n. 6
0
 public PermissionBase(SecurityPolicy <TUserSecurityContext> policy)
 {
     Policy = policy;
     Name   = this.GetType().GetCustomAttribute <PermissionNameAttribute>()?.Name ?? this.GetType().Name;
 }