public SASIdentifier LocateSasIdentifier(List <SASIdentifier> sasIdentifiers) { SASIdentifier sASIdentifier; List <SASIdentifier> .Enumerator enumerator = sasIdentifiers.GetEnumerator(); try { while (enumerator.MoveNext()) { SASIdentifier current = enumerator.Current; if (string.IsNullOrEmpty(current.Id) || !current.Id.Equals(this.SignedIdentifier)) { continue; } sASIdentifier = current; return(sASIdentifier); } throw new AuthenticationFailureException("SAS identifier cannot be found for specified signed identifier"); } finally { ((IDisposable)enumerator).Dispose(); } return(sASIdentifier); }
public virtual void ValidateAndDeriveEffectiveAccessPolicy(SASIdentifier sasIdentifier) { NephosAssertionException.Assert(sasIdentifier.Id.Equals(this.SignedIdentifier)); if (!this.SignedExpiry.HasValue && !sasIdentifier.AccessPolicy.SignedExpiry.HasValue) { throw new AuthenticationFailureException("Signed expiry must be specified in signature or SAS identifier"); } if (!this.SignedPermission.HasValue && !sasIdentifier.AccessPolicy.SignedPermission.HasValue) { throw new AuthenticationFailureException("Signed permission must be specified in signature or SAS identifier"); } if (this.SignedStart.HasValue && sasIdentifier.AccessPolicy.SignedStart.HasValue || this.SignedExpiry.HasValue && sasIdentifier.AccessPolicy.SignedExpiry.HasValue || this.SignedPermission.HasValue && sasIdentifier.AccessPolicy.SignedPermission.HasValue) { throw new AuthenticationFailureException("Access policy fields can be associated with signature or SAS identifier but not both"); } if (sasIdentifier.AccessPolicy.SignedStart.HasValue) { this.SignedStart = new DateTime?(sasIdentifier.AccessPolicy.SignedStart.Value); } if (sasIdentifier.AccessPolicy.SignedExpiry.HasValue) { NephosAssertionException.Assert(!this.SignedExpiry.HasValue); this.SignedExpiry = new DateTime?(sasIdentifier.AccessPolicy.SignedExpiry.Value); } if (sasIdentifier.AccessPolicy.SignedPermission.HasValue) { NephosAssertionException.Assert(!this.SignedPermission.HasValue); this.SignedPermission = new SASPermission?(sasIdentifier.AccessPolicy.SignedPermission.Value); } }
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); }