Beispiel #1
0
            private string GetFullClassName(string className)
            {
                StringBuilder b = new StringBuilder(50);

                b.Append(Application.WindowsFormsVersion);
                b.Append('.');
                b.Append(className);

                // While we don't have multiple AppDomains any more, we'll still include the information
                // to keep the names in the same historical format for now.

                b.Append(".app.0.");

                // VersioningHelper does a lot of string allocations, and on .NET Core for our purposes
                // it always returns the exact same string (process is hardcoded to r3 and the AppDomain
                // id is always 1 as there is only one AppDomain).

                const string versionSuffix = "_r3_ad1";

                Debug.Assert(string.Equals(
                                 VersioningHelper.MakeVersionSafeName(s_currentAppDomainHash, ResourceScope.Process, ResourceScope.AppDomain),
                                 s_currentAppDomainHash + versionSuffix));
                b.Append(s_currentAppDomainHash);
                b.Append(versionSuffix);

                return(b.ToString());
            }
Beispiel #2
0
        public static byte[] ComputeUrlDecodedUtf8EncodedStringToSign(string st, string se, string sp, string si, string sip, string spr, string sv, string sep, NephosUriComponents uriComponents)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append(sp ?? string.Empty);
            stringBuilder.Append("\n");
            stringBuilder.Append(st ?? string.Empty);
            stringBuilder.Append("\n");
            stringBuilder.Append(se ?? string.Empty);
            stringBuilder.Append("\n");
            stringBuilder.Append(QueueSignedAccessHelper.GetCanonicalizedResource(uriComponents, sv));
            stringBuilder.Append("\n");
            stringBuilder.Append(si ?? string.Empty);
            stringBuilder.Append("\n");
            if (!VersioningHelper.IsPreApril15OrInvalidVersion(sv))
            {
                stringBuilder.Append(sip ?? string.Empty);
                stringBuilder.Append("\n");
                stringBuilder.Append(spr ?? string.Empty);
                stringBuilder.Append("\n");
            }
            stringBuilder.Append(sv ?? string.Empty);
            if (sep != null)
            {
                stringBuilder.Append("\n");
                stringBuilder.Append(sep);
            }
            return((new UTF8Encoding()).GetBytes(stringBuilder.ToString()));
        }
Beispiel #3
0
 public TableDataServiceBase(TableProtocolHead tableProtocolHead, IAccountIdentifier identifier, IUtilityTableDataContextFactory factory, bool operationIsConditional, Dictionary <string, string> continuationToken, RequestStartedCallback requestStartedCallback, CheckPermissionDelegate checkPermissionCallback, QueryRowCommandPropertiesAvailableCallback queryRowCommandPropertiesAvailableCallback, ContinuationTokenAvailableCallback continuationTokenAvailableCallback)
 {
     if (factory == null)
     {
         throw new ArgumentNullException("factory");
     }
     if (tableProtocolHead == null)
     {
         throw new ArgumentNullException("tableProtocolHead");
     }
     this.dataSource            = factory.CreateDataContext(identifier, tableProtocolHead.ServiceOperationContext.AccountName, tableProtocolHead.RequestRestVersion);
     this.dataSource.ApiVersion = tableProtocolHead.RequestRestVersion;
     this.dataSource.OldMetricsTableNamesDeprecated = tableProtocolHead.IsRequestVersionAtLeast("2013-08-15");
     this.dataSource.IsBatchRequest          = tableProtocolHead.IsBatchRequest();
     this.dataSource.OperationIsConditional  = operationIsConditional;
     this.dataSource.ContinuationToken       = continuationToken;
     this.dataSource.RequestStartedCallback  = requestStartedCallback;
     this.dataSource.CheckPermissionCallback = checkPermissionCallback;
     this.dataSource.QueryRowCommandPropertiesAvailableCallback = queryRowCommandPropertiesAvailableCallback;
     this.dataSource.ContinuationTokenAvailableCallback         = continuationTokenAvailableCallback;
     this.tableProtocolHead = tableProtocolHead;
     if (VersioningHelper.CompareVersions(tableProtocolHead.RequestRestVersion, "2016-05-31") >= 0)
     {
         this.dataSource.Timeout = tableProtocolHead.operationContext.RemainingTimeout();
     }
 }
