protected virtual XacmlContextAction ReadContextAction(XmlReader reader) { if (reader == null) { throw new ArgumentNullException(nameof(reader)); } if (!reader.IsStartElement(XacmlConstants.ElementNames.Action, this.Version.NamespaceContext)) { throw ThrowHelperXml(reader, "XML message is not valid."); } XacmlContextAction result = new XacmlContextAction(); // Read attributes if (reader.IsEmptyElement) { reader.Read(); return(result); } reader.ReadStartElement(XacmlConstants.ElementNames.Action, this.Version.NamespaceContext); // Read elements this.ReadList(result.Attributes, XacmlConstants.ElementNames.Attribute, this.Version.NamespaceContext, this.ReadContextAttribute, reader, isRequired: false); reader.ReadEndElement(); return(result); }
public void WriteRequest_11() { var s = new XacmlContextSubject(new XacmlContextAttribute(new Uri("uri:action"), new Uri("uri:type"), new XacmlContextAttributeValue())); var r = new XacmlContextResource(new XacmlContextAttribute(new Uri("uri:action"), new Uri("uri:type"), new XacmlContextAttributeValue())); var a = new XacmlContextAction(new XacmlContextAttribute(new Uri("uri:action"), new Uri("uri:type"), new XacmlContextAttributeValue())); var request = new XacmlContextRequest(r, a, s); StringBuilder builder = new StringBuilder(); using (XmlWriter writer = XmlWriter.Create(builder)) { var serializer = new Xacml10ProtocolSerializer(); serializer.WriteContextRequest(writer, request); } string xml = builder.ToString(); ValidateMessage(xml, Path.Combine(TestCasePath, "cs-xacml-schema-context-01.xsd")); }
protected virtual void WriteContextAction(XmlWriter writer, XacmlContextAction xacmlContextAction) { if (writer == null) { throw new ArgumentNullException(nameof(writer)); } if (xacmlContextAction == null) { throw new ArgumentNullException(nameof(xacmlContextAction)); } writer.WriteStartElement(XacmlConstants.Prefixes.Context, XacmlConstants.ElementNames.Action, this.Version.NamespaceContext); foreach (var attr in xacmlContextAction.Attributes) { this.WriteContextAttribute(writer, attr); } writer.WriteEndElement(); }