GroupGrantee.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright (C) Alibaba Cloud Computing
  3. * All rights reserved.
  4. *
  5. * 版权所有 (C)阿里云计算有限公司
  6. */
  7. using System;
  8. namespace Aliyun.OSS
  9. {
  10. /// <summary>
  11. /// 定义了可以被授权的一组OSS用户。
  12. /// </summary>
  13. public sealed class GroupGrantee : IGrantee
  14. {
  15. private readonly string _identifier;
  16. /// <summary>
  17. /// 获取被授权者的标识。
  18. /// </summary>
  19. /// <remarks>
  20. /// 不支持set操作,否则会抛出<see cref="NotSupportedException" />。
  21. /// </remarks>
  22. public string Identifier
  23. {
  24. get { return _identifier; }
  25. set { throw new NotSupportedException(); }
  26. }
  27. private static readonly GroupGrantee _allUsers =
  28. new GroupGrantee("http://oss.service.aliyun.com/acl/group/ALL_USERS");
  29. /// <summary>
  30. /// 表示为OSS的<see cref="Bucket" />或<see cref="OssObject" />指定匿名访问的权限。
  31. /// 任何用户都可以根据被授予的权限进行访问。
  32. /// </summary>
  33. public static GroupGrantee AllUsers
  34. {
  35. get { return _allUsers; }
  36. }
  37. /// <summary>
  38. /// 设置授权者标识
  39. /// </summary>
  40. /// <param name="identifier">授权者标识</param>
  41. private GroupGrantee(string identifier)
  42. {
  43. _identifier = identifier;
  44. }
  45. /// <summary>
  46. /// 判断两个<see cref="GroupGrantee"/>是否相等
  47. /// </summary>
  48. /// <param name="obj">需要判断的另一个<see cref="GroupGrantee"/></param>
  49. /// <returns></returns>
  50. public override bool Equals(object obj)
  51. {
  52. var grantee = obj as GroupGrantee;
  53. if (grantee == null)
  54. return false;
  55. return grantee.Identifier == Identifier;
  56. }
  57. /// <summary>
  58. /// 获取hash code值
  59. /// </summary>
  60. /// <returns>hash code值</returns>
  61. public override int GetHashCode()
  62. {
  63. return ("[GroupGrantee ID=" + Identifier + "]").GetHashCode();
  64. }
  65. }
  66. }