/// <summary>
 /// Creates a S3Grant and adds it to the list of grants.
 /// </summary>
 /// <param name="grantee">The grantee for the grant.</param>
 /// <param name="permission">The permission for the grantee.</param>
 public void AddGrant(S3Grantee grantee, S3Permission permission)
 {
     S3Grant grant = new S3Grant();
     grant.WithGrantee(grantee);
     grant.WithPermission(permission);
     this.grantList.Add(grant);
 }
Example #2
0
 public void AddGrant(S3Grantee grantee, S3Permission permission)
 {
     S3Grant item = new S3Grant();
     item.WithGrantee(grantee);
     item.WithPermission(permission);
     this.grantList.Add(item);
 }
    private static void ParseGrant(GetObjectAclResponse response, XmlReader xmlReader)
    {
        S3Permission permission = S3Permission.Unknown;
        S3Grantee?   grantee    = null;

        foreach (string name in XmlHelper.ReadElements(xmlReader, "Grant"))
        {
            switch (name)
            {
            case "Grantee":
                grantee = ParseGrantee(xmlReader);
                break;

            case "Permission":
                permission = ValueHelper.ParseEnum <S3Permission>(xmlReader.ReadString());
                break;
            }
        }

        if (grantee == null)
        {
            throw new InvalidOperationException("Missing required values");
        }

        response.Grants.Add(new S3Grant(grantee, permission));
    }
Example #4
0
        public void AddGrant(S3Grantee grantee, S3Permission permission)
        {
            S3Grant item = new S3Grant();

            item.WithGrantee(grantee);
            item.WithPermission(permission);
            this.grantList.Add(item);
        }
Example #5
0
        /// <summary>
        /// Creates a S3Grant and adds it to the list of grants.
        /// </summary>
        /// <param name="grantee">The grantee for the grant.</param>
        /// <param name="permission">The permission for the grantee.</param>
        public void AddGrant(S3Grantee grantee, S3Permission permission)
        {
            S3Grant grant = new S3Grant();

            grant.Grantee    = grantee;
            grant.Permission = permission;
            this.Grants.Add(grant);
        }
        /// <summary>
        /// Creates a S3Grant and adds it to the list of grants.
        /// </summary>
        /// <param name="grantee">The grantee for the grant.</param>
        /// <param name="permission">The permission for the grantee.</param>
        public void AddGrant(S3Grantee grantee, S3Permission permission)
        {
            S3Grant grant = new S3Grant {
                Grantee = grantee, Permission = permission
            };

            Grants.Add(grant);
        }
Example #7
0
        /// <summary>
        /// Creates a S3Grant and adds it to the list of grants.
        /// </summary>
        /// <param name="grantee">The grantee for the grant.</param>
        /// <param name="permission">The permission for the grantee.</param>
        public void AddGrant(S3Grantee grantee, S3Permission permission)
        {
            S3Grant grant = new S3Grant();

            grant.WithGrantee(grantee);
            grant.WithPermission(permission);
            Grants.Add(grant);
        }
Example #8
0
        public void AddGrant(S3Grantee grantee, S3Permission permission)
        {
            S3Grant item = new S3Grant
            {
                Grantee    = grantee,
                Permission = permission
            };

            Grants.Add(item);
        }
 /// <summary>
 /// Removes a specific permission for the given grantee.
 /// </summary>
 /// <param name="grantee">The grantee</param>
 /// <param name="permission">The permission for the grantee to remove</param>
 public void RemoveGrant(S3Grantee grantee, S3Permission permission)
 {
     foreach (S3Grant grant in this.Grants)
     {
         if (grant.Grantee.Equals(grantee) && grant.Permission == permission)
         {
             this.Grants.Remove(grant);
             break;
         }
     }
 }
 /// <summary>
 /// Removes a specific permission for the given grantee.
 /// </summary>
 /// <param name="grantee">The grantee</param>
 /// <param name="permission">The permission for the grantee to remove</param>
 public void RemoveGrant(S3Grantee grantee, S3Permission permission)
 {
     foreach (S3Grant grant in this.grantList)
     {
         if (grant.Grantee.Equals(grantee) && grant.Permission == permission)
         {
             this.grantList.Remove(grant);
             break;
         }
     }
 }
