Esempio n. 1
0
        public void Decode(string sasIdentifier)
        {
            ASCIIEncoding   aSCIIEncoding   = new ASCIIEncoding();
            UnicodeEncoding unicodeEncoding = new UnicodeEncoding();

            SASUtilities.ValidateACIIEncoding(sasIdentifier);
            NameValueCollection nameValueCollection = new NameValueCollection();

            MetadataEncoding.Decode(aSCIIEncoding.GetBytes(sasIdentifier), nameValueCollection);
            string item  = nameValueCollection[SASIdentifier.IdName];
            string str   = nameValueCollection[SASAccessPolicy.SignedStartName];
            string item1 = nameValueCollection[SASAccessPolicy.SignedExpiryName];
            string str1  = nameValueCollection[SASAccessPolicy.SignedPermissionName];

            if (!string.IsNullOrEmpty(item))
            {
                this.Id = unicodeEncoding.GetString(Convert.FromBase64String(item));
            }
            if (!string.IsNullOrEmpty(str))
            {
                this.AccessPolicy.SignedStart = new DateTime?(SASUtilities.ParseTime(str));
            }
            if (!string.IsNullOrEmpty(item1))
            {
                this.AccessPolicy.SignedExpiry = new DateTime?(SASUtilities.ParseTime(item1));
            }
            if (!string.IsNullOrEmpty(str1))
            {
                this.AccessPolicy.SignedPermission = new SASPermission?(SASUtilities.ParseSASPermission(str1));
            }
        }
Esempio n. 2
0
        public static List <SASIdentifier> DecodeSASIdentifiers(string sasIdentifiersValue)
        {
            ASCIIEncoding aSCIIEncoding = new ASCIIEncoding();

            if (sasIdentifiersValue == null)
            {
                throw new ArgumentNullException("sasIdentifiersValue");
            }
            SASUtilities.ValidateACIIEncoding(sasIdentifiersValue);
            sasIdentifiersValue = aSCIIEncoding.GetString(Convert.FromBase64String(sasIdentifiersValue));
            List <SASIdentifier> sASIdentifiers = new List <SASIdentifier>();

            using (StringReader stringReader = new StringReader(sasIdentifiersValue))
            {
                string str = null;
                while (true)
                {
                    string str1 = stringReader.ReadLine();
                    str = str1;
                    if (str1 == null)
                    {
                        break;
                    }
                    str = str.Trim();
                    if (str.Length != 0)
                    {
                        string        str2          = aSCIIEncoding.GetString(Convert.FromBase64String(str));
                        SASIdentifier sASIdentifier = new SASIdentifier();
                        sASIdentifier.Decode(str2);
                        sASIdentifiers.Add(sASIdentifier);
                    }
                }
            }
            return(sASIdentifiers);
        }