Beispiel #4
0
        public async Task WillFilterMetadataPropertiesStartingWithAt()
        {
            var company = new Company {
                Name = "Company Name"
            };

            using (var store = GetDocumentStore())
            {
                await VersioningHelper.SetupVersioning(store);

                using (var session = store.OpenAsyncSession())
                {
                    await session.StoreAsync(company);

                    session.Advanced.GetMetadataFor(company)["@foo"] = "bar";
                    await session.SaveChangesAsync();
                }
                using (var session = store.OpenAsyncSession())
                {
                    var company3 = await session.LoadAsync <Company>(company.Id);

                    Assert.Null(session.Advanced.GetMetadataFor(company3).Value <string>("@foo"));
                }
            }
        }
Beispiel #5
0
        public bool ProcessConditionalHeader(ConditionalHeaders condHeaders, NameValueCollection requestHeaders, OperationTypeForConditionParsing operationType, string requestVersion, ConditionInformation outputCondition)
        {
            bool?nullable;

            if (!string.IsNullOrEmpty(condHeaders.IfRange))
            {
                return(false);
            }
            if (string.IsNullOrEmpty(condHeaders.IfMatch))
            {
                return(false);
            }
            outputCondition.ConditionFailStatusCode = HttpStatusCode.PreconditionFailed;
            outputCondition.ResourceExistsCondition = new ResourceExistenceCondition?(ResourceExistenceCondition.MustExist);
            string ifMatch = condHeaders.IfMatch;

            string[]        strArrays  = new string[] { "," };
            string[]        strArrays1 = ifMatch.Split(strArrays, StringSplitOptions.RemoveEmptyEntries);
            List <DateTime> dateTimes  = new List <DateTime>();

            string[] strArrays2 = strArrays1;
            for (int i = 0; i < (int)strArrays2.Length; i++)
            {
                string str = strArrays2[i];
                if (Comparison.StringEqualsIgnoreCase(str, "*"))
                {
                    return(false);
                }
                try
                {
                    dateTimes.Add(BasicHttpProcessor.GetLastModifiedTimeFromETag(str));
                }
                catch (InvalidHeaderProtocolException invalidHeaderProtocolException1)
                {
                    InvalidHeaderProtocolException invalidHeaderProtocolException = invalidHeaderProtocolException1;
                    if (!VersioningHelper.IsPreSeptember09OrInvalidVersion(requestVersion))
                    {
                        if (operationType == OperationTypeForConditionParsing.CopyOperation)
                        {
                            nullable = new bool?(false);
                        }
                        else
                        {
                            nullable = null;
                        }
                        throw new UnrecognizedIfMatchConditionException(nullable, invalidHeaderProtocolException);
                    }
                    throw;
                }
            }
            if (dateTimes.Count > 0)
            {
                outputCondition.IfMatch = dateTimes.ToArray();
            }
            if (outputCondition != null && (int)outputCondition.IfMatch.Length > 0)
            {
                return(true);
            }
            return(false);
        }
Beispiel #6
0
 public static Version BuildVersion(Assembly assembly)
 {
     return(new Version(
                // VersionNumber
                VersioningHelper.VersionNumber(assembly),
                // LastBuildOccurred
                VersioningHelper.BuildDate(assembly)
                ));
 }
Beispiel #7
0
    private static string getAppDomainFriendlyName()
    {
        string friendlyName = AppDomain.CurrentDomain.FriendlyName;

        if ((friendlyName == null) || (friendlyName.Length <= 0))
        {
            friendlyName = "AppDomain.H" + AppDomain.CurrentDomain.GetHashCode();
        }
        return(VersioningHelper.MakeVersionSafeName(friendlyName, ResourceScope.Machine, ResourceScope.AppDomain));
    }
