Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
MultiplePrivileges.cs
2{
6 public class MultiplePrivileges<T> : IAuthorization<T>
7 {
8 private readonly string[] privileges;
9 private readonly int count;
10
15 public MultiplePrivileges(string[] Privileges)
16 {
17 this.privileges = Privileges;
18 this.count = Privileges?.Length ?? 0;
19 }
20
27 public bool IsAuthorized(T Resource, IHasPrivileges User)
28 {
29 for (int i = 0; i < this.count; i++)
30 {
31 if (!User.HasPrivilege(this.privileges[i]))
32 return false;
33 }
34
35 return true;
36 }
37 }
38}
Authorization based on multiple privileges.
MultiplePrivileges(string[] Privileges)
Authorization based on multiple privileges.
bool IsAuthorized(T Resource, IHasPrivileges User)
Checks if an user or object is authorized to perform an action.
Basic authorization interface for objects of type T .
Interface for objects that have privileges.
bool HasPrivilege(string Privilege)
If the object has a given privilege.