Beispiel #1
0
        public IAsyncResult BeginSetProperties(ContainerPropertyNames propertyNames, IContainerCondition condition, AsyncCallback callback, object state)
        {
            AsyncIteratorContext <NoResults> asyncIteratorContext = new AsyncIteratorContext <NoResults>("RealBlobContainer.SetProperties", callback, state);

            asyncIteratorContext.Begin(this.SetPropertiesImpl(propertyNames, condition, asyncIteratorContext));
            return(asyncIteratorContext);
        }
Beispiel #2
0
        private IEnumerator <IAsyncResult> GetPropertiesNoCacheSynchronizationImpl(ContainerPropertyNames propertyNames, IContainerCondition condition, CacheRefreshOptions cacheRefreshOptions, bool shouldUpdateCacheEntryOnRefresh, AsyncIteratorContext <NoResults> context)
        {
            IAsyncResult asyncResult;

            try
            {
                asyncResult = this.container.BeginGetProperties(propertyNames, Helpers.Convert(condition), context.GetResumeCallback(), context.GetResumeState("BlobContainer.GetPropertiesImpl"));
            }
            catch (Exception exception)
            {
                StorageStamp.TranslateException(exception);
                throw;
            }
            yield return(asyncResult);

            try
            {
                this.container.EndGetProperties(asyncResult);
            }
            catch (Exception exception1)
            {
                StorageStamp.TranslateException(exception1);
                throw;
            }
        }
Beispiel #3
0
        private IAsyncResult BeginGetPropertiesNoCacheSynchronization(ContainerPropertyNames propertyNames, IContainerCondition condition, CacheRefreshOptions cacheRefreshOptions, bool shouldUpdateCacheEntryOnRefresh, AsyncCallback callback, object state)
        {
            AsyncIteratorContext <NoResults> asyncIteratorContext = new AsyncIteratorContext <NoResults>("RealBlobContainer.GetPropertiesNoCacheSynchronization", callback, state);

            asyncIteratorContext.Begin(this.GetPropertiesNoCacheSynchronizationImpl(propertyNames, condition, cacheRefreshOptions, shouldUpdateCacheEntryOnRefresh, asyncIteratorContext));
            return(asyncIteratorContext);
        }
Beispiel #4
0
        protected IEnumerator <IAsyncResult> GetTableAclImpl(IAccountIdentifier identifier, string account, string tableName, TimeSpan timeout, RequestContext requestContext, AsyncIteratorContext <ContainerAclSettings> context)
        {
            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 (timeout <= TimeSpan.Zero)
            {
                throw new TimeoutException("Timed out in GetTableAcl");
            }
            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.ReadAcl, startingNow.Remaining(timeout), context.GetResumeCallback(), context.GetResumeState("TableManager.GetTableAclImpl"));

            yield return(asyncResult);

            this.authorizationManager.EndCheckAccess(asyncResult);
            string str  = account;
            string str1 = tableName;

            using (IStorageAccount storageAccount = this.storageManager.CreateAccountInstance(str))
            {
                using (ITableContainer tableContainer = storageAccount.CreateTableContainerInstance(str1))
                {
                    ContainerPropertyNames containerPropertyName = ContainerPropertyNames.LastModificationTime | ContainerPropertyNames.ServiceMetadata;
                    tableContainer.Timeout = startingNow.Remaining(timeout);
                    asyncResult            = tableContainer.BeginGetProperties(containerPropertyName, null, CacheRefreshOptions.SkipAllCache, context.GetResumeCallback(), context.GetResumeState("TableManager.GetTableAclImpl"));
                    yield return(asyncResult);

                    tableContainer.EndGetProperties(asyncResult);
                    try
                    {
                        context.ResultData = new ContainerAclSettings(tableContainer.ServiceMetadata);
                    }
                    catch (MetadataFormatException metadataFormatException1)
                    {
                        MetadataFormatException metadataFormatException = metadataFormatException1;
                        throw new NephosStorageDataCorruptionException(string.Format("Error decoding Acl setting for {0}", RealServiceManager.GetResourceString(account, tableName)), metadataFormatException);
                    }
                }
            }
        }
