Ejemplo n.º 1
0
 /// <summary>
 /// Creates a TargetMatchCollection, with the items contained in a ReadWriteTargetMatchCollection
 /// </summary>
 /// <param name="items"></param>
 public TargetMatchCollection(TargetMatchReadWriteCollection items)
 {
     if (items == null)
     {
         throw new ArgumentNullException("items");
     }
     foreach (TargetMatchBaseReadWrite item in items)
     {
         var sItem = item as SubjectMatchElementReadWrite;
         var aItem = item as ActionMatchElementReadWrite;
         var rItem = item as ResourceMatchElementReadWrite;
         var eItem = item as EnvironmentMatchElementReadWrite;
         if (sItem != null)
         {
             this.List.Add(new SubjectMatchElement(sItem.MatchId, sItem.AttributeValue, sItem.AttributeReference, sItem.SchemaVersion));
         }
         else if (aItem != null)
         {
             this.List.Add(new ActionMatchElement(aItem.MatchId, aItem.AttributeValue, aItem.AttributeReference, aItem.SchemaVersion));
         }
         else if (rItem != null)
         {
             this.List.Add(new ResourceMatchElement(rItem.MatchId, rItem.AttributeValue, rItem.AttributeReference, rItem.SchemaVersion));
         }
         else if (eItem != null)
         {
             this.List.Add(new EnvironmentMatchElement(eItem.MatchId, eItem.AttributeValue, eItem.AttributeReference, eItem.SchemaVersion));
         }
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a TargetMatchCollection, with the items contained in a ReadWriteTargetMatchCollection
 /// </summary>
 /// <param name="items"></param>
 public TargetMatchCollection(TargetMatchReadWriteCollection items)
 {
     if (items == null) throw new ArgumentNullException("items");
     foreach (TargetMatchBaseReadWrite item in items)
     {
         var sItem = item as SubjectMatchElementReadWrite;
         var aItem = item as ActionMatchElementReadWrite;
         var rItem = item as ResourceMatchElementReadWrite;
         var eItem = item as EnvironmentMatchElementReadWrite;
         if (sItem != null)
         {
             this.List.Add(new SubjectMatchElement(sItem.MatchId, sItem.AttributeValue, sItem.AttributeReference, sItem.SchemaVersion));
         }
         else if (aItem != null)
         {
             this.List.Add(new ActionMatchElement(aItem.MatchId, aItem.AttributeValue, aItem.AttributeReference, aItem.SchemaVersion));
         }
         else if (rItem != null)
         {
             this.List.Add(new ResourceMatchElement(rItem.MatchId, rItem.AttributeValue, rItem.AttributeReference, rItem.SchemaVersion));
         }
         else if (eItem != null)
         {
             this.List.Add(new EnvironmentMatchElement(eItem.MatchId, eItem.AttributeValue, eItem.AttributeReference, eItem.SchemaVersion));
         }
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates a new instance of TargetItem using the specified arguments.
 /// </summary>
 /// <param name="match">The collection of target item matchs.</param>
 /// <param name="schemaVersion">The version of the schema that was used to validate.</param>
 protected TargetItemBase(TargetMatchReadWriteCollection match, XacmlVersion schemaVersion)
     : base(match, schemaVersion)
 {
 }
Ejemplo n.º 4
0
		/// <summary>
		/// Creates a new Resource with the specified aguments.
		/// </summary>
		/// <param name="match">The target item match collection.</param>
		/// <param name="version">The version of the schema that was used to validate.</param>
		public ResourceElement( TargetMatchReadWriteCollection match, XacmlVersion version )
			: base( match, version )
		{
		}
Ejemplo n.º 5
0
 /// <summary>
 /// Creates a new instance of Action using the specified arguments.
 /// </summary>
 /// <param name="match">The target item match collection.</param>
 /// <param name="version">The version of the schema that was used to validate.</param>
 public ActionElementReadWrite(TargetMatchReadWriteCollection match, XacmlVersion version) :
     base(match, version)
 {
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Creates a new Subject with the specified aguments.
 /// </summary>
 /// <param name="match">The target item match collection.</param>
 /// <param name="version">The version of the schema that was used to validate.</param>
 public SubjectElement(TargetMatchReadWriteCollection match, XacmlVersion version)
     : base(match, version)
 {
 }
Ejemplo n.º 7
0
		/// <summary>
		/// Creates a new Subject with the specified aguments.
		/// </summary>
		/// <param name="match">The target item match collection.</param>
		/// <param name="version">The version of the schema that was used to validate.</param>
		public SubjectElement( TargetMatchReadWriteCollection match, XacmlVersion version )
			: base( match, version )
		{
		}
Ejemplo n.º 8
0
		/// <summary>
		/// Creates a new instance of TargetItem using the specified arguments.
		/// </summary>
		/// <param name="match">The collection of target item matchs.</param>
		/// <param name="schemaVersion">The version of the schema that was used to validate.</param>
		protected TargetItemBase( TargetMatchReadWriteCollection match, XacmlVersion schemaVersion )
			: base( match, schemaVersion )
		{
		}
		/// <summary>
		/// Creates a new instance of Environment using the specified arguments.
		/// </summary>
		/// <param name="match">The target item match collection.</param>
		/// <param name="version">The version of the schema that was used to validate.</param>
		public EnvironmentElementReadWrite( TargetMatchReadWriteCollection match, XacmlVersion version ) : 
			base( match, version )
		{
		}
Ejemplo n.º 10
0
 /// <summary>
 /// Creates a new instance of TargetItem using the specified arguments.
 /// </summary>
 /// <param name="match">The collection of target item matchs.</param>
 /// <param name="schemaVersion">The version of the schema that was used to validate.</param>
 protected TargetItemBaseReadWrite(TargetMatchReadWriteCollection match, XacmlVersion schemaVersion)
     : this(schemaVersion)
 {
     _match = match;
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Creates a new Resource with the specified aguments.
 /// </summary>
 /// <param name="match">The target item match collection.</param>
 /// <param name="version">The version of the schema that was used to validate.</param>
 public ResourceElement(TargetMatchReadWriteCollection match, XacmlVersion version)
     : base(match, version)
 {
 }
Ejemplo n.º 12
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void CreateTargetItem(object sender, EventArgs args)
        {
            if (_mainTree.SelectedNode is AnySubject)
            {
                var anyNode = (AnySubject)_mainTree.SelectedNode;
                var targetNode = (Target)anyNode.Parent;

                int idx = targetNode.Nodes.IndexOf(anyNode);
                targetNode.Nodes.RemoveAt(idx);

                var matchCollection = new TargetMatchReadWriteCollection();
                matchCollection.Add(
                    new SubjectMatchElementReadWrite(
                        Consts.Schema1.InternalFunctions.StringEqual,
                        new AttributeValueElementReadWrite(Consts.Schema1.InternalDataTypes.XsdString, "Somebody", XacmlVersion.Version11),  //TODO: check version
                        new SubjectAttributeDesignatorElement(Consts.Schema1.InternalDataTypes.XsdString, false, Consts.Schema1.SubjectElement.ActionSubjectId, "", "", XacmlVersion.Version11), XacmlVersion.Version11));  //TODO: check version
                var targetItem = new SubjectElementReadWrite(matchCollection, XacmlVersion.Version11);  //TODO: check version

                var targetItemNode = new TargetItem(targetItem);

                targetNode.Nodes.Insert(idx, targetItemNode);
                targetNode.TargetDefinition.Subjects.IsAny = false;
                targetNode.TargetDefinition.Subjects.ItemsList.Add(targetItem);
                targetItemNode.NodeFont = new Font(_mainTree.Font, FontStyle.Bold);

                _mainTree.SelectedNode = targetItemNode;
            }
            else if (_mainTree.SelectedNode is AnyAction)
            {
                var anyActionNode = (AnyAction)_mainTree.SelectedNode;
                var targetNode = (Target)anyActionNode.Parent;

                int idx = targetNode.Nodes.IndexOf(anyActionNode);
                targetNode.Nodes.RemoveAt(idx);

                var matchCollection = new TargetMatchReadWriteCollection
                {
                    new ActionMatchElementReadWrite(
                        Consts.Schema1.InternalFunctions.StringEqual,
                        new AttributeValueElementReadWrite(Consts.Schema1.InternalDataTypes.XsdString, "DoSomething",
                            XacmlVersion.Version11), //TODO: check version
                        new ActionAttributeDesignatorElement(Consts.Schema1.InternalDataTypes.XsdString, false,
                            Consts.Schema1.ActionElement.ActionId, "", XacmlVersion.Version11), XacmlVersion.Version11)
                };
                var action = new ActionElementReadWrite(matchCollection, XacmlVersion.Version11); //TODO: check version

                var actionNode = new TargetItem(action);

                targetNode.Nodes.Insert(idx, actionNode);
                targetNode.TargetDefinition.Actions.IsAny = false;
                targetNode.TargetDefinition.Actions.ItemsList.Add(action);
                actionNode.NodeFont = new Font(_mainTree.Font, FontStyle.Bold);

                _mainTree.SelectedNode = actionNode;
            }
            else if (_mainTree.SelectedNode is AnyResource)
            {
                var anyNode = (AnyResource)_mainTree.SelectedNode;
                var targetNode = (Target)anyNode.Parent;

                int idx = targetNode.Nodes.IndexOf(anyNode);
                targetNode.Nodes.RemoveAt(idx);

                var matchCollection = new TargetMatchReadWriteCollection
                {
                    new ResourceMatchElementReadWrite(
                        Consts.Schema1.InternalFunctions.StringEqual,
                        new AttributeValueElementReadWrite(Consts.Schema1.InternalDataTypes.XsdString, "Something",
                            XacmlVersion.Version11), //TODO: check version
                        new ResourceAttributeDesignatorElement(Consts.Schema1.InternalDataTypes.XsdString, false,
                            Consts.Schema1.ResourceElement.ResourceId, "", XacmlVersion.Version11),
                        XacmlVersion.Version11)
                };
                var targetItem = new ResourceElementReadWrite(matchCollection, XacmlVersion.Version11); //TODO: check version

                var targetItemNode = new TargetItem(targetItem);

                targetNode.Nodes.Insert(idx, targetItemNode);
                targetNode.TargetDefinition.Resources.IsAny = false;
                targetNode.TargetDefinition.Resources.ItemsList.Add(targetItem);
                targetItemNode.NodeFont = new Font(_mainTree.Font, FontStyle.Bold);

                _mainTree.SelectedNode = targetItemNode;
            }
        }
Ejemplo n.º 13
0
 /// <summary>
 /// Creates a new instance of TargetItem using the specified arguments.
 /// </summary>
 /// <param name="match">The collection of target item matchs.</param>
 /// <param name="schemaVersion">The version of the schema that was used to validate.</param>
 protected TargetItemBaseReadWrite(TargetMatchReadWriteCollection match, XacmlVersion schemaVersion)
     : this(schemaVersion)
 {
     _match = match;
 }