コード例 #1
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 TargetElementReadWrite(ResourcesElementReadWrite resources, SubjectsElementReadWrite subjects, ActionsElementReadWrite actions, EnvironmentsElementReadWrite environments, XacmlVersion schemaVersion)
     : base(XacmlSchema.Policy, schemaVersion)
 {
     _resources    = resources;
     _subjects     = subjects;
     _actions      = actions;
     _environments = environments;
 }
コード例 #2
0
ファイル: TargetElement.cs プロジェクト: zszqwe/anycmd
 /// <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)
 {
 }
コード例 #3
0
        /// <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 == Consts.Schema1.TargetElement.Target &&
                ValidateSchema(reader, schemaVersion))
            {
                if (!reader.IsEmptyElement)
                {
                    while (reader.Read())
                    {
                        switch (reader.LocalName)
                        {
                        case Consts.Schema1.TargetElement.Subjects:
                            _subjects = new SubjectsElementReadWrite(reader, schemaVersion);
                            break;

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

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

                        case Consts.Schema2.TargetElement.Environments:
                            _environments = new EnvironmentsElementReadWrite(reader, schemaVersion);
                            break;
                        }
                        if (reader.LocalName == Consts.Schema1.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(string.Format(Properties.Resource.exc_invalid_node_name, reader.LocalName));
            }
        }