1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
-
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Text;
- namespace Aliyun.OSS
- {
-
-
-
-
-
- public class AccessControlList
- {
- private readonly Dictionary<Grant, bool> _grants = new Dictionary<Grant, bool>();
-
-
-
- public IEnumerable<Grant> Grants
- {
- get { return _grants.Keys; }
- }
-
-
-
- public Owner Owner { get; internal set; }
-
-
-
- internal AccessControlList()
- { }
-
-
-
-
-
-
- internal void GrantPermission(IGrantee grantee, Permission permission)
- {
- if (grantee == null)
- throw new ArgumentNullException("grantee");
- _grants.Add(new Grant(grantee, permission), true);
- }
-
-
-
-
-
-
- internal void RevokeAllPermissions(IGrantee grantee)
- {
- if (grantee == null)
- throw new ArgumentNullException("grantee");
- foreach (var e in _grants.Keys)
- {
- if (e.Grantee == grantee)
- {
- _grants.Remove(e);
- }
- }
- }
-
-
-
-
- public override String ToString() {
- var grantsBuilder = new StringBuilder();
- foreach(var g in Grants)
- {
- grantsBuilder.Append(g).Append(",");
- }
- return string.Format(CultureInfo.InvariantCulture,
- "[AccessControlList: Owner={0}, Grants={1}]", Owner, grantsBuilder);
- }
- }
- }
|