protected virtual void WriteRoleDescriptorElements(XmlWriter writer, RoleDescriptor descriptor) { if (writer == null) { throw new ArgumentNullException(nameof(writer)); } if (descriptor == null) { throw new ArgumentNullException(nameof(descriptor)); } if (descriptor.Organization != null) { WriteOrganization(writer, descriptor.Organization); } foreach (var key in descriptor.Keys) { WriteKeyDescriptor(writer, key); } foreach (var contact in descriptor.Contacts) { WriteContactPerson(writer, contact); } WriteCustomElements(writer, descriptor); }
protected virtual void WriteRoleDescriptorAttributes(XmlWriter writer, RoleDescriptor descriptor) { if (writer == null) { throw new ArgumentNullException(nameof(writer)); } if (descriptor == null) { throw new ArgumentNullException(nameof(descriptor)); } if (descriptor.ProtocolsSupported?.Any() != true) { throw new ArgumentNullException(nameof(descriptor.ProtocolsSupported)); } if (descriptor.ValidUntil.HasValue && descriptor.ValidUntil != DateTime.MaxValue) { writer.WriteAttributeString(Saml2MetadataConstants.Attributes.ValidUntil, null, descriptor.ValidUntil.Value.ToString("s", CultureInfo.InvariantCulture)); } writer.WriteAttributeIfPresent(Saml2MetadataConstants.Attributes.ErrorUrl, null, descriptor.ErrorUrl); var sb = new StringBuilder(); foreach (var protocol in descriptor.ProtocolsSupported) { sb.AppendFormat("{0} ", protocol.IsAbsoluteUri ? protocol.AbsoluteUri : protocol.ToString()); } writer.WriteAttributeString(Saml2MetadataConstants.Attributes.ProtocolsSupported, null, sb.ToString().Trim()); WriteCustomAttributes(writer, descriptor); }