Ejemplo n.º 1
0
        protected IEnumerator <IAsyncResult> SetTableAclImpl(IAccountIdentifier identifier, string account, string tableName, ContainerAclSettings acl, TimeSpan timeout, RequestContext requestContext, AsyncIteratorContext <NoResults> context)
        {
            byte[]   numArray;
            Duration startingNow = Duration.StartingNow;

            if (identifier == null)
            {
                throw new ArgumentNullException("identifier");
            }
            if (string.IsNullOrEmpty(account))
            {
                throw new ArgumentException("account", "Cannot be null or empty");
            }
            if (string.IsNullOrEmpty(tableName))
            {
                throw new ArgumentException("tableName", "Cannot be null or empty");
            }
            if (acl == null)
            {
                throw new ArgumentNullException("acl");
            }
            if (acl.SASIdentifiers == null)
            {
                throw new ArgumentNullException("sasidentifiers");
            }
            if (timeout <= TimeSpan.Zero)
            {
                throw new TimeoutException("Timed out in SetTableAcl");
            }
            RemainingTime remainingTime = new RemainingTime(timeout);

            if (identifier is TableSignedAccessAccountIdentifier || identifier is AccountSasAccessIdentifier)
            {
                throw new NephosUnauthorizedAccessException("Signed access not supported for this request", AuthorizationFailureReason.InvalidOperationSAS);
            }
            IAsyncResult asyncResult = this.authorizationManager.BeginCheckAccess(identifier, account, tableName, null, PermissionLevel.WriteAcl, remainingTime, context.GetResumeCallback(), context.GetResumeState("TableManager.SetTableAclImpl"));

            yield return(asyncResult);

            this.authorizationManager.EndCheckAccess(asyncResult);
            using (IStorageAccount storageAccount = this.storageManager.CreateAccountInstance(account))
            {
                using (ITableContainer tableContainer = storageAccount.CreateTableContainerInstance(tableName))
                {
                    acl.EncodeToServiceMetadata(out numArray);
                    ContainerCondition containerCondition = null;
                    tableContainer.ServiceMetadata = numArray;
                    tableContainer.Timeout         = startingNow.Remaining(timeout);
                    asyncResult = tableContainer.BeginSetProperties(ContainerPropertyNames.ServiceMetadata, containerCondition, context.GetResumeCallback(), context.GetResumeState("TableManager.SetTableAclImpl"));
                    yield return(asyncResult);

                    tableContainer.EndSetProperties(asyncResult);
                }
            }
        }
Ejemplo n.º 2
0
        protected override IEnumerator <IAsyncResult> SetQueueAclImpl(IAccountIdentifier identifier, string account, string queue, ContainerAclSettings acl, TimeSpan timeout, RequestContext requestContext, AsyncIteratorContext <NoResults> context)
        {
            byte[]   numArray;
            Duration startingNow = Duration.StartingNow;

            if (identifier == null)
            {
                throw new ArgumentNullException("identifier");
            }
            if (string.IsNullOrEmpty(account))
            {
                throw new ArgumentException("account", "Cannot be null or empty");
            }
            if (string.IsNullOrEmpty(queue))
            {
                throw new ArgumentException("queue", "Cannot be null or empty");
            }
            if (acl == null)
            {
                throw new ArgumentNullException("acl");
            }
            if (acl.SASIdentifiers == null)
            {
                throw new ArgumentNullException("sasidentifiers");
            }
            if (timeout <= TimeSpan.Zero)
            {
                throw new TimeoutException("Timed out in SetQueueAcl");
            }
            RemainingTime remainingTime = new RemainingTime(timeout);
            IAsyncResult  asyncResult   = this.BeginGetQueue(identifier, account, queue, PermissionLevel.WriteAcl, remainingTime, requestContext, context.GetResumeCallback(), context.GetResumeState("QueueManager.SetQueueAclImpl"));

            yield return(asyncResult);

            IQueueContainer operationStatus = this.EndGetQueue(asyncResult);

            if (requestContext != null)
            {
                operationStatus.OperationStatus = requestContext.OperationStatus;
            }
            acl.EncodeToServiceMetadata(out numArray);
            operationStatus.ServiceMetadata = numArray;
            operationStatus.Timeout         = remainingTime;
            asyncResult = operationStatus.BeginSetProperties(ContainerPropertyNames.ServiceMetadata, null, context.GetResumeCallback(), context.GetResumeState("QueueManager.SetQueueAclImpl"));
            yield return(asyncResult);

            operationStatus.EndSetProperties(asyncResult);
        }