Beispiel #5
0
        private IEnumerator <IAsyncResult> GetPropertiesImpl(ContainerPropertyNames propertyNames, IContainerCondition condition, CacheRefreshOptions cacheRefreshOptions, bool shouldUpdateCacheEntryOnRefresh, AsyncIteratorContext <NoResults> context)
        {
            IAsyncResult asyncResult = this.Account.BeginGetProperties(AccountPropertyNames.None, null, context.GetResumeCallback(), context.GetResumeState("Container.GetPropertiesImpl"));

            yield return(asyncResult);

            this.Account.EndGetProperties(asyncResult);
            asyncResult = this.BeginGetPropertiesNoCacheSynchronization(propertyNames, condition, cacheRefreshOptions, shouldUpdateCacheEntryOnRefresh, context.GetResumeCallback(), context.GetResumeState("Container.GetPropertiesImpl"));
            yield return(asyncResult);

            this.EndGetPropertiesNoCacheSynchronization(asyncResult);
        }
Beispiel #6
0
        private IEnumerator <IAsyncResult> GetPropertiesImpl(ContainerPropertyNames propertyNames, IContainerCondition condition, AsyncIteratorContext <NoResults> context)
        {
            IAsyncResult asyncResult = this.StorageManager.AsyncProcessor.BeginExecute((TimeSpan remaining) => {
                using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext())
                {
                    Microsoft.WindowsAzure.DevelopmentStorage.Store.QueueContainer queueContainer = this.LoadQueueContainer(dbContext);
                    DbQueueContainer.CheckQueueContainerCondition(queueContainer, condition);
                    this._queue = queueContainer;
                }
            }, this.Timeout, context.GetResumeCallback(), context.GetResumeState("DbQueueContainer.GetPropertiesImpl"));

            yield return(asyncResult);

            this.StorageManager.AsyncProcessor.EndExecute(asyncResult);
        }
Beispiel #7
0
        private IEnumerator <IAsyncResult> GetPropertiesImpl(ContainerPropertyNames propertyNames, IContainerCondition condition, AsyncIteratorContext <NoResults> context)
        {
            IAsyncResult asyncResult = this.StorageManager.AsyncProcessor.BeginExecute((TimeSpan param0) => {
                using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext())
                {
                    Microsoft.WindowsAzure.DevelopmentStorage.Store.BlobContainer blobContainer = this.LoadBlobContainer(dbContext);
                    ContainerLeaseInfo containerLeaseInfo = new ContainerLeaseInfo(blobContainer, DateTime.UtcNow);
                    DbBlobContainer.CheckBlobContainerCondition(blobContainer, condition, containerLeaseInfo);
                    this._container = blobContainer;
                    this.LeaseInfo  = containerLeaseInfo;
                }
            }, this.Timeout, context.GetResumeCallback(), context.GetResumeState("DbBlobContainer.GetProperties"));

            yield return(asyncResult);

            this.StorageManager.AsyncProcessor.EndExecute(asyncResult);
        }
Beispiel #8
0
        private IEnumerator <IAsyncResult> SetPropertiesImpl(ContainerPropertyNames propertyNames, IContainerCondition condition, AsyncIteratorContext <NoResults> context)
        {
            IAsyncResult asyncResult = this.StorageManager.AsyncProcessor.BeginExecute((TimeSpan remaining) => {
                using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext())
                {
                    Microsoft.WindowsAzure.DevelopmentStorage.Store.QueueContainer applicationMetadata = this.LoadQueueContainer(dbContext);
                    if ((propertyNames & ContainerPropertyNames.ApplicationMetadata) != ContainerPropertyNames.None)
                    {
                        StorageStampHelpers.ValidateApplicationMetadata(this.ApplicationMetadata);
                        applicationMetadata.Metadata = this.ApplicationMetadata;
                    }
                    if ((propertyNames & ContainerPropertyNames.ServiceMetadata) != ContainerPropertyNames.None)
                    {
                        applicationMetadata.ServiceMetadata = ((IContainer)this).ServiceMetadata;
                    }
                    dbContext.SubmitChanges();
                    this._queue = applicationMetadata;
                }
            }, this.Timeout, context.GetResumeCallback(), context.GetResumeState("DbQueueContainer.SetProperties"));

            yield return(asyncResult);

            this.StorageManager.AsyncProcessor.EndExecute(asyncResult);
        }