Beispiel #8
0
        public static bool IsAccountSasAccess(NameValueCollection queryParameters)
        {
            string item = queryParameters["sv"];

            if (string.IsNullOrWhiteSpace(queryParameters["ss"]))
            {
                return(false);
            }
            return(!VersioningHelper.IsPreApril15OrInvalidVersion(item));
        }
Beispiel #9
0
        public static void MakeVersionSafeNameTest()
        {
            string str1 = VersioningHelper.MakeVersionSafeName("TestFile", ResourceScope.Process, ResourceScope.AppDomain);

#if uapaot
            Assert.NotNull(str1);
#else
            Assert.Equal($"TestFile_r3_ad{AppDomain.CurrentDomain.Id}", str1);
#endif
        }
Beispiel #10
0
        public void ConvertTo_Process()
        {
            // if process is present in "from" then the ouput is unchanged
            Assert.AreEqual("a", VersioningHelper.MakeVersionSafeName("a", ResourceScope.Process, ResourceScope.Library), "1a");
            Assert.AreEqual("a", VersioningHelper.MakeVersionSafeName("a", ResourceScope.Process, ResourceScope.Process), "1b");
            Assert.AreEqual("a", VersioningHelper.MakeVersionSafeName("a", ResourceScope.Process, ResourceScope.Process | ResourceScope.Library), "1c");

            // if "from" doesn't have process then the process id is appended
            Assert.IsTrue(VersioningHelper.MakeVersionSafeName("a", ResourceScope.Machine, ResourceScope.Process).StartsWith("a_"), "2");
        }
Beispiel #11
0
        public void ConvertTo_AppDomain()
        {
            // if appdomain is present in "from" then the ouput is unchanged
            Assert.AreEqual("a", VersioningHelper.MakeVersionSafeName("a", ResourceScope.AppDomain, ResourceScope.Library), "1a");
            Assert.AreEqual("a", VersioningHelper.MakeVersionSafeName("a", ResourceScope.AppDomain, ResourceScope.AppDomain), "1b");
            Assert.AreEqual("a", VersioningHelper.MakeVersionSafeName("a", ResourceScope.AppDomain, ResourceScope.AppDomain | ResourceScope.Machine), "1c");

            // if "from" doesn't have appdomain then the appdomain id is appended
            Assert.IsTrue(VersioningHelper.MakeVersionSafeName("a", ResourceScope.Machine, ResourceScope.AppDomain).StartsWith("a_"), "2");
        }
Beispiel #12
0
        public virtual void ParseAccessPolicyFields(bool isDoubleSigned)
        {
            string item = this.QueryParams["st"];

            this.ValidateOptionalField(item, "st");
            if (item != null)
            {
                this.SignedStart = new DateTime?(SASUtilities.ParseTime(item));
            }
            string str = this.QueryParams["se"];

            if (!this.IsRevocableAccess)
            {
                this.ValidateMandatoryField(str, "se");
                this.SignedExpiry = new DateTime?(SASUtilities.ParseTime(str));
            }
            else
            {
                this.ValidateOptionalField(str, "se");
                if (str != null)
                {
                    this.SignedExpiry = new DateTime?(SASUtilities.ParseTime(str));
                }
            }
            if (!VersioningHelper.IsPreApril15OrInvalidVersion(this.SignedVersion))
            {
                string item1 = this.QueryParams["sip"];
                this.ValidateOptionalField(item1, "sip");
                if (item1 != null)
                {
                    try
                    {
                        this.SignedIP = SASUtilities.ParseSip(item1);
                    }
                    catch (ArgumentOutOfRangeException argumentOutOfRangeException)
                    {
                        throw new FormatException("Invalid sip format", argumentOutOfRangeException);
                    }
                }
                string str1 = this.QueryParams["spr"];
                this.ValidateOptionalField(str1, "spr");
                if (str1 != null)
                {
                    this.SignedProtocol = SASUtilities.ParseSignedProtocol(str1);
                }
            }
            string item2 = this.QueryParams["sep"];

            this.ValidateOptionalField(item2, "sep");
            if (item2 != null)
            {
                this.SignedExtraPermission = SASUtilities.ParseExtraPermission(item2);
            }
        }
        private static string GetInstanceName()
        {
            string str  = ReplaceInvalidChars(AppDomain.CurrentDomain.FriendlyName);
            string str2 = VersioningHelper.MakeVersionSafeName(string.Empty, ResourceScope.Machine, ResourceScope.AppDomain);
            string str3 = str + str2;

            if (str3.Length > 0x7f)
            {
                str3 = str.Substring(0, 0x7f - str2.Length) + str2;
            }
            return(str3);
        }
