/// <summary>
        /// Initializes a new instance of the <see cref="XacmlContextAttribute"/> class.
        /// </summary>
        /// <param name="attributeId">The attribute identifier.</param>
        /// <param name="dataType">Type of the data.</param>
        /// <param name="attributeValue">The attribute value.</param>
        /// <remarks>Used only for XACML1.0/1.1</remarks>
        public XacmlContextAttribute(Uri attributeId, Uri dataType, XacmlContextAttributeValue attributeValue) {
            Contract.Requires<ArgumentNullException>(attributeId != null);
            Contract.Requires<ArgumentNullException>(dataType != null);
            Contract.Requires<ArgumentNullException>(attributeValue != null);

            this.attributeId = attributeId;
            this.dataType = dataType;
            this.attributeValues = new List<XacmlContextAttributeValue>() { attributeValue };
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="XacmlContextAttribute"/> class.
        /// </summary>
        /// <param name="attributeId">The attribute identifier.</param>
        /// <param name="dataType">Type of the data.</param>
        /// <param name="attributeValue">The attribute value.</param>
        /// <remarks>Used only for XACML1.0/1.1</remarks>
        public XacmlContextAttribute(Uri attributeId, Uri dataType, XacmlContextAttributeValue attributeValue)
        {
            if (attributeId == null)
            {
                throw new ArgumentNullException(nameof(attributeId));
            }

            if (dataType == null)
            {
                throw new ArgumentNullException(nameof(dataType));
            }

            if (attributeValue == null)
            {
                throw new ArgumentNullException(nameof(attributeValue));
            }

            this.attributeId     = attributeId;
            this.dataType        = dataType;
            this.attributeValues = new List <XacmlContextAttributeValue>()
            {
                attributeValue
            };
        }
        protected virtual XacmlContextAttributeValue ReadContextAttributeValue(XmlReader reader) {
            Contract.Requires<ArgumentNullException>(reader != null, "reader");
            Contract.Requires<XmlException>(reader.IsStartElement(XacmlConstants.ElementNames.AttributeValue, this.version.NamespaceContext));

            XacmlContextAttributeValue result = new XacmlContextAttributeValue();
            if (reader.IsEmptyElement) {
                reader.Read();
                return result;
            }

            reader.ReadStartElement(XacmlConstants.ElementNames.AttributeValue, this.version.NamespaceContext);

            // Read elements
            result.Value = reader.ReadContentAsString(); // JG:
            //result.Value = reader.ReadInnerXml(); // TODO: 

            reader.ReadEndElement();

            return result;
        }
        protected virtual void WriteContextAttributeValue(XmlWriter writer, XacmlContextAttributeValue xacmlContextAttributeValue) {
            Contract.Requires<ArgumentNullException>(writer != null);
            Contract.Requires<ArgumentNullException>(xacmlContextAttributeValue != null);

            writer.WriteStartElement(XacmlConstants.Prefixes.Context, XacmlConstants.ElementNames.AttributeValue, this.version.NamespaceContext);

            // UNDONE AnyAttribute

            writer.WriteRaw(xacmlContextAttributeValue.Value);

            writer.WriteEndElement();
        }