123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- using System;
- using System.Collections.Generic;
- using System.Xml.Serialization;
- using System.Text;
- namespace COSXML.Model.Tag
- {
- /// <summary>
- /// ACL权限
- /// <see href="https://cloud.tencent.com/document/product/436/7733"/>
- /// </summary>
- [XmlRoot]
- public sealed class AccessControlPolicy
- {
- /// <summary>
- /// Bucket 持有者信息
- /// <see href="Owner"/>
- /// </summary>
- [XmlElement("Owner")]
- public Owner owner;
- /// <summary>
- /// 被授权者信息与权限信息
- /// <see href="AccessControlList"/>
- /// </summary>
- [XmlElement("AccessControlList")]
- public AccessControlList accessControlList;
- public string GetInfo()
- {
- StringBuilder stringBuilder = new StringBuilder("{AccessControlPolicy:\n");
- if (owner != null)
- {
- stringBuilder.Append(owner.GetInfo()).Append("\n");
- }
- if (accessControlList != null)
- {
- stringBuilder.Append(accessControlList.GetInfo()).Append("\n");
- }
- stringBuilder.Append("}");
- return stringBuilder.ToString();
- }
- public sealed class Owner
- {
- /// <summary>
- /// Bucket 持有者 ID
- /// 格式:qcs::cam::uin/<OwnerUin>:uin/<SubUin> 如果是根帐号,<OwnerUin> 和 <SubUin> 是同一个值
- /// </summary>
- [XmlElement("ID")]
- public string id;
- /// <summary>
- /// Bucket 持有者
- /// </summary>
- [XmlElement("DisplayName")]
- public string displayName;
- public string GetInfo()
- {
- StringBuilder stringBuilder = new StringBuilder("{Owner:\n");
- stringBuilder.Append("Id:").Append(id).Append("\n");
- stringBuilder.Append("}");
- return stringBuilder.ToString();
- }
- }
- public sealed class AccessControlList
- {
- /// <summary>
- /// 单个 Bucket 的授权信息。一个 AccessControlList 可以拥有 100 条 Grant
- /// <see href="Grant"/>
- /// </summary>
- [XmlElement("Grant")]
- public List<Grant> grants;
- public string GetInfo()
- {
- StringBuilder stringBuilder = new StringBuilder("{AccessControlList:\n");
- if (grants != null)
- {
- foreach (Grant grant in grants)
- {
- if (grant != null)
- {
- stringBuilder.Append(grant.GetInfo()).Append("\n");
- }
- }
- }
- stringBuilder.Append("}");
- return stringBuilder.ToString();
- }
- }
- public sealed class Grant
- {
- /// <summary>
- /// 说明被授权者的信息,
- /// <see href="Grantee"/>
- /// </summary>
- [XmlElement("Grantee")]
- public Grantee grantee;
- /// <summary>
- /// 指明授予被授权者的权限信息
- /// <see href="COSXML.Common.CosGrantPermission"/>
- /// </summary>
- [XmlElement("Permission")]
- public string permission;
- public string GetInfo()
- {
- StringBuilder stringBuilder = new StringBuilder("{Grant:\n");
- if (grantee != null)
- {
- stringBuilder.Append(grantee.GetInfo()).Append("\n");
- }
- stringBuilder.Append("Permission:").Append(permission).Append("\n");
- stringBuilder.Append("}");
- return stringBuilder.ToString();
- }
- }
- public sealed class Grantee
- {
- /// <summary>
- /// 用户的 ID,如果是根帐号,格式为:qcs::cam::uin/<OwnerUin>:uin/<OwnerUin>
- /// 如果是子帐号,格式为: qcs::cam::uin/<OwnerUin>:uin/<SubUin>
- /// </summary>
- [XmlElement("ID")]
- public string id;
- /// <summary>
- /// 或 http://cam.qcloud.com/groups/global/AllUsers (指代所有用户).
- /// </summary>
- [XmlElement("URI")]
- public string uri;
- /// <summary>
- /// 或 qcs::cam::anyone:anyone (指代所有用户).
- /// </summary>
- [XmlElement("DisplayName")]
- public string displayName;
- public string GetInfo()
- {
- StringBuilder stringBuilder = new StringBuilder("{Grantee:\n");
- if (uri != null)
- {
- stringBuilder.Append("URI:").Append(uri).Append("\n");
- }
- if (id != null)
- {
- stringBuilder.Append("Id:").Append(id).Append("\n");
- }
- stringBuilder.Append("}");
- return stringBuilder.ToString();
- }
- }
- }
- }
|