Beispiel #9
0
 public static IAsyncResult BeginListContainers(this IStorageAccount account, ServiceType serviceType, string containerName, ContainerPropertyNames propertyNames, string separator, string containerNameStart, IContainerCondition condition, int maxContainerNames, AsyncCallback callback, object state)
 {
     if (serviceType == ServiceType.BlobService)
     {
         return(account.BeginListBlobContainers(containerName, propertyNames, separator, containerNameStart, condition, maxContainerNames, callback, state));
     }
     NephosAssertionException.Fail("Invalid service type {0}.", new object[] { serviceType });
     return(null);
 }
Beispiel #10
0
 IAsyncResult Microsoft.Cis.Services.Nephos.Common.Storage.IStorageAccount.BeginListTableContainers(string containerName, ContainerPropertyNames propertyNames, string separator, string containerNameStart, IContainerCondition condition, int maxContainerNames, AsyncCallback callback, object state)
 {
     throw new NotSupportedException();
 }
Beispiel #11
0
        IAsyncResult Microsoft.Cis.Services.Nephos.Common.Storage.IStorageAccount.BeginListQueueContainers(string containerName, ContainerPropertyNames propertyNames, string separator, string containerNameStart, IContainerCondition condition, int maxContainerNames, AsyncCallback callback, object state)
        {
            AsyncIteratorContext <IQueueContainerCollection> asyncIteratorContext = new AsyncIteratorContext <IQueueContainerCollection>("StorageAccount.ListQueueContainers", callback, state);

            asyncIteratorContext.Begin(this.ListQueueContainersImpl(containerName, propertyNames, separator, containerNameStart, condition, maxContainerNames, asyncIteratorContext));
            return(asyncIteratorContext);
        }
Beispiel #12
0
        private IEnumerator <IAsyncResult> ListQueueContainersImpl(string containerNamePrefix, ContainerPropertyNames propertyNames, string separator, string containerNameStart, IContainerCondition condition, int maxQueueNames, AsyncIteratorContext <IQueueContainerCollection> context)
        {
            IStringDataEventStream verboseDebug = Logger <INormalAndDebugLogger> .Instance.VerboseDebug;

            object[] objArray = new object[] { containerNamePrefix, propertyNames, separator, containerNameStart, condition, maxQueueNames, this.Timeout };
            verboseDebug.Log("ListQueueContainersImpl({0},{1},{2},{3},{4},{5},{6})", objArray);
            IAsyncResult asyncResult = this.StorageManager.AsyncProcessor.BeginExecute <DbQueueContainerCollection>((TimeSpan param0) => {
                DbQueueContainerCollection dbQueueContainerCollections;
                StorageStampHelpers.ValidateMaxContainers(maxQueueNames);
                using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext())
                {
                    IQueryable <Microsoft.WindowsAzure.DevelopmentStorage.Store.QueueContainer> queueContainers = this.MakeListQueueContainersQuery(containerNamePrefix, separator, containerNameStart, condition, maxQueueNames, dbContext);
                    dbQueueContainerCollections = this.ReadListQueueContainersResult(containerNamePrefix, separator, maxQueueNames, queueContainers);
                }
                return(dbQueueContainerCollections);
            }, this.Timeout, context.GetResumeCallback(), context.GetResumeState("StorageStamp.ListQueueContainersImpl"));

            yield return(asyncResult);

            context.ResultData = this.StorageManager.AsyncProcessor.EndExecute <DbQueueContainerCollection>(asyncResult);
        }
