protected override bool TryReadRoleDescriptor(XmlDictionaryReader reader, out RoleDescriptor role) { if (!reader.IsStartElement(Saml2MetadataConstants.Elements.RoleDescriptor, Saml2MetadataConstants.Namespace)) { return(Out.False(out role)); } var d = null as RoleDescriptor; if (reader.TryReadFederationEndpointType(out var type)) { if (type == FederationEndpointType.ApplicationService) { d = new ApplicationServiceDescriptor(); } if (type == FederationEndpointType.AttributeService) { d = new AttributeServiceDescriptor(); } if (type == FederationEndpointType.PseudonymService) { d = new PseudonymServiceDescriptor(); } if (type == FederationEndpointType.SecurityTokenService) { d = new SecurityTokenServiceDescriptor(); } } if (d == null) { d = new RoleDescriptor(); } ReadRoleDescriptorAttributes(reader, d); reader.ForEachChild(r => TryReadRoleDescriptorChild(r, d), out var signature); d.Signature = signature; role = d; return(true); }
protected virtual void WriteAttributeServiceDescriptorChildren(XmlDictionaryWriter writer, AttributeServiceDescriptor attributeServiceDescriptor) { if (attributeServiceDescriptor == null) { return; } if (!attributeServiceDescriptor.AttributeServiceEndpoint.Any()) { throw XmlWriterExceptionHelper.CreateRequiredChildElementMissingException(Saml2MetadataConstants.Elements.RoleDescriptor, attributeServiceDescriptor.GetXmlTypeName()); } WriteWebServiceDescriptorChildren(writer, attributeServiceDescriptor); foreach (var attributeServiceEndpoint in attributeServiceDescriptor.AttributeServiceEndpoint) { WsAddressingSerializer.WriteEndpointReferenceCollection(writer, Prefix, Elements.AttributeServiceEndpoint, Namespace, attributeServiceEndpoint); } foreach (var singleSignOutNotificationEndpoint in attributeServiceDescriptor.SingleSignOutNotificationEndpoint) { WsAddressingSerializer.WriteEndpointReferenceCollection(writer, Prefix, Elements.SingleSignOutNotificationEndpoint, Namespace, singleSignOutNotificationEndpoint); } }
protected virtual void WriteAttributeServiceDescriptorAttributes(XmlDictionaryWriter writer, AttributeServiceDescriptor attributeServiceDescriptor) { WriteWebServiceDescriptorAttributes(writer, attributeServiceDescriptor); }
protected virtual void ReadAttributeServiceDescriptorAttributes(XmlDictionaryReader reader, AttributeServiceDescriptor attributeServiceDescriptor) { // No default attributes }
protected virtual bool TryReadAttributeServiceDescriptorChild(XmlDictionaryReader reader, AttributeServiceDescriptor attributeServiceDescriptor) { if (WsAddressingSerializer.TryReadEndpointReferenceCollection(reader, Elements.SingleSignOutNotificationEndpoint, Namespace, out var singleSignOutNotificationEndpoint)) { attributeServiceDescriptor.SingleSignOutNotificationEndpoint.Add(singleSignOutNotificationEndpoint); } else if (WsAddressingSerializer.TryReadEndpointReferenceCollection(reader, Elements.AttributeServiceEndpoint, Namespace, out var attributeServiceEndpoint)) { attributeServiceDescriptor.AttributeServiceEndpoint.Add(attributeServiceEndpoint); } else { return(TryReadWebServiceDescriptorChild(reader, attributeServiceDescriptor)); } return(true); }