Beispiel #14
0
 private void ValidateAndSetSASVersionToUse(string sasVersion)
 {
     if (string.IsNullOrWhiteSpace(sasVersion))
     {
         throw new AuthenticationFailureException("sv is mandatory. Cannot be empty");
     }
     if (VersioningHelper.IsPreApril15OrInvalidVersion(sasVersion))
     {
         throw new AuthenticationFailureException(string.Format("{0} is either not in the correct format or is not equal or later than version {1}", "sv", "2015-04-05"));
     }
     base.SignedVersion = sasVersion;
 }
Beispiel #15
0
        public string GetCounterInstanceNameForCurrentProcess(PerformanceCounterConfiguration counterConfiguration)
        {
            Requires.NotNull(counterConfiguration, nameof(counterConfiguration));

            var    key = new CacheKey(counterConfiguration.ProcessIdCounterCategory, counterConfiguration.ProcessIdCounterName);
            string instanceName;

            if (this.instanceNames.TryGetValue(key, out instanceName))
            {
                return(instanceName);
            }

            Process currentProcess = Process.GetCurrentProcess();

            if (counterConfiguration.UseDotNetInstanceNameConvention)
            {
                instanceName = VersioningHelper.MakeVersionSafeName(currentProcess.ProcessName, ResourceScope.Machine, ResourceScope.AppDomain);
                // We actually don't need the AppDomain portion, but there is no way to get the runtime ID without AppDomain id attached.
                // So we just filter it out
                int adIdIndex = instanceName.LastIndexOf("_ad");
                if (adIdIndex > 0)
                {
                    instanceName = instanceName.Substring(0, adIdIndex);
                }
                this.instanceNames[key] = instanceName;
                return(instanceName);
            }
            else
            {
                PerformanceCounterCategory category = new PerformanceCounterCategory(counterConfiguration.ProcessIdCounterCategory);

                string[] processInstanceNames = category.GetInstanceNames()
                                                .Where(inst => inst.StartsWith(currentProcess.ProcessName))
                                                .ToArray();

                foreach (string processInstanceName in processInstanceNames)
                {
                    using (PerformanceCounter cnt = new PerformanceCounter(counterConfiguration.ProcessIdCounterCategory, counterConfiguration.ProcessIdCounterName, processInstanceName, readOnly: true))
                    {
                        int val = (int)cnt.RawValue;
                        if (val == currentProcess.Id)
                        {
                            this.instanceNames[key] = processInstanceName;
                            return(processInstanceName);
                        }
                    }
                }
            }

            this.instanceNames[key] = null;
            return(null);
        }
        private static string GetInstanceName()
        {
            string friendlyName = ReplaceInvalidChars(AppDomain.CurrentDomain.FriendlyName);
            string postfix      = VersioningHelper.MakeVersionSafeName(string.Empty, ResourceScope.Machine, ResourceScope.AppDomain);

            string result = friendlyName + postfix;

            if (result.Length > INSTANCE_NAME_MAX_LENGTH)
            {
                result = friendlyName.Substring(0, INSTANCE_NAME_MAX_LENGTH - postfix.Length) + postfix;
            }

            return(result);
        }
