Пример #1
0
 /// <summary>
 /// Constructor user only for XACML 2.0
 /// </summary>
 /// <param name="resources">The resource.</param>
 /// <param name="action">The action.</param>
 /// <param name="subjects">The subject.</param>
 /// <param name="environment">The environment.</param>
 public XacmlContextRequest(XacmlContextResource resource, XacmlContextAction action, XacmlContextSubject subject, XacmlContextEnvironment environment) :
     this(new List<XacmlContextResource> { resource }, action, new List<XacmlContextSubject> { subject }, environment) {
     Contract.Requires<ArgumentNullException>(resource != null);
     Contract.Requires<ArgumentNullException>(action != null);
     Contract.Requires<ArgumentNullException>(subject != null);
     Contract.Requires<ArgumentNullException>(environment != null);
 }
Пример #2
0
        /// <summary>
        /// Constructor user only for XACML 1.0/1.1/2.0
        /// </summary>
        /// <param name="resource">The resource.</param>
        /// <param name="action">The action.</param>
        /// <param name="subjects">The subjects.</param>
        public XacmlContextRequest(XacmlContextResource resource, XacmlContextAction action, IEnumerable <XacmlContextSubject> subjects)
        {
            if (resource == null)
            {
                throw new ArgumentNullException(nameof(resource));
            }

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

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

            this.resources.Add(resource);
            this.action = action;

            foreach (var item in subjects)
            {
                this.subjects.Add(item);
            }
        }
Пример #3
0
 /// <summary>
 /// Constructor user only for XACML 2.0
 /// </summary>
 /// <param name="resources">The resource.</param>
 /// <param name="action">The action.</param>
 /// <param name="subjects">The subject.</param>
 /// <param name="environment">The environment.</param>
 public XacmlContextRequest(XacmlContextResource resource, XacmlContextAction action, XacmlContextSubject subject, XacmlContextEnvironment environment)
     : this(new List <XacmlContextResource> {
     resource
 }, action, new List <XacmlContextSubject> {
     subject
 }, environment)
 {
 }
Пример #4
0
        /// <summary>
        /// Constructor user only for XACML 1.0/1.1/2.0
        /// </summary>
        /// <param name="resource">The resource.</param>
        /// <param name="action">The action.</param>
        /// <param name="subjects">The subjects.</param>
        public XacmlContextRequest(XacmlContextResource resource, XacmlContextAction action, IEnumerable<XacmlContextSubject> subjects) {
            Contract.Requires<ArgumentNullException>(resource != null);
            Contract.Requires<ArgumentNullException>(action != null);
            Contract.Requires<ArgumentNullException>(subjects != null);

            this.resources.Add(resource);
            this.action = action;
           
            foreach (var item in subjects) {
                this.subjects.Add(item);
            }
        }
        protected virtual void WriteContextAction(XmlWriter writer, XacmlContextAction xacmlContextAction) {
            Contract.Requires<ArgumentNullException>(writer != null);
            Contract.Requires<ArgumentNullException>(xacmlContextAction != null);

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

            foreach (var attr in xacmlContextAction.Attributes) {
                this.WriteContextAttribute(writer, attr);
            }

            writer.WriteEndElement();
        }
        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, @"..\..\_Data\cs-xacml-schema-context-01.xsd");
        }
Пример #7
0
        /// <summary>
        /// Constructor user only for XACML 2.0
        /// </summary>
        /// <param name="resources">The resources.</param>
        /// <param name="action">The action.</param>
        /// <param name="subjects">The subjects.</param>
        /// <param name="environment">The environment.</param>
        public XacmlContextRequest(IEnumerable <XacmlContextResource> resources, XacmlContextAction action, IEnumerable <XacmlContextSubject> subjects, XacmlContextEnvironment environment)
        {
            if (resources == null)
            {
                throw new ArgumentNullException(nameof(resources));
            }

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

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

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

            foreach (var item in resources)
            {
                this.resources.Add(item);
            }

            this.action = action;

            foreach (var item in subjects)
            {
                this.subjects.Add(item);
            }

            this.Environment = environment;
        }
Пример #8
0
        /// <summary>
        /// Constructor user only for XACML 2.0
        /// </summary>
        /// <param name="resources">The resources.</param>
        /// <param name="action">The action.</param>
        /// <param name="subjects">The subjects.</param>
        /// <param name="environment">The environment.</param>
        public XacmlContextRequest(IEnumerable<XacmlContextResource> resources, XacmlContextAction action, IEnumerable<XacmlContextSubject> subjects, XacmlContextEnvironment environment) {
            Contract.Requires<ArgumentNullException>(resources != null);
            Contract.Requires<ArgumentNullException>(action != null);
            Contract.Requires<ArgumentNullException>(subjects != null);
            Contract.Requires<ArgumentNullException>(environment != null);

            foreach (var item in resources) {
                this.resources.Add(item);
            }

            this.action = action;

            foreach (var item in subjects) {
                this.subjects.Add(item);
            }

            this.Environment = environment;
        }
Пример #9
0
 /// <summary>
 /// Constructor user only for XACML 1.0/1.1/2.0
 /// </summary>
 /// <param name="resource">The resource.</param>
 /// <param name="action">The action.</param>
 /// <param name="subjects">The subjects.</param>
 public XacmlContextRequest(XacmlContextResource resource, XacmlContextAction action, XacmlContextSubject subject)
     : this(resource, action, new List<XacmlContextSubject> { subject }) {
     Contract.Requires<ArgumentNullException>(resource != null);
     Contract.Requires<ArgumentNullException>(action != null);
     Contract.Requires<ArgumentNullException>(subject != null);
 }
        protected virtual XacmlContextAction ReadContextAction(XmlReader reader) {
            Contract.Requires<ArgumentNullException>(reader != null, "reader");
            Contract.Requires<XmlException>(reader.IsStartElement(XacmlConstants.ElementNames.Action, this.version.NamespaceContext));

            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;
        }
Пример #11
0
 /// <summary>
 /// Constructor user only for XACML 1.0/1.1/2.0
 /// </summary>
 /// <param name="resource">The resource.</param>
 /// <param name="action">The action.</param>
 /// <param name="subjects">The subjects.</param>
 public XacmlContextRequest(XacmlContextResource resource, XacmlContextAction action, XacmlContextSubject subject)
     : this(resource, action, new List <XacmlContextSubject> {
     subject
 })
 {
 }