Beispiel #1
0
 public void JustDecompileGenerated_set_ContainerAcl(ContainerAclSettings value)
 {
     this.JustDecompileGenerated_ContainerAcl_k__BackingField = value;
 }
Beispiel #2
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);
                }
            }
        }
Beispiel #3
0
        public IAsyncResult BeginSetTableAcl(IAccountIdentifier identifier, string account, string tableName, ContainerAclSettings acl, TimeSpan timeout, RequestContext requestContext, AsyncCallback callback, object state)
        {
            AsyncIteratorContext <NoResults> asyncIteratorContext = new AsyncIteratorContext <NoResults>("TableManager.SetTableAcl", callback, state);

            asyncIteratorContext.Begin(this.SetTableAclImpl(identifier, account, tableName, acl, timeout, requestContext, asyncIteratorContext));
            return(asyncIteratorContext);
        }
Beispiel #4
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);
        }
Beispiel #5
0
 protected abstract IEnumerator <IAsyncResult> SetQueueAclImpl(IAccountIdentifier identifier, string account, string queue, ContainerAclSettings acl, TimeSpan timeout, RequestContext requestContext, AsyncIteratorContext <NoResults> context);
Beispiel #6
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);
            }
        }
Beispiel #7
0
 public abstract DateTime EndGetContainerAcl(IAsyncResult ar, out ContainerAclSettings acl);
Beispiel #8
0
 public abstract IAsyncResult BeginSetContainerAcl(IAccountIdentifier identifier, string account, string container, ContainerAclSettings acl, DateTime?ifModifiedSince, DateTime?ifNotModifiedSince, Guid?leaseId, TimeSpan timeout, RequestContext requestContext, AsyncCallback callback, object state);