Beispiel #17
0
 public void ToNameValues(out NameValueCollection nameValues)
 {
     nameValues = new NameValueCollection();
     if (VersioningHelper.IsPreSeptember09OrInvalidVersion(this.version))
     {
         bool publicAccess = this.PublicAccess;
         nameValues.Add("PublicAccess", publicAccess.ToString(CultureInfo.InvariantCulture));
     }
     else if (!string.IsNullOrEmpty(this.publicAccessLevel))
     {
         nameValues.Add("PublicAccess1", this.publicAccessLevel.ToString(CultureInfo.InvariantCulture));
     }
     nameValues.Add("SASIdentifiers", SASUtilities.EncodeSASIdentifiers(this.sasIdentifiers));
 }
Beispiel #18
0
        public override byte[] ComputeUrlDecodedUtf8EncodedStringToSign()
        {
            StringBuilder stringBuilder = new StringBuilder();

            if (base.SignedPermission.HasValue)
            {
                stringBuilder.Append(base.QueryParams["sp"]);
            }
            stringBuilder.Append("\n");
            if (base.SignedStart.HasValue)
            {
                stringBuilder.Append(base.QueryParams["st"]);
            }
            stringBuilder.Append("\n");
            if (base.SignedExpiry.HasValue)
            {
                stringBuilder.Append(base.QueryParams["se"]);
            }
            stringBuilder.Append("\n");
            stringBuilder.Append(QueueSignedAccessHelper.GetCanonicalizedResource(base.UriComponents, base.SignedVersion));
            stringBuilder.Append("\n");
            if (base.SignedIdentifier != null)
            {
                stringBuilder.Append(base.QueryParams["si"]);
            }
            stringBuilder.Append("\n");
            if (!VersioningHelper.IsPreApril15OrInvalidVersion(base.SignedVersion))
            {
                string item = base.QueryParams["sip"];
                if (item != null)
                {
                    stringBuilder.Append(item);
                }
                stringBuilder.Append("\n");
                string str = base.QueryParams["spr"];
                if (str != null)
                {
                    stringBuilder.Append(str);
                }
                stringBuilder.Append("\n");
            }
            stringBuilder.Append(base.QueryParams["sv"]);
            if (base.SignedExtraPermission.HasValue)
            {
                stringBuilder.Append("\n");
                stringBuilder.Append(base.QueryParams["sep"]);
            }
            return((new UTF8Encoding()).GetBytes(stringBuilder.ToString()));
        }
Beispiel #19
0
            private string GetFullClassName(string className)
            {
                StringBuilder builder = new StringBuilder(50);

                builder.Append(Application.WindowsFormsVersion);
                builder.Append('.');
                builder.Append(className);
                builder.Append(".app.");
                builder.Append(domainQualifier);
                builder.Append('.');
                string name = Convert.ToString(AppDomain.CurrentDomain.GetHashCode(), 0x10);

                builder.Append(VersioningHelper.MakeVersionSafeName(name, ResourceScope.Process, ResourceScope.AppDomain));
                return(builder.ToString());
            }
Beispiel #20
0
 protected override void EncodeInitialElements(Uri requestUrl, ListContainersOperationContext loc, IListContainersResultCollection result, XmlWriter xmlWriter)
 {
     xmlWriter.WriteStartElement("EnumerationResults");
     if (!VersioningHelper.IsPreAugust13OrInvalidVersion(loc.RequestVersion))
     {
         string str = string.Concat(HttpRequestAccessorCommon.TrimEndSlash(requestUrl.GetLeftPart(UriPartial.Path)), "/");
         xmlWriter.WriteAttributeString("ServiceEndpoint", str);
     }
     else
     {
         xmlWriter.WriteAttributeString("AccountName", requestUrl.GetLeftPart(UriPartial.Path));
     }
     XmlListEncoderHelpers.WriteListOperationInfoToXml(xmlWriter, loc);
     xmlWriter.WriteStartElement(this.XmlContainersElementName);
 }
