Free cookie consent management tool by TermsFeed Policy Generator

source: branches/Persistence Test/HeuristicLab.Hive.Server.Core/3.2/Authorization/Policy.cs @ 3696

Last change on this file since 3696 was 2100, checked in by mbecirov, 15 years ago

#586: Fixed authorization when no policy scope is defined.

File size: 1.0 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using HeuristicLab.Security.Contracts.BusinessObjects;
6
7namespace HeuristicLab.Hive.Server.Core {
8  public class Policy {
9    private string _name;
10    public string Name { get { return _name; } set { this._name = value; } }
11
12    private IDictionary<Permission, PermissionContext> _permissions = new Dictionary<Permission, PermissionContext>();
13    public IDictionary<Permission, PermissionContext> Permissions { get { return this._permissions; } set { this._permissions = value; } }
14
15    public Policy(string name) {
16      this._name = name;
17    }
18
19    public void AddPermission(Permission permission, PermissionContext ctx) {
20      this._permissions.Add(permission, ctx);
21    }
22
23    public Permission GetPermissionByContext(string context) {
24      foreach (KeyValuePair<Permission, PermissionContext> item in _permissions) {
25        if (item.Value.Elevation == context)
26          return item.Key;
27      }
28      return null;
29    }
30
31  }
32}
Note: See TracBrowser for help on using the repository browser.