예제 #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));
            }
        }
예제 #2
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);
            }
        }
예제 #3
0
 public SASAccessPolicy(string signedStart, string signedExpiry, string signedPermission)
 {
     if (!string.IsNullOrEmpty(signedStart))
     {
         this.SignedStart = new DateTime?(SASUtilities.ParseTime(signedStart));
     }
     if (!string.IsNullOrEmpty(signedExpiry))
     {
         this.SignedExpiry = new DateTime?(SASUtilities.ParseTime(signedExpiry));
     }
     if (!string.IsNullOrEmpty(signedPermission))
     {
         this.SignedPermission = new SASPermission?(SASUtilities.ParseSASPermission(signedPermission));
     }
 }