Beispiel #21
0
        private static string GetCanonicalizedResource(NephosUriComponents uriComponents, string tableName, string signedVersion)
        {
            NephosAssertionException.Assert(!string.IsNullOrEmpty(uriComponents.AccountName));
            NephosAssertionException.Assert(!string.IsNullOrEmpty(tableName));
            StringBuilder stringBuilder = new StringBuilder();

            if (signedVersion != null && VersioningHelper.CompareVersions(signedVersion, "2015-02-21") >= 0)
            {
                stringBuilder.Append("/table");
            }
            stringBuilder.Append("/");
            stringBuilder.Append(uriComponents.AccountName);
            stringBuilder.Append("/");
            stringBuilder.Append(tableName.ToLower());
            return(stringBuilder.ToString());
        }
Beispiel #22
0
        public void ConvertTo_AppDomain_Process()
        {
            // if the appdomain is present then the output is unchanged (process isn't appended)
            Assert.AreEqual("a", VersioningHelper.MakeVersionSafeName("a", ResourceScope.AppDomain, ResourceScope.AppDomain | ResourceScope.Process), "1a");
            // if the process is present then appdomain is appended to the output
            Assert.IsTrue(VersioningHelper.MakeVersionSafeName("a", ResourceScope.Process, ResourceScope.AppDomain | ResourceScope.Process).StartsWith("a_"), "1b");

            // if "from" doesn't have process nor appdomain then both id are appended
            string s  = VersioningHelper.MakeVersionSafeName("a", ResourceScope.Machine, ResourceScope.AppDomain);
            int    p1 = s.IndexOf("_");

            Assert.IsTrue((p1 > 0), "first _");
            int p2 = s.LastIndexOf("_");

            Assert.IsTrue(((p2 > 0) && (p2 != p1)), "second _");
        }
Beispiel #23
0
 protected override void EncodeInitialElements(Uri requestUrl, ListBlobsOperationContext lboc, IListBlobsResultCollection result, XmlWriter xmlWriter)
 {
     xmlWriter.WriteStartElement("EnumerationResults");
     if (!VersioningHelper.IsPreAugust13OrInvalidVersion(lboc.RequestVersion))
     {
         string str = HttpRequestAccessorCommon.TrimEndSlash(requestUrl.GetLeftPart(UriPartial.Path));
         int    num = str.LastIndexOf("/");
         xmlWriter.WriteAttributeString("ServiceEndpoint", str.Remove(num + 1));
         xmlWriter.WriteAttributeString("ContainerName", str.Substring(num + 1));
     }
     else
     {
         xmlWriter.WriteAttributeString("ContainerName", requestUrl.GetLeftPart(UriPartial.Path));
     }
     XmlListEncoderHelpers.WriteListOperationInfoToXml(xmlWriter, lboc);
     xmlWriter.WriteStartElement("Blobs");
 }
Beispiel #24
0
 // note: this one can be _very_ slow under a debugger due to the high number of exceptions
 public void MakeVersionSafeName()
 {
     for (int i = 0; i < 64; i++)
     {
         ResourceScope from = (ResourceScope)i;
         for (int j = 0; j < 64; j++)
         {
             ResourceScope to      = (ResourceScope)j;
             bool          valid   = IsValid((i << 6) | j);
             string        from_to = String.Format("From ({2}) {0} to ({3}) {1}", from, to, (int)from, (int)to);
             try {
                 string s = VersioningHelper.MakeVersionSafeName("a", from, to);
                 Assert.IsTrue(valid, from_to);
             }
             catch (ArgumentException) {
                 Assert.IsFalse(valid, from_to);
             }
         }
     }
 }
