Exemple #1
0
        protected virtual void WriteSingleSignOnDescriptorElements(XmlWriter writer, SingleSignOnDescriptor singleSignOnDescriptor)
        {
            if (writer == null)
            {
                throw new ArgumentNullException(nameof(writer));
            }
            if (singleSignOnDescriptor == null)
            {
                throw new ArgumentNullException(nameof(singleSignOnDescriptor));
            }

            WriteRoleDescriptorElements(writer, singleSignOnDescriptor);

            if (singleSignOnDescriptor.ArtifactResolutionServices != null && singleSignOnDescriptor.ArtifactResolutionServices.Count > 0)
            {
                foreach (var ep in singleSignOnDescriptor.ArtifactResolutionServices.Values)
                {
                    if (ep.ResponseLocation != null)
                    {
                        throw new MetadataSerializationException("An artifact resoluce service has a null ResponseLocation");
                    }
                    WriteIndexedProtocolEndpoint(writer, ep, Saml2MetadataConstants.Elements.ArtifactResolutionService,
                                                 Saml2MetadataConstants.Namespace);
                }
            }

            if (singleSignOnDescriptor.SingleLogoutServices != null && singleSignOnDescriptor.SingleLogoutServices.Count > 0)
            {
                foreach (var endpoint in singleSignOnDescriptor.SingleLogoutServices)
                {
                    WriteProtocolEndpoint(writer, endpoint, Saml2MetadataConstants.Elements.SingleLogoutService, Saml2MetadataConstants.Namespace);
                }
            }

            if (singleSignOnDescriptor.NameIdentifierFormats != null && singleSignOnDescriptor.NameIdentifierFormats.Count > 0)
            {
                foreach (var nameId in singleSignOnDescriptor.NameIdentifierFormats)
                {
                    if (!nameId.IsAbsoluteUri)
                    {
                        throw new MetadataSerializationException("NameIdentifierFormat is not absolute URI");
                    }

                    writer.WriteStartElement(Saml2MetadataConstants.Elements.NameIdFormat, Saml2MetadataConstants.Namespace);
                    writer.WriteString(nameId.AbsoluteUri);
                    writer.WriteEndElement();
                }
            }

            WriteCustomElements(writer, singleSignOnDescriptor);
        }
Exemple #2
0
 protected virtual void WriteSingleSignOnDescriptorAttributes(XmlWriter writer, SingleSignOnDescriptor singleSignOnDescriptor)
 {
     WriteRoleDescriptorAttributes(writer, singleSignOnDescriptor);
     WriteCustomAttributes(writer, singleSignOnDescriptor);
 }