예제 #1
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;
        }
예제 #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)
        {
            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;
        }
예제 #3
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) {
     Contract.Requires<ArgumentNullException>(matchId != null);
     Contract.Requires<ArgumentNullException>(attributeValue != null);
     Contract.Requires<ArgumentNullException>(attributeSelector != null);
 }
예제 #4
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)
 {
 }
예제 #5
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)
 {
 }
        /// <summary>
        /// Writes the attribute selector.
        /// </summary>
        /// <param name="writer">The writer.</param>
        /// <param name="data">The data.</param>
        protected override void WriteAttributeSelector(XmlWriter writer, XacmlAttributeSelector data) {
            writer.WriteStartElement(XacmlConstants.Prefixes.Policy, XacmlConstants.ElementNames.AttributeSelector, this.version.NamespacePolicy);
            writer.WriteAttributeString(XacmlConstants.AttributeNames.Category, data.Category.OriginalString);
            writer.WriteAttributeString(XacmlConstants.AttributeNames.Path, data.Path);
            writer.WriteAttributeString(XacmlConstants.AttributeNames.DataType, data.DataType.OriginalString);
            writer.WriteAttributeString(XacmlConstants.AttributeNames.MustBePresent, data.MustBePresent.ToString());

            if (data.ContextSelectorId != null) {
                writer.WriteAttributeString(XacmlConstants.AttributeNames.ContextSelectorId, data.ContextSelectorId.OriginalString);
            }

            writer.WriteEndElement();
        }
        /// <summary>
        /// Reads the attribute selector.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <returns></returns>
        protected override XacmlAttributeSelector ReadAttributeSelector(XmlReader reader) {
            Contract.Requires<ArgumentNullException>(reader != null, "reader");
            Contract.Requires<XmlException>(reader.IsStartElement(XacmlConstants.ElementNames.AttributeSelector, this.version.NamespacePolicy));

            XacmlAttributeSelector result = new XacmlAttributeSelector(
                this.ReadAttribute<Uri>(reader, XacmlConstants.AttributeNames.Category),
                this.ReadAttribute<string>(reader, XacmlConstants.AttributeNames.Path),
                this.ReadAttribute<Uri>(reader, XacmlConstants.AttributeNames.DataType),
                this.ReadAttribute<bool>(reader, XacmlConstants.AttributeNames.MustBePresent)
                ) {
                    ContextSelectorId = this.ReadAttribute<Uri>(reader, XacmlConstants.AttributeNames.ContextSelectorId, isRequered: false)
                };

            reader.ReadInnerXml();

            return result;
        }
예제 #8
0
        protected virtual IEnumerable<string> GetAttributeSelector(XacmlAttributeSelector selector) {
            Contract.Requires<ArgumentNullException>(selector != null);

            IEnumerable<XmlNode> attributeBag = this.pip.GetAttributeByXPath(this.xpathVersion, selector.Path, this.namespaces);

            if (!attributeBag.Any()) {
                if (selector.MustBePresent.HasValue && selector.MustBePresent.Value) {
                    // return "Indeterminate”
                    return null;
                }
            }

            return attributeBag.Select(o => o.Value);
        }
예제 #9
0
        protected override IEnumerable<string> GetAttributeSelector(XacmlAttributeSelector selector) {
            IEnumerable<XmlNode> attributeBag = this.pip.GetAttributeByXPath(this.xpathVersion, selector.Path, selector.Category, selector.ContextSelectorId, this.namespaces);

            if (attributeBag.Count() == 0) {
                if (selector.MustBePresent.HasValue && selector.MustBePresent.Value) {
                    // return "Indeterminate”
                    return null;
                }
            }

            return attributeBag.Select(o => o.Value);
        }
        /// <summary>
        ///  protected virtual void WriteAttributeSelector
        /// </summary>
        /// <param name="writer">XmlWriter writer</param>
        /// <param name="data">XacmlAttributeSelector data</param>
        protected virtual void WriteAttributeSelector(XmlWriter writer, XacmlAttributeSelector data) {
            Contract.Requires<ArgumentNullException>(writer != null);
            Contract.Requires<ArgumentNullException>(data != null);

            writer.WriteStartElement(XacmlConstants.Prefixes.Policy, XacmlConstants.ElementNames.AttributeSelector, this.version.NamespacePolicy);
            writer.WriteAttributeString(XacmlConstants.AttributeNames.RequestContextPath, data.Path.ToString());
            writer.WriteAttributeString(XacmlConstants.AttributeNames.DataType, data.DataType.OriginalString);
            writer.WriteAttributeString(XacmlConstants.AttributeNames.MustBePresent, data.MustBePresent.ToString());
            writer.WriteEndElement();
        }