Beispiel #25
0
        public bool ProcessConditionalHeader(ConditionalHeaders condHeaders, NameValueCollection requestHeaders, OperationTypeForConditionParsing operationType, string requestVersion, ConditionInformation outputCondition)
        {
            if (!string.IsNullOrEmpty(condHeaders.IfRange))
            {
                return(false);
            }
            if (string.IsNullOrEmpty(condHeaders.IfNoneMatch))
            {
                return(false);
            }
            outputCondition.ConditionFailStatusCode = HttpStatusCode.NotModified;
            string ifNoneMatch = condHeaders.IfNoneMatch;

            string[]        strArrays  = new string[] { "," };
            string[]        strArrays1 = ifNoneMatch.Split(strArrays, StringSplitOptions.RemoveEmptyEntries);
            List <DateTime> dateTimes  = new List <DateTime>();

            string[] strArrays2 = strArrays1;
            for (int i = 0; i < (int)strArrays2.Length; i++)
            {
                string str = strArrays2[i];
                if (Comparison.StringEqualsIgnoreCase(str, "*"))
                {
                    if (!VersioningHelper.IsPreFebruary16OrInvalidVersion(requestVersion))
                    {
                        throw new UnsatisfiableConditionException();
                    }
                    return(false);
                }
                dateTimes.Add(BasicHttpProcessor.GetLastModifiedTimeFromETag(str));
            }
            if (dateTimes.Count > 0)
            {
                outputCondition.IfNoneMatch = dateTimes.ToArray();
            }
            if (outputCondition == null)
            {
                return(false);
            }
            return((int)outputCondition.IfNoneMatch.Length > 0);
        }
Beispiel #26
0
        private static string GetCanonicalizedResource(NephosUriComponents uriComponents, SASAccessLevel signedResource, string signedVersion)
        {
            NephosAssertionException.Assert(!string.IsNullOrEmpty(uriComponents.AccountName));
            NephosAssertionException.Assert(!string.IsNullOrEmpty(uriComponents.ContainerName));
            StringBuilder stringBuilder = new StringBuilder();

            if (signedVersion != null && VersioningHelper.CompareVersions(signedVersion, "2015-02-21") >= 0)
            {
                stringBuilder.Append("/blob");
            }
            stringBuilder.Append("/");
            stringBuilder.Append(uriComponents.AccountName);
            stringBuilder.Append("/");
            stringBuilder.Append(uriComponents.ContainerName);
            if (signedResource == SASAccessLevel.Blob)
            {
                NephosAssertionException.Assert(!string.IsNullOrEmpty(uriComponents.RemainingPart));
                stringBuilder.Append("/");
                stringBuilder.Append(uriComponents.RemainingPart);
            }
            return(stringBuilder.ToString());
        }
 private static string GetInstanceName()
 {
     return(VersioningHelper.MakeVersionSafeName("http2client.exe", ResourceScope.Machine, ResourceScope.AppDomain));
 }
Beispiel #28
0
 private void ValidateSASVersion(string sasVersion)
 {
     sasVersion = sasVersion.Trim();
     if (!VersioningConfigurationLookup.Instance.IsValidVersion(sasVersion) || VersioningHelper.CompareVersions(sasVersion, "2012-02-12") < 0)
     {
         FutureVersionProtocolException.ThrowIfFutureVersion(sasVersion);
         throw new AuthenticationFailureException(string.Format("{0} is either not in the correct format or is not equal or later than version {1}", "sv", "2012-02-12"));
     }
     base.SignedVersion = sasVersion;
 }
Beispiel #29
0
        public void Type_Null()
        {
            string s = VersioningHelper.MakeVersionSafeName(null, ResourceScope.AppDomain, ResourceScope.AppDomain, null);

            Assert.AreEqual(String.Empty, s, "Result");
        }
Beispiel #30
0
 public void To_Invalid()
 {
     ResourceScope bad = (ResourceScope)Int32.MinValue;
     string        s   = VersioningHelper.MakeVersionSafeName(null, ResourceScope.AppDomain, bad);
 }