Beispiel #13
0
        private IEnumerator <IAsyncResult> ListBlobContainersImpl(string containerNamePrefix, ContainerPropertyNames propertyNames, string separator, string containerKeyStart, IContainerCondition condition, int maxContainerNames, AsyncIteratorContext <IBlobContainerCollection> context)
        {
            IStringDataEventStream verboseDebug = Logger <INormalAndDebugLogger> .Instance.VerboseDebug;

            object[] objArray = new object[] { containerNamePrefix, propertyNames, separator, containerKeyStart, condition, maxContainerNames, this.Timeout };
            verboseDebug.Log("ListBlobContainersImpl({0},{1},{2},{3},{4},{5},{6})", objArray);
            string str = null;

            if (containerKeyStart != null)
            {
                string[] strArrays = containerKeyStart.Split(new char[] { '/' });
                if ((int)strArrays.Length != 3)
                {
                    throw new ArgumentOutOfRangeException("containerKeyStart", "The marker is not well formed.");
                }
                string str1 = strArrays[1];
                str = strArrays[2];
                if (str1 != this.Name)
                {
                    throw new ArgumentException(string.Format("Account name '{0}' specified in the container key start does not match the account being listed '{1}'", str1, this.Name), "containerKeyStart");
                }
            }
            IAsyncResult asyncResult = this.StorageManager.AsyncProcessor.BeginExecute <DbBlobContainerCollection>((TimeSpan param0) => {
                DbBlobContainerCollection dbBlobContainerCollections;
                StorageStampHelpers.ValidateMaxContainers(maxContainerNames);
                using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext())
                {
                    IQueryable <Microsoft.WindowsAzure.DevelopmentStorage.Store.BlobContainer> blobContainers = this.MakeListBlobContainersQuery(containerNamePrefix, separator, str, condition, maxContainerNames, dbContext);
                    dbBlobContainerCollections = this.ReadListBlobContainersResult(containerNamePrefix, separator, maxContainerNames, blobContainers);
                }
                return(dbBlobContainerCollections);
            }, this.Timeout, context.GetResumeCallback(), context.GetResumeState("StorageStamp.ListBlobContainersImpl"));

            yield return(asyncResult);

            context.ResultData = this.StorageManager.AsyncProcessor.EndExecute <DbBlobContainerCollection>(asyncResult);
        }
Beispiel #14
0
        private IEnumerator <IAsyncResult> ListBlobContainersImpl(string containerName, ContainerPropertyNames propertyNames, string separator, string containerNameStart, IContainerCondition condition, int maxContainerNames, AsyncIteratorContext <IBlobContainerCollection> context)
        {
            IAsyncResult           asyncResult;
            IStringDataEventStream verboseDebug = Logger <IRestProtocolHeadLogger> .Instance.VerboseDebug;

            object[] objArray = new object[] { containerName, propertyNames, separator, containerNameStart, condition, maxContainerNames, this.Timeout };
            verboseDebug.Log("ListBlobContainersImpl({0},{1},{2},{3},{4},{5},{6})", objArray);
            try
            {
                asyncResult = this.internalAccount.BeginListBlobContainers(containerName, propertyNames, separator, containerNameStart, Helpers.Convert(condition), maxContainerNames, context.GetResumeCallback(), context.GetResumeState("StorageStamp.ListBlobContainersImpl"));
            }
            catch (Exception exception)
            {
                StorageStamp.TranslateException(exception);
                throw;
            }
            yield return(asyncResult);

            try
            {
                IBlobContainerCollection blobContainerCollections = this.internalAccount.EndListBlobContainers(asyncResult);
                context.ResultData = new BlobContainerCollection(blobContainerCollections);
            }
            catch (Exception exception1)
            {
                StorageStamp.TranslateException(exception1);
                throw;
            }
        }
Beispiel #15
0
        IAsyncResult Microsoft.Cis.Services.Nephos.Common.Storage.IContainer.BeginSetProperties(ContainerPropertyNames propertyNames, IContainerCondition condition, AsyncCallback callback, object state)
        {
            AsyncIteratorContext <NoResults> asyncIteratorContext = new AsyncIteratorContext <NoResults>("DbQueueContainer.SetProperties", callback, state);

            asyncIteratorContext.Begin(this.SetPropertiesImpl(propertyNames, condition, asyncIteratorContext));
            return(asyncIteratorContext);
        }
