示例#1
0
        public override string ParseAccountNameFromAuthorizationHeader(RequestContext requestContext, NephosUriComponents uriComponents)
        {
            SupportedAuthScheme?nullable;
            string str  = null;
            string str1 = null;
            bool   flag = false;

            NephosAuthenticationManager.ParseSignatureParametersFromAuthorizationHeader(requestContext, uriComponents, true, out str, out str1, out nullable, out flag);
            return(str);
        }
示例#2
0
 private XFEQueueAuthenticationManager(IStorageManager manager)
 {
     this.storageManager = manager;
     this.nephosAuthenticationManager = NephosAuthenticationManager.CreateAuthenticationManager(manager) as NephosAuthenticationManager;
     NephosAssertionException.Assert(this.nephosAuthenticationManager != null);
 }
示例#3
0
        private IEnumerator <IAsyncResult> AuthenticateImpl(IStorageAccount storageAccount, RequestContext requestContext, NephosUriComponents uriComponents, AuthenticationManager.GetStringToSignCallback getStringToSignCallback, TimeSpan timeout, AsyncIteratorContext <IAuthenticationResult> context)
        {
            SupportedAuthScheme?nullable;
            IStorageAccount     operationStatus;

            context.ResultData = null;
            if (getStringToSignCallback == null)
            {
                throw new ArgumentNullException("getStringToSignCallback");
            }
            string str  = null;
            string str1 = null;
            bool   flag = false;

            NephosAuthenticationManager.ParseSignatureParametersFromAuthorizationHeader(requestContext, uriComponents, false, out str, out str1, out nullable, out flag);
            if (!flag)
            {
                NephosAssertionException.Assert(nullable.HasValue, "Request Authentication Scheme should have a value");
                IAccountIdentifier        accountIdentifier = null;
                AuthenticationInformation authInfoForScheme = null;
                if (this.storageManager != null)
                {
                    if (storageAccount == null || !storageAccount.Name.Equals(str))
                    {
                        try
                        {
                            operationStatus = this.storageManager.CreateAccountInstance(str);
                            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 = timeout;
                        IAsyncResult asyncResult = operationStatus.BeginGetProperties(AccountPropertyNames.All, null, context.GetResumeCallback(), context.GetResumeState("NephosAuthenticationManager.AuthenticateImpl"));
                        yield return(asyncResult);

                        try
                        {
                            operationStatus.EndGetProperties(asyncResult);
                        }
                        catch (AccountNotFoundException accountNotFoundException1)
                        {
                            AccountNotFoundException accountNotFoundException = accountNotFoundException1;
                            CultureInfo invariantCulture = CultureInfo.InvariantCulture;
                            object[]    objArray         = new object[] { str };
                            throw new AuthenticationFailureException(string.Format(invariantCulture, "Cannot find the claimed account when trying to GetProperties for the account {0}.", objArray), accountNotFoundException);
                        }
                        catch (Exception exception1)
                        {
                            Exception exception            = exception1;
                            IStringDataEventStream warning = Logger <IRestProtocolHeadLogger> .Instance.Warning;
                            warning.Log("Rethrow exception when trying to GetProperties for the account {0}: {1}", new object[] { str, exception });
                            throw;
                        }
                    }
                    else
                    {
                        operationStatus = storageAccount;
                        if (requestContext != null)
                        {
                            operationStatus.OperationStatus = requestContext.OperationStatus;
                        }
                    }
                    authInfoForScheme = NephosAuthenticationManager.GetAuthInfoForScheme(operationStatus, nullable.Value, requestContext, uriComponents, false);
                    if (authInfoForScheme == null)
                    {
                        if (storageAccount != operationStatus)
                        {
                            operationStatus.Dispose();
                        }
                        CultureInfo cultureInfo = CultureInfo.InvariantCulture;
                        object[]    name        = new object[] { nullable, operationStatus.Name };
                        throw new AuthenticationFailureException(string.Format(cultureInfo, "Authentication scheme {0} is not supported by account {1}.", name));
                    }
                    SecretKeyPermissions permissions = SecretKeyPermissions.Full;
                    if (authInfoForScheme.NamedKeyAuthData != null)
                    {
                        permissions = authInfoForScheme.NamedKeyAuthData.Permissions;
                    }
                    accountIdentifier = new AccountIdentifier(operationStatus, permissions);
                    if (storageAccount != operationStatus)
                    {
                        operationStatus.Dispose();
                    }
                }
                string str2 = null;
                try
                {
                    str2 = getStringToSignCallback(requestContext, uriComponents, nullable.Value);
                }
                catch (NotSupportedException notSupportedException)
                {
                    CultureInfo invariantCulture1 = CultureInfo.InvariantCulture;
                    object[]    objArray1         = new object[] { nullable };
                    throw new AuthenticationFailureException(string.Format(invariantCulture1, "Authentication scheme {0} is not supported.", objArray1));
                }
                AuthenticationMethod item = NephosAuthenticationManager.serviceAuthMethodsTable[requestContext.ServiceType][nullable.Value];
                item(str2, str1, authInfoForScheme);
                NephosAssertionException.Assert(accountIdentifier != null);
                context.ResultData = new AuthenticationResult(accountIdentifier, null, false);
            }
            else
            {
                context.ResultData = new AuthenticationResult(AuthenticationManager.AnonymousAccount, null, false);
            }
        }