private static void WriteSharedAccessIdentifiers(SharedAccessTablePolicies sharedAccessPolicies, Stream outputStream) { WriteSharedAccessIdentifiers(sharedAccessPolicies, outputStream, delegate(SharedAccessTablePolicy policy, XmlWriter writer) { writer.WriteElementString("Start", SharedAccessSignatureHelper.GetDateTimeOrEmpty(policy.SharedAccessStartTime)); writer.WriteElementString("Expiry", SharedAccessSignatureHelper.GetDateTimeOrEmpty(policy.SharedAccessExpiryTime)); writer.WriteElementString("Permission", SharedAccessTablePolicy.PermissionsToString(policy.Permissions)); }); }
////public string SharedAccessAuthenticatedURI(Uri uri, string permission) { return ""; } /// <summary> /// Writes a collection of shared access policies to the specified stream in XML format. /// </summary> /// <param name="sharedAccessPolicies">A collection of shared access policies.</param> /// <param name="outputStream">An output stream.</param> public static void WriteSharedAccessIdentifiers(SharedAccessPolicies sharedAccessPolicies, Stream outputStream) { CommonUtils.AssertNotNull("sharedAccessPolicies", sharedAccessPolicies); CommonUtils.AssertNotNull("outputStream", outputStream); if (sharedAccessPolicies.Count > Constants.MaxSharedAccessPolicyIdentifiers) { string errorMessage = string.Format( CultureInfo.CurrentCulture, SR.TooManyPolicyIdentifiers, sharedAccessPolicies.Count, Constants.MaxSharedAccessPolicyIdentifiers); throw new ArgumentOutOfRangeException("sharedAccessPolicies", errorMessage); } XmlWriterSettings settings = new XmlWriterSettings(); settings.Encoding = Encoding.UTF8; using (XmlWriter writer = XmlWriter.Create(outputStream, settings)) { writer.WriteStartElement(Constants.SignedIdentifiers); foreach (var key in sharedAccessPolicies.Keys) { writer.WriteStartElement(Constants.SignedIdentifier); // Set the identifier writer.WriteElementString(Constants.Id, key); // Set the permissions writer.WriteStartElement(Constants.AccessPolicy); var policy = sharedAccessPolicies[key]; writer.WriteElementString( Constants.Start, SharedAccessSignatureHelper.GetDateTimeOrEmpty(policy.SharedAccessStartTime)); writer.WriteElementString( Constants.Expiry, SharedAccessSignatureHelper.GetDateTimeOrEmpty(policy.SharedAccessExpiryTime)); writer.WriteElementString( Constants.Permission, SharedAccessPolicy.PermissionsToString(policy.Permissions)); writer.WriteEndElement(); writer.WriteEndElement(); } writer.WriteEndDocument(); } }
/// <summary> /// Writes a collection of shared access policies to the specified stream in XML format. /// </summary> /// <param name="sharedAccessPolicies">A collection of shared access policies.</param> /// <param name="outputStream">An output stream.</param> public static void WriteSharedAccessIdentifiers(SharedAccessBlobPolicies sharedAccessPolicies, Stream outputStream) { Request.WriteSharedAccessIdentifiers( sharedAccessPolicies, outputStream, (policy, writer) => { writer.WriteElementString( Constants.Start, SharedAccessSignatureHelper.GetDateTimeOrEmpty(policy.SharedAccessStartTime)); writer.WriteElementString( Constants.Expiry, SharedAccessSignatureHelper.GetDateTimeOrEmpty(policy.SharedAccessExpiryTime)); writer.WriteElementString( Constants.Permission, SharedAccessBlobPolicy.PermissionsToString(policy.Permissions)); }); }