/// <summary>
        /// Initializes a new instance of the <see cref="XacmlCombinerParameter"/> class.
        /// </summary>
        /// <param name="parameterName">The identifier of the parameter.</param>
        /// <param name="attributeValue">The value of the parameter.</param>
        public XacmlCombinerParameter(string parameterName, XacmlAttributeValue attributeValue) {
            Contract.Requires<ArgumentNullException>(!string.IsNullOrEmpty(parameterName));
            Contract.Requires<ArgumentNullException>(attributeValue != null);

            this.parameterName = parameterName;
            this.attributeValue = attributeValue;
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="XacmlMatch"/> class.
        /// </summary>
        /// <param name="matchId">The match identifier.</param>
        /// <param name="attributeValue">The attribute value.</param>
        /// <param name="attributeSelector">The attribute selector.</param>
        public XacmlMatch(Uri matchId, XacmlAttributeValue attributeValue, XacmlAttributeSelector attributeSelector) {
            Contract.Requires<ArgumentNullException>(matchId != null);
            Contract.Requires<ArgumentNullException>(attributeValue != null);
            Contract.Requires<ArgumentNullException>(attributeSelector != null);

            this.matchId = matchId;
            this.attributeValue = attributeValue;
            this.attributeSelector = attributeSelector;
        }
示例#3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="XacmlCombinerParameter"/> class.
        /// </summary>
        /// <param name="parameterName">The identifier of the parameter.</param>
        /// <param name="attributeValue">The value of the parameter.</param>
        public XacmlCombinerParameter(string parameterName, XacmlAttributeValue attributeValue)
        {
            if (parameterName == null)
            {
                throw new ArgumentNullException(nameof(parameterName));
            }

            if (parameterName.Length == 0)
            {
                throw new ArgumentException("Value cannot be empty.", nameof(parameterName));
            }

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

            this.parameterName  = parameterName;
            this.attributeValue = attributeValue;
        }
示例#4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="XacmlMatch"/> class.
        /// </summary>
        /// <param name="matchId">The match identifier.</param>
        /// <param name="attributeValue">The attribute value.</param>
        /// <param name="attributeSelector">The attribute selector.</param>
        public XacmlMatch(Uri matchId, XacmlAttributeValue attributeValue, XacmlAttributeSelector attributeSelector)
        {
            if (matchId == null)
            {
                throw new ArgumentNullException(nameof(matchId));
            }

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

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

            this.matchId           = matchId;
            this.attributeValue    = attributeValue;
            this.attributeSelector = attributeSelector;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="XacmlActionMatch"/> class.
 /// </summary>
 /// <param name="matchId">The match identifier.</param>
 /// <param name="attributeValue">The attribute value.</param>
 /// <param name="attributeSelector">The attribute selector.</param>
 public XacmlActionMatch(Uri matchId, XacmlAttributeValue attributeValue, XacmlAttributeSelector attributeSelector)
     : base(matchId, attributeValue, attributeSelector) {
     Contract.Requires<ArgumentNullException>(matchId != null);
     Contract.Requires<ArgumentNullException>(attributeValue != null);
     Contract.Requires<ArgumentNullException>(attributeSelector != null);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="XacmlSubjectMatch"/> class.
 /// </summary>
 /// <param name="matchId">The match identifier.</param>
 /// <param name="attributeValue">The attribute value.</param>
 /// <param name="attributeDesignator">The attribute designator.</param>
 public XacmlSubjectMatch(Uri matchId, XacmlAttributeValue attributeValue, XacmlSubjectAttributeDesignator attributeDesignator)
     : base(matchId, attributeValue, attributeDesignator) {
     Contract.Requires<ArgumentNullException>(matchId != null);
     Contract.Requires<ArgumentNullException>(attributeValue != null);
     Contract.Requires<ArgumentNullException>(attributeDesignator != null);
 }
示例#7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="XacmlActionMatch"/> class.
 /// </summary>
 /// <param name="matchId">The match identifier.</param>
 /// <param name="attributeValue">The attribute value.</param>
 /// <param name="attributeSelector">The attribute selector.</param>
 public XacmlActionMatch(Uri matchId, XacmlAttributeValue attributeValue, XacmlAttributeSelector attributeSelector)
     : base(matchId, attributeValue, attributeSelector)
 {
 }
示例#8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="XacmlActionMatch"/> class.
 /// </summary>
 /// <param name="matchId">The match identifier.</param>
 /// <param name="attributeValue">The attribute value.</param>
 /// <param name="attributeDesignator">The attribute designator.</param>
 public XacmlActionMatch(Uri matchId, XacmlAttributeValue attributeValue, XacmlActionAttributeDesignator attributeDesignator)
     : base(matchId, attributeValue, attributeDesignator)
 {
 }
示例#9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="XacmlResourceMatch"/> class.
 /// </summary>
 /// <param name="matchId">The match identifier.</param>
 /// <param name="attributeValue">The attribute value.</param>
 /// <param name="attributeSelector">The attribute selector.</param>
 public XacmlResourceMatch(Uri matchId, XacmlAttributeValue attributeValue, XacmlAttributeSelector attributeSelector)
     : base(matchId, attributeValue, attributeSelector)
 {
 }
示例#10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="XacmlResourceMatch"/> class.
 /// </summary>
 /// <param name="matchId">The match identifier.</param>
 /// <param name="attributeValue">The attribute value.</param>
 /// <param name="attributeDesignator">The attribute designator.</param>
 public XacmlResourceMatch(Uri matchId, XacmlAttributeValue attributeValue, XacmlResourceAttributeDesignator attributeDesignator)
     : base(matchId, attributeValue, attributeDesignator)
 {
 }
示例#11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="XacmlSubjectMatch"/> class.
 /// </summary>
 /// <param name="matchId">The match identifier.</param>
 /// <param name="attributeValue">The attribute value.</param>
 /// <param name="attributeDesignator">The attribute designator.</param>
 public XacmlSubjectMatch(Uri matchId, XacmlAttributeValue attributeValue, XacmlSubjectAttributeDesignator attributeDesignator)
     : base(matchId, attributeValue, attributeDesignator)
 {
 }
        /// <summary>
        /// Reads the attribute value.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <returns></returns>
        /// <exception cref="System.Xml.XmlException">
        /// AttributeValue NotStartElement
        /// or
        /// DataType IsNullOrEmpty
        /// </exception>
        protected virtual XacmlAttributeValue ReadAttributeValue(XmlReader reader) {
            Contract.Requires<ArgumentNullException>(reader != null, "reader");

            if (!reader.IsStartElement(XacmlConstants.ElementNames.AttributeValue, this.version.NamespacePolicy)) {
                throw Diagnostic.DiagnosticTools.ExceptionUtil.ThrowHelperError(new XmlException("AttributeValue NotStartElement"));
            }

            IDictionary<string, string> attributes = new Dictionary<string, string>();
            var dataType = reader.GetAttribute(XacmlConstants.AttributeNames.DataType);

            if (string.IsNullOrEmpty(dataType)) {
                throw Diagnostic.DiagnosticTools.ExceptionUtil.ThrowHelperError(new XmlException("DataType IsNullOrEmpty"));
            }

            while (reader.MoveToNextAttribute()) {
                attributes.Add(reader.Name, reader.Value);
            }

            // Move the reader back to the element node.
            reader.MoveToElement();

            string value = null; //Any

            if (dataType == "http://www.w3.org/2001/XMLSchema#string") {
                // Nevajag lietot Trim, jo tas izgriež tukšumzimes, kuras ir svarīgas, ja dati ir domāti priekš Regular Expression
                value = reader.ReadElementContentAsString();
            }
            else {
                value = reader.ReadInnerXml();
            }

            var attribute = new XacmlAttributeValue(new Uri(dataType, UriKind.RelativeOrAbsolute), value);

            foreach (var item in attributes) {
                attribute.Attributes.Add(new System.Xml.Linq.XAttribute(item.Key, item.Value)); // UNDONE: namespace
            }

            return attribute;
        }
        /// <summary>
        /// protected virtual void WriteAttributeValue
        /// </summary>
        /// <param name="writer">XmlWriter writer</param>
        /// <param name="data">XacmlAttributeValue data</param>
        protected virtual void WriteAttributeValue(XmlWriter writer, XacmlAttributeValue data) {
            Contract.Requires<ArgumentNullException>(writer != null);
            Contract.Requires<ArgumentNullException>(data != null);

            writer.WriteStartElement(XacmlConstants.Prefixes.Policy, XacmlConstants.ElementNames.AttributeValue, this.version.NamespacePolicy);
            writer.WriteAttributeString(XacmlConstants.AttributeNames.DataType, data.DataType.OriginalString);

            if (data.Value != null) {
                writer.WriteString(data.Value);
            }
            else {
                this.WriteOpenElement(writer, (XacmlOpenElement)data);
            }

            writer.WriteEndElement();
        }