Example #11
0
 private bool GrantsContain(List <S3Grant> grants, string uriSubstring, S3Permission s3Permission)
 {
     foreach (var grant in grants)
     {
         if (grant.Permission == s3Permission && grant.Grantee.URI != null && grant.Grantee.URI.Contains(uriSubstring))
         {
             return(true);
         }
     }
     return(false);
 }
 /// <summary>
 /// Removes a specific permission for the given grantee.
 /// </summary>
 /// <param name="grantee">The grantee</param>
 /// <param name="permission">The permission for the grantee to remove</param>
 public void RemoveGrant(S3Grantee grantee, S3Permission permission)
 {
     foreach (S3Grant grant in Grants)
     {
         if (grant.Grantee.Equals(grantee) && grant.Permission == permission)
         {
             Grants.Remove(grant);
             break;
         }
     }
 }
Example #13
0
        private void setS3Permission(String bucketName, String key)
        {
            // Get the ACL for the file and retrieve the owner ID (not sure how to get it otherwise).
            GetACLRequest  getAclRequest = new GetACLRequest().WithBucketName(bucketName).WithKey(key);
            GetACLResponse aclResponse   = s3.GetACL(getAclRequest);
            Owner          owner         = aclResponse.AccessControlList.Owner;

            // Create a grantee as the MessageGears account
            S3Grantee grantee = new S3Grantee().WithCanonicalUser(properties.MessageGearsAWSCanonicalId, "MessageGears");

            // Grant MessageGears Read-only access
            S3Permission        messageGearsPermission = S3Permission.READ;
            S3AccessControlList acl = new S3AccessControlList().WithOwner(owner);

            acl.AddGrant(grantee, messageGearsPermission);

            // Create a new ACL granting the owner full control.
            grantee = new S3Grantee().WithCanonicalUser(owner.Id, "MyAWSId");
            acl.AddGrant(grantee, S3Permission.FULL_CONTROL);
            SetACLRequest aclRequest = new SetACLRequest().WithACL(acl).WithBucketName(bucketName).WithKey(key);

            s3.SetACL(aclRequest);
        }
Example #14
0
 public S3Grant WithPermission(S3Permission permission)
 {
     this.permission = permission;
     return this;
 }
Example #15
0
 public S3Grant(S3Grantee grantee, S3Permission permission)
 {
     Grantee    = grantee;
     Permission = permission;
 }
Example #16
0
 public S3Grant WithPermission(S3Permission permission)
 {
     this.permission = permission;
     return(this);
 }
 /// <summary>
 /// Creates a S3Grant and adds it to the list of grants.
 /// </summary>
 /// <param name="grantee">The grantee for the grant.</param>
 /// <param name="permission">The permission for the grantee.</param>
 public void AddGrant(S3Grantee grantee, S3Permission permission)
 {
     S3Grant grant = new S3Grant();
     grant.Grantee = grantee;
     grant.Permission = permission;
     this.Grants.Add(grant);
 }
Example #18
0
 /// <summary>
 /// Appends the given <see cref="S3Permission"/> to this instance's <see cref="Permissions"/> collection.
 /// </summary>
 /// <param name="permission">The permission to append.</param>
 /// <returns>This instance.</returns>
 public S3Access WithPermission(S3Permission permission)
 {
     return(this.WithPermissions(new S3Permission[] { permission }));
 }
 /// <summary>
 /// Creates a S3Grant and adds it to the list of grants.
 /// </summary>
 /// <param name="grantee">The grantee for the grant.</param>
 /// <param name="permission">The permission for the grantee.</param>
 public void AddGrant(S3Grantee grantee, S3Permission permission)
 {
     S3Grant grant = new S3Grant
     {
         Grantee = grantee,
         Permission = permission
     };
     Grants.Add(grant);
 }