Esempio 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)
     {
         SubjectMatchElementReadWrite     sItem = item as SubjectMatchElementReadWrite;
         ActionMatchElementReadWrite      aItem = item as ActionMatchElementReadWrite;
         ResourceMatchElementReadWrite    rItem = item as ResourceMatchElementReadWrite;
         EnvironmentMatchElementReadWrite 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));
         }
     }
 }
Esempio 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)
     {
         SubjectMatchElementReadWrite sItem = item as SubjectMatchElementReadWrite;
         ActionMatchElementReadWrite aItem = item as ActionMatchElementReadWrite;
         ResourceMatchElementReadWrite rItem = item as ResourceMatchElementReadWrite;
         EnvironmentMatchElementReadWrite 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));
         }
     }
 }
Esempio 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 )
		{
		}
Esempio n. 4
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)
 {
 }
Esempio n. 5
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 )
		{
		}
		/// <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;
		}
Esempio n. 7
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 )
		{
		}
Esempio n. 8
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="args"></param>
		private void CreateTargetItem( object sender, EventArgs args )
		{
			if( mainTree.SelectedNode is AnySubject )
			{
				AnySubject anyNode = (AnySubject)mainTree.SelectedNode;
				Target targetNode = (Target)anyNode.Parent;

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

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

				TargetItem 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 )
			{
				AnyAction anyActionNode = (AnyAction)mainTree.SelectedNode;
				Target targetNode = (Target)anyActionNode.Parent;

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

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

				TargetItem 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 )
			{
				AnyResource anyNode = (AnyResource)mainTree.SelectedNode;
				Target targetNode = (Target)anyNode.Parent;

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

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

				TargetItem 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;
			}			
		}
		/// <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 )
		{
		}
Esempio n. 10
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)
 {
 }
Esempio 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)
 {
 }
 /// <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;
 }
Esempio 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 TargetItemBase(TargetMatchReadWriteCollection match, XacmlVersion schemaVersion)
     : base(match, schemaVersion)
 {
 }