Represents a grant for an bucket/object ACL. A grant contains a S3Grantee and a S3Permission for that S3Grantee. For more information on Grants/ACLs refer:
Ejemplo n.º 1
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);
     this.grantList.Add(grant);
 }
Ejemplo n.º 2
0
 public void AddGrant(S3Grantee grantee, S3Permission permission)
 {
     S3Grant item = new S3Grant();
     item.WithGrantee(grantee);
     item.WithPermission(permission);
     this.grantList.Add(item);
 }
        /// <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);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        public void AddGrant(S3Grantee grantee, S3Permission permission)
        {
            S3Grant item = new S3Grant();

            item.WithGrantee(grantee);
            item.WithPermission(permission);
            this.grantList.Add(item);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
0
        public static void loggingSerial()
        {
            System.Console.WriteLine("\nhello,Logging!!");
            NameValueCollection appConfig = ConfigurationManager.AppSettings;

            AmazonS3 s3Client = AWSClientFactory.CreateAmazonS3Client(appConfig["AWSAccessKey"], appConfig["AWSSecretKey"]);
            String bucketName = "chttest1";
            String logBucketName = "chttest2";

            //PutBucket
            System.Console.WriteLine("PutBucket: {0} + {1}\n", bucketName,logBucketName);
            s3Client.PutBucket(new PutBucketRequest().WithBucketName(bucketName));
            s3Client.PutBucket(new PutBucketRequest().WithBucketName(logBucketName));

            //PutBucketACL for logDelivery user
            SetACLRequest aclRequest = new SetACLRequest();
            aclRequest.WithBucketName(logBucketName);
            aclRequest.WithCannedACL(S3CannedACL.LogDeliveryWrite);
            SetACLResponse setACLResult = s3Client.SetACL(aclRequest);
            System.Console.WriteLine("SetBucketACL, requestID:{0}\n",setACLResult.RequestId);

            //PutBucketLogging
            S3BucketLoggingConfig config = new S3BucketLoggingConfig();
            config.WithTargetBucketName(logBucketName);
            config.WithTargetPrefix("log-prefix");
            EnableBucketLoggingResponse setLoggingResult = s3Client.EnableBucketLogging(new EnableBucketLoggingRequest().WithBucketName(bucketName).WithLoggingConfig(config));
            System.Console.WriteLine("SetBucketLogging, requestID:{0}\n", setLoggingResult.RequestId);

            //GetBucketLogging
            GetBucketLoggingResponse getLoggingResult = s3Client.GetBucketLogging(new GetBucketLoggingRequest().WithBucketName(bucketName));
            System.Console.WriteLine("GetBucketLogging:\n {0}\n", getLoggingResult.ResponseXml);

            //jerry add
            S3BucketLoggingConfig config2 = new S3BucketLoggingConfig();
            config2.WithTargetBucketName(logBucketName);
            config2.WithTargetPrefix("log-prefix");

            S3Grant grant = new  S3Grant();
            S3Grantee grantee = new S3Grantee();

            grantee.WithCanonicalUser("262ab9144f28c47d5f65ad45d5a4930a6547e12c175762cb14dbae95ec7c0680", "HNJERRY");
            grant.WithGrantee(grantee);
            //grant_list.Add(grant);
            config2.AddGrant(grantee, S3Permission.FULL_CONTROL);
            //config2.WithGrants(grant_list);
            EnableBucketLoggingResponse setLoggingResult2 = s3Client.EnableBucketLogging(new EnableBucketLoggingRequest().WithBucketName(bucketName).WithLoggingConfig(config2));
            System.Console.WriteLine("SetBucketLogging, requestID:{0}\n", setLoggingResult.RequestId);

            GetBucketLoggingResponse getLoggingResult2 = s3Client.GetBucketLogging(new GetBucketLoggingRequest().WithBucketName(bucketName));
            System.Console.WriteLine("GetBucketLogging:\n {0}\n", getLoggingResult2.ResponseXml);
            //jerry add end

            //DeleteBucket
            System.Console.WriteLine("Delete Bucket!");
            s3Client.DeleteBucket(new DeleteBucketRequest().WithBucketName(bucketName));
            s3Client.DeleteBucket(new DeleteBucketRequest().WithBucketName(logBucketName));
            System.Console.WriteLine("END!");
        }
Ejemplo n.º 8
0
        public void AddGrant(S3Grantee grantee, S3Permission permission)
        {
            S3Grant item = new S3Grant
            {
                Grantee    = grantee,
                Permission = permission
            };

            Grants.Add(item);
        }
 /// <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);
 }
Ejemplo n.º 10
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);
 }
Ejemplo n.º 11
0
        public void AclSamples()
        {
            {
                #region PutACL Sample 1

                // Create a client
                AmazonS3Client client = new AmazonS3Client();

                // Set Canned ACL (PublicRead) for an existing item
                client.PutACL(new PutACLRequest
                {
                    BucketName = "SampleBucket",
                    Key = "Item1",
                    CannedACL = S3CannedACL.PublicRead
                });

                // Set Canned ACL (PublicRead) for an existing item
                // (This reverts ACL back to default for object)
                client.PutACL(new PutACLRequest
                {
                    BucketName = "SampleBucket",
                    Key = "Item1",
                    CannedACL = S3CannedACL.Private
                });

                #endregion
            }

            {
                #region GetACL\PutACL Samples

                // Create a client
                AmazonS3Client client = new AmazonS3Client();

                // Retrieve ACL for object
                S3AccessControlList acl = client.GetACL(new GetACLRequest
                {
                    BucketName = "SampleBucket",
                    Key = "Item1",
                }).AccessControlList;

                // Retrieve owner
                Owner owner = acl.Owner;


                // Describe grant
                S3Grant grant = new S3Grant
                {
                    Grantee = new S3Grantee { EmailAddress = "*****@*****.**" },
                    Permission = S3Permission.WRITE_ACP
                };

                // Create new ACL
                S3AccessControlList newAcl = new S3AccessControlList
                {
                    Grants = new List<S3Grant> { grant },
                    Owner = owner
                };

                // Set new ACL
                PutACLResponse response = client.PutACL(new PutACLRequest
                {
                    BucketName = "SampleBucket",
                    Key = "Item1",
                    AccessControlList = acl
                });

                #endregion
            }
        }