Beispiel #16
0
 public IAsyncResult BeginGetProperties(ContainerPropertyNames propertyNames, IContainerCondition condition, CacheRefreshOptions cacheRefreshOptions, AsyncCallback callback, object state)
 {
     return(this.BeginGetProperties(propertyNames, condition, cacheRefreshOptions, true, callback, state));
 }
Beispiel #17
0
        private IAsyncResult BeginGetQueue(IAccountIdentifier identity, string account, string queue, PermissionLevel permission, SASAuthorizationParameters sasParams, ContainerPropertyNames propertyNames, TimeSpan timeout, RequestContext requestContext, AsyncCallback callback, object state)
        {
            AsyncIteratorContext <IQueueContainer> asyncIteratorContext = new AsyncIteratorContext <IQueueContainer>("QueueManager.GetQueue", callback, state);

            asyncIteratorContext.Begin(this.GetQueueImpl(identity, account, queue, permission, sasParams, propertyNames, timeout, requestContext, asyncIteratorContext));
            return(asyncIteratorContext);
        }
Beispiel #18
0
 private IAsyncResult BeginGetQueue(IAccountIdentifier identity, string account, string queue, PermissionLevel permission, ContainerPropertyNames propertyNames, TimeSpan timeout, RequestContext requestContext, AsyncCallback callback, object state)
 {
     return(this.BeginGetQueue(identity, account, queue, permission, propertyNames, CacheRefreshOptions.None, timeout, requestContext, callback, state));
 }
Beispiel #19
0
        private IEnumerator <IAsyncResult> GetQueueImpl(IAccountIdentifier identity, string account, string queue, PermissionLevel permission, SASAuthorizationParameters sasParams, ContainerPropertyNames propertyNames, TimeSpan timeout, RequestContext requestContext, AsyncIteratorContext <IQueueContainer> context)
        {
            RemainingTime remainingTime = new RemainingTime(timeout);
            IAsyncResult  asyncResult   = this.authorizationManager.BeginCheckAccess(identity, account, null, null, permission, sasParams, remainingTime, context.GetResumeCallback(), context.GetResumeState("QueueManager.GetQueueImpl"));

            yield return(asyncResult);

            this.authorizationManager.EndCheckAccess(asyncResult);
            IStorageAccount storageAccount = this.storageManager.CreateAccountInstance(account);
            IQueueContainer queueContainer = storageAccount.CreateQueueContainerInstance(queue);

            queueContainer.Timeout = remainingTime;
            asyncResult            = queueContainer.BeginGetProperties(propertyNames, null, context.GetResumeCallback(), context.GetResumeState("QueueManager.GetQueueImpl"));
            yield return(asyncResult);

            queueContainer.EndGetProperties(asyncResult);
            context.ResultData = queueContainer;
        }
Beispiel #20
0
        IAsyncResult Microsoft.Cis.Services.Nephos.Common.Storage.IContainer.BeginGetProperties(ContainerPropertyNames propertyNames, IContainerCondition condition, CacheRefreshOptions cacheRefreshOptions, bool shouldUpdateCacheEntryOnRefresh, AsyncCallback callback, object state)
        {
            AsyncIteratorContext <NoResults> asyncIteratorContext = new AsyncIteratorContext <NoResults>("DbBlobContainer.GetProperties", callback, state);

            asyncIteratorContext.Begin(this.GetPropertiesImpl(propertyNames, condition, asyncIteratorContext));
            return(asyncIteratorContext);
        }
Beispiel #21
0
        private IEnumerator <IAsyncResult> AuthenticateImpl(IStorageAccount storageAccount, RequestContext requestContext, NephosUriComponents uriComponents, AuthenticationManager.GetStringToSignCallback getStringToSignCallback, TimeSpan timeout, AsyncIteratorContext <IAuthenticationResult> context)
        {
            bool flag;
            bool flag1;
            SignedAccessHelper   queueSignedAccessHelper;
            IStorageAccount      operationStatus;
            ContainerAclSettings containerAclSetting;
            string              signedVersion   = null;
            Duration            startingNow     = Duration.StartingNow;
            NameValueCollection queryParameters = requestContext.QueryParameters;

            if (AuthenticationManager.IsInvalidAccess(requestContext))
            {
                throw new InvalidAuthenticationInfoException("Ambiguous authentication scheme credentials providedRequest contains authentication credentials for signed access and authenticated access");
            }
            bool flag2 = AuthenticationManager.IsAuthenticatedAccess(requestContext);
            bool flag3 = AuthenticationManager.IsSignatureAccess(requestContext);

            flag = (!flag2 ? false : AuthenticationManager.IsAuthenticatedAccess(requestContext, "SignedKey"));
            bool flag4 = flag;

            flag1 = (flag2 ? false : !flag3);
            if ((!flag2 || flag4) && !flag1)
            {
                NephosAssertionException.Assert((flag3 ? true : flag4));
                bool flag5 = (flag3 ? false : flag4);
                if (!AuthenticationManager.IsAccountSasAccess(requestContext.QueryParameters))
                {
                    queueSignedAccessHelper = new QueueSignedAccessHelper(requestContext, uriComponents, flag5);
                }
                else
                {
                    if (flag5)
                    {
                        throw new AuthenticationFailureException("SignedKey is not supported with account-level SAS.");
                    }
                    queueSignedAccessHelper = new AccountSasHelper(requestContext, uriComponents);
                }
                queueSignedAccessHelper.ParseAccessPolicyFields(flag5);
                queueSignedAccessHelper.PerformSignedAccessAuthenticationFirstPhaseValidations();
                AccountIdentifier signedAccessAccountIdentifier = null;
                if (!flag5)
                {
                    byte[] sign = queueSignedAccessHelper.ComputeUrlDecodedUtf8EncodedStringToSign();
                    if (storageAccount == null || !string.Equals(storageAccount.Name, uriComponents.AccountName))
                    {
                        try
                        {
                            operationStatus = this.storageManager.CreateAccountInstance(uriComponents.AccountName);
                            if (requestContext != null)
                            {
                                operationStatus.OperationStatus = requestContext.OperationStatus;
                            }
                        }
                        catch (ArgumentOutOfRangeException argumentOutOfRangeException)
                        {
                            throw new AuthenticationFailureException(string.Format(CultureInfo.InvariantCulture, "The account name is invalid.", new object[0]));
                        }
                        operationStatus.Timeout = startingNow.Remaining(timeout);
                        IAsyncResult asyncResult = operationStatus.BeginGetProperties(AccountPropertyNames.All, null, context.GetResumeCallback(), context.GetResumeState("XFEQueueAuthenticationManager.AuthenticateImpl"));
                        yield return(asyncResult);

                        try
                        {
                            operationStatus.EndGetProperties(asyncResult);
                        }
                        catch (AccountNotFoundException accountNotFoundException1)
                        {
                            AccountNotFoundException accountNotFoundException = accountNotFoundException1;
                            CultureInfo invariantCulture = CultureInfo.InvariantCulture;
                            object[]    name             = new object[] { operationStatus.Name };
                            throw new AuthenticationFailureException(string.Format(invariantCulture, "Cannot find the claimed account when trying to GetProperties for the account {0}.", name), accountNotFoundException);
                        }
                        catch (Exception exception1)
                        {
                            Exception exception            = exception1;
                            IStringDataEventStream warning = Logger <IRestProtocolHeadLogger> .Instance.Warning;
                            object[] objArray = new object[] { operationStatus.Name, exception };
                            warning.Log("Rethrow exception when trying to GetProperties for the account {0}: {1}", objArray);
                            throw;
                        }
                    }
                    else
                    {
                        operationStatus = storageAccount;
                    }
                    if (!queueSignedAccessHelper.ComputeSignatureAndCompare(sign, operationStatus.SecretKeysV3))
                    {
                        throw new AuthenticationFailureException(string.Concat("Signature did not match. String to sign used was ", (new UTF8Encoding()).GetString(sign)));
                    }
                    NephosAssertionException.Assert(queueSignedAccessHelper.KeyUsedForSigning != null, "Key used for signing cannot be null");
                    signedAccessAccountIdentifier = queueSignedAccessHelper.CreateAccountIdentifier(operationStatus);
                    if (storageAccount != operationStatus)
                    {
                        operationStatus.Dispose();
                    }
                }
                else
                {
                    IAsyncResult asyncResult1 = this.nephosAuthenticationManager.BeginAuthenticate(storageAccount, requestContext, uriComponents, getStringToSignCallback, startingNow.Remaining(timeout), context.GetResumeCallback(), context.GetResumeState("XFEQueueAuthenticationManager.AuthenticateImpl"));
                    yield return(asyncResult1);

                    IAuthenticationResult authenticationResult = this.nephosAuthenticationManager.EndAuthenticate(asyncResult1);
                    signedAccessAccountIdentifier = new SignedAccessAccountIdentifier(authenticationResult.AccountIdentifier);
                }
                signedVersion = queueSignedAccessHelper.SignedVersion;
                if (queueSignedAccessHelper.IsRevocableAccess)
                {
                    using (IQueueContainer queueContainer = this.storageManager.CreateQueueContainerInstance(uriComponents.AccountName, uriComponents.ContainerName))
                    {
                        if (requestContext != null)
                        {
                            queueContainer.OperationStatus = requestContext.OperationStatus;
                        }
                        ContainerPropertyNames containerPropertyName = ContainerPropertyNames.ServiceMetadata;
                        queueContainer.Timeout = startingNow.Remaining(timeout);
                        IAsyncResult asyncResult2 = queueContainer.BeginGetProperties(containerPropertyName, null, context.GetResumeCallback(), context.GetResumeState("XFEQueueAuthenticationManager.AuthenticateImpl"));
                        yield return(asyncResult2);

                        try
                        {
                            queueContainer.EndGetProperties(asyncResult2);
                        }
                        catch (Exception exception3)
                        {
                            Exception exception2 = exception3;
                            if (exception2 is ContainerNotFoundException)
                            {
                                throw new AuthenticationFailureException("Error locating SAS identifier", exception2);
                            }
                            IStringDataEventStream stringDataEventStream = Logger <IRestProtocolHeadLogger> .Instance.Warning;
                            object[] accountName = new object[] { uriComponents.AccountName, uriComponents.ContainerName, exception2 };
                            stringDataEventStream.Log("Rethrow exception when trying to fetch SAS identifier account {0} container {1} : {2}", accountName);
                            throw;
                        }
                        try
                        {
                            containerAclSetting = new ContainerAclSettings(queueContainer.ServiceMetadata);
                        }
                        catch (MetadataFormatException metadataFormatException1)
                        {
                            MetadataFormatException metadataFormatException = metadataFormatException1;
                            throw new NephosStorageDataCorruptionException(string.Format("Error decoding Acl setting for container {0}", uriComponents.ContainerName), metadataFormatException);
                        }
                    }
                    try
                    {
                        queueSignedAccessHelper.ValidateAndDeriveEffectiveAccessPolicy(queueSignedAccessHelper.LocateSasIdentifier(containerAclSetting.SASIdentifiers));
                        queueSignedAccessHelper.PerformSignedAccessAuthenticationSecondPhaseValidations();
                        signedAccessAccountIdentifier.Initialize(queueSignedAccessHelper);
                        context.ResultData = new AuthenticationResult(signedAccessAccountIdentifier, signedVersion, true);
                    }
                    catch (FormatException formatException)
                    {
                        throw new AuthenticationFailureException("Signature fields not well formed.", formatException);
                    }
                }
                else
                {
                    signedAccessAccountIdentifier.Initialize(queueSignedAccessHelper);
                    context.ResultData = new AuthenticationResult(signedAccessAccountIdentifier, signedVersion, true);
                }
            }
            else
            {
                IAsyncResult asyncResult3 = this.nephosAuthenticationManager.BeginAuthenticate(storageAccount, requestContext, uriComponents, getStringToSignCallback, startingNow.Remaining(timeout), context.GetResumeCallback(), context.GetResumeState("XFEQueueAuthenticationManager.AuthenticateImpl"));
                yield return(asyncResult3);

                context.ResultData = this.nephosAuthenticationManager.EndAuthenticate(asyncResult3);
            }
        }