void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { writer.WriteStartObject(); writer.WritePropertyName("templateUri"); writer.WriteStringValue(TemplateUri); writer.WritePropertyName("sasType"); writer.WriteStringValue(SasType.ToString()); writer.WritePropertyName("validityPeriod"); writer.WriteStringValue(ValidityPeriod); if (Optional.IsDefined(SasDefinitionAttributes)) { writer.WritePropertyName("attributes"); writer.WriteObjectValue(SasDefinitionAttributes); } if (Optional.IsCollectionDefined(Tags)) { writer.WritePropertyName("tags"); writer.WriteStartObject(); foreach (var item in Tags) { writer.WritePropertyName(item.Key); writer.WriteStringValue(item.Value); } writer.WriteEndObject(); } writer.WriteEndObject(); }
public SASAuthorizationParameters CheckAccessWithMultiplePermissions(IAccountIdentifier requestor, string resourceAccount, string resourceContainer, string resourceIdentifier, PermissionLevel requiredPermission, SasType supportedSasTypes, SasResourceType requiredResourceType, List <SASPermission> requiredSasPermissions, TimeSpan timeout) { SASAuthorizationParameters sASAuthorizationParameter; AuthorizationResult authorizationResult = null; Duration startingNow = Duration.StartingNow; SASAuthorizationParameters sASAuthorizationParameter1 = new SASAuthorizationParameters() { SupportedSasTypes = supportedSasTypes, SignedResourceType = requiredResourceType }; SASAuthorizationParameters current = sASAuthorizationParameter1; List <SASPermission> .Enumerator enumerator = requiredSasPermissions.GetEnumerator(); try { do { if (!enumerator.MoveNext()) { break; } current.SignedPermission = enumerator.Current; IAsyncResult asyncResult = this.BeginAuthorizeRequest(requestor, resourceAccount, resourceContainer, resourceIdentifier, requiredPermission, current, startingNow.Remaining(timeout), null, null); authorizationResult = this.EndAuthorizeRequest(asyncResult); if (!authorizationResult.Authorized) { continue; } sASAuthorizationParameter = current; return(sASAuthorizationParameter); }while (authorizationResult.Authorized || authorizationResult.FailureReason == AuthorizationFailureReason.PermissionMismatch); if (requestor == null || !requestor.IsSecondaryAccess || !AuthorizationManager.IsWritePermission(requiredPermission)) { throw new NephosUnauthorizedAccessException(resourceAccount, resourceContainer, resourceIdentifier, requestor, requiredPermission, authorizationResult.FailureReason); } throw new SecondaryWriteNotAllowedException(); } finally { ((IDisposable)enumerator).Dispose(); } return(sASAuthorizationParameter); }