Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Hive.Server.Core/3.2/Authorization/PermissionCollection.cs @ 2074

Last change on this file since 2074 was 2065, checked in by mbecirov, 15 years ago

#586: Added authorization components.

File size: 1.6 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 PermissionCollection : IEnumerable<Permission> {
9    public IList<Permission> perm = new List<Permission>();
10
11    public PermissionCollection() {
12    }
13
14    public IList<Permission> Permissions {
15      get { return perm; }
16    }
17
18    /// <summary>
19    /// Gets the Permission identified by FQN type.
20    /// </summary>
21    /// <param name="permissionName">eg. 'HivePermissions.Jobmanagement.Create.Any'</param>
22    /// <returns></returns>
23    public Permission this[string permissionName] {
24      get {
25        foreach (Permission item in perm) {
26          if (item.Name == permissionName)
27            return item;
28        }
29        return null;
30      }
31    }
32
33    /// <summary>
34    /// Converts an enumeration to a fully qualified string.
35    /// </summary>
36    /// <param name="obj">Any enumeration type.</param>
37    /// <returns>Type Information in Full Qualified Notation (FQN).</returns>
38    public string Convert(object obj) {
39      string retVal = string.Empty;
40      Type t = obj.GetType();
41      string value = obj.ToString();
42      retVal = (t.FullName.Replace(t.Namespace + ".", "")).Replace("+", ".") + "." + value;
43      return retVal;
44    }
45
46    public IEnumerator<Permission> GetEnumerator() {
47      return perm.GetEnumerator();
48    }
49
50    System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() {
51      return perm.GetEnumerator();
52    }
53
54  }
55
56}
Note: See TracBrowser for help on using the repository browser.