/// <summary>
		/// Creates a new Target with the specified agumetns.
		/// </summary>
		/// <param name="resources">The resources for this target.</param>
		/// <param name="subjects">The subjects for this target.</param>
		/// <param name="actions">The actions for this target.</param>
		/// <param name="environments">The environments for this target.</param>
		/// <param name="schemaVersion">The version of the schema that was used to validate.</param>
		public TargetElementReadWrite(ResourcesElementReadWrite resources, SubjectsElementReadWrite subjects, ActionsElementReadWrite actions, EnvironmentsElementReadWrite environments, XacmlVersion schemaVersion)
			: base(XacmlSchema.Policy, schemaVersion)
		{
			_resources = resources;
			_subjects = subjects;
			_actions = actions;
			_environments = environments;
		}
 /// <summary>
 /// Creates a new Target with the specified agumetns.
 /// </summary>
 /// <param name="resources">The resources for this target.</param>
 /// <param name="subjects">The subjects for this target.</param>
 /// <param name="actions">The actions for this target.</param>
 /// <param name="environments">The environments for this target.</param>
 /// <param name="schemaVersion">The version of the schema that was used to validate.</param>
 public TargetElementReadWrite(ResourcesElementReadWrite resources, SubjectsElementReadWrite subjects, ActionsElementReadWrite actions, EnvironmentsElementReadWrite environments, XacmlVersion schemaVersion)
     : base(XacmlSchema.Policy, schemaVersion)
 {
     _resources    = resources;
     _subjects     = subjects;
     _actions      = actions;
     _environments = environments;
 }
		/// <summary>
		/// Creates a new Target using the XmlReader instance provided.
		/// </summary>
		/// <param name="reader">The XmlReader positioned at the Target node.</param>
		/// <param name="schemaVersion">The version of the schema that was used to validate.</param>
		public TargetElementReadWrite(XmlReader reader, XacmlVersion schemaVersion)
			: base(XacmlSchema.Policy, schemaVersion)
		{
            if (reader == null) throw new ArgumentNullException("reader");
			if (reader.LocalName == PolicySchema1.TargetElement.Target &&
				ValidateSchema(reader, schemaVersion))
			{
				if (!reader.IsEmptyElement)
				{
					while (reader.Read())
					{
						switch (reader.LocalName)
						{
							case PolicySchema1.TargetElement.Subjects:
								_subjects = new SubjectsElementReadWrite(reader, schemaVersion);
								break;
							case PolicySchema1.TargetElement.Resources:
								_resources = new ResourcesElementReadWrite(reader, schemaVersion);
								break;
							case PolicySchema1.TargetElement.Actions:
								_actions = new ActionsElementReadWrite(reader, schemaVersion);
								break;
							case PolicySchema2.TargetElement.Environments:
								_environments = new EnvironmentsElementReadWrite(reader, schemaVersion);
								break;
						}
						if (reader.LocalName == PolicySchema1.TargetElement.Target &&
							reader.NodeType == XmlNodeType.EndElement)
						{
							break;
						}
					}
				}

				// V2 does not have the All(TargetItem) element, and a missing (TargetItem)s element is considered as
				// Any(TargetItem). In order to mantain the code for both versions 
				if (schemaVersion == XacmlVersion.Version20)
				{
					if (_subjects == null)
					{
						_subjects = new SubjectsElementReadWrite(true, new TargetItemReadWriteCollection(), schemaVersion);
					}
					if (_resources == null)
					{
						_resources = new ResourcesElementReadWrite(true, new TargetItemReadWriteCollection(), schemaVersion);
					}
					if (_actions == null)
					{
						_actions = new ActionsElementReadWrite(true, new TargetItemReadWriteCollection(), schemaVersion);
					}
				}
			}
			else
			{
				throw new Exception(Resource.ResourceManager[Resource.MessageKey.exc_invalid_node_name, reader.LocalName]);
			}
		}
示例#4
0
 /// <summary>
 /// Creates a new Target with the specified agumetns.
 /// </summary>
 /// <param name="resources">The resources for this target.</param>
 /// <param name="subjects">The subjects for this target.</param>
 /// <param name="actions">The actions for this target.</param>
 /// <param name="environments">The environments for this target.</param>
 /// <param name="schemaVersion">The version of the schema that was used to validate.</param>
 public TargetElement(ResourcesElementReadWrite resources, SubjectsElementReadWrite subjects, ActionsElementReadWrite actions, EnvironmentsElementReadWrite environments, XacmlVersion schemaVersion)
     : base(resources, subjects, actions, environments, schemaVersion)
 {
 }
示例#5
0
		/// <summary>
		/// Creates a new Target with the specified agumetns.
		/// </summary>
		/// <param name="resources">The resources for this target.</param>
		/// <param name="subjects">The subjects for this target.</param>
		/// <param name="actions">The actions for this target.</param>
		/// <param name="environments">The environments for this target.</param>
		/// <param name="schemaVersion">The version of the schema that was used to validate.</param>
		public TargetElement( ResourcesElementReadWrite resources, SubjectsElementReadWrite subjects, ActionsElementReadWrite actions, EnvironmentsElementReadWrite environments, XacmlVersion schemaVersion )
			: base( resources, subjects, actions, environments, schemaVersion )
		{
		}
        /// <summary>
        /// Creates a new Target using the XmlReader instance provided.
        /// </summary>
        /// <param name="reader">The XmlReader positioned at the Target node.</param>
        /// <param name="schemaVersion">The version of the schema that was used to validate.</param>
        public TargetElementReadWrite(XmlReader reader, XacmlVersion schemaVersion)
            : base(XacmlSchema.Policy, schemaVersion)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            if (reader.LocalName == PolicySchema1.TargetElement.Target &&
                ValidateSchema(reader, schemaVersion))
            {
                if (!reader.IsEmptyElement)
                {
                    while (reader.Read())
                    {
                        switch (reader.LocalName)
                        {
                        case PolicySchema1.TargetElement.Subjects:
                            _subjects = new SubjectsElementReadWrite(reader, schemaVersion);
                            break;

                        case PolicySchema1.TargetElement.Resources:
                            _resources = new ResourcesElementReadWrite(reader, schemaVersion);
                            break;

                        case PolicySchema1.TargetElement.Actions:
                            _actions = new ActionsElementReadWrite(reader, schemaVersion);
                            break;

                        case PolicySchema2.TargetElement.Environments:
                            _environments = new EnvironmentsElementReadWrite(reader, schemaVersion);
                            break;
                        }
                        if (reader.LocalName == PolicySchema1.TargetElement.Target &&
                            reader.NodeType == XmlNodeType.EndElement)
                        {
                            break;
                        }
                    }
                }

                // V2 does not have the All(TargetItem) element, and a missing (TargetItem)s element is considered as
                // Any(TargetItem). In order to mantain the code for both versions
                if (schemaVersion == XacmlVersion.Version20)
                {
                    if (_subjects == null)
                    {
                        _subjects = new SubjectsElementReadWrite(true, new TargetItemReadWriteCollection(), schemaVersion);
                    }
                    if (_resources == null)
                    {
                        _resources = new ResourcesElementReadWrite(true, new TargetItemReadWriteCollection(), schemaVersion);
                    }
                    if (_actions == null)
                    {
                        _actions = new ActionsElementReadWrite(true, new TargetItemReadWriteCollection(), schemaVersion);
                    }
                }
            }
            else
            {
                throw new Exception(Resource.ResourceManager[Resource.MessageKey.exc_invalid_node_name, reader.LocalName]);
            }
        }