<taskModel xmlns="http://ce.org/cea-2018" about="urn:cetask.wpi.edu:examples:policytaskmodel">
	<!-- Access Control Policy Authoring Task Model
		 (Project for CS 525U)
		 Author: Paul Freitas
		 Date: 4/8/08 -->
		 
	<task id="AuthorPolicy">
		<output name="policy" type="string"/>
		<subtasks id="authoring" ordered="false">
			<step name="define" task="Define"/>
			<step name="initialize" task="InitializeMatrix" requires="define"/>
			<step name="fillin" task="FillInMatrix" requires="initialize"/>
			<step name="sanitycheck" task="SanityCheck" requires="fillin"/>
			<step name="create" task="CreatePolicy" requires="fillin sanitycheck"/>
			<binding slot="$initialize.roles" value="$define.roles"/>
			<binding slot="$initialize.actions" value="$define.actions"/>
			<binding slot="$this.policy" value="$create.output"/>
		</subtasks>
	</task>
	
	<task id="Define">
		<output name="roles" type="Array"/>
		<output name="actions" type="Array"/>
		<subtasks id="defineAll" ordered="false">
			<step name="roles" task="DefineRoles"/>
			<step name="actions" task="DefineActions"/>
			<step name="constraints" task="DefineConstraints" requires="roles actions"/>
			<binding slot="$this.roles" value="$roles.output"/>
			<binding slot="$this.actions" value="$actions.output"/>
		</subtasks>
	</task>
	
	<task id="DefineRoles">
		<output name="output" type="Array"/>
	</task>
	
	<task id="DefineActions">
		<output name="output" type="Array"/>
	</task>
	
	<task id="DefineConstraints">
	</task>
	
	<task id="InitializeMatrix">
		<input name="roles" type="Array"/>
		<input name="actions" type="Array"/>
		<postcondition> $matrix != undefined </postcondition>
		<script>
			$matrix = new ACMatrix($this.roles,$this.actions);
		</script>
	</task>
	
	<task id="FillInMatrix">
		<postcondition> $matrix != undefined &amp;&amp; $matrix.isFull() </postcondition>
		
		<subtasks id="Random" ordered="true">
			<step name="fillcell" task="FillInCell"/>
			<step name="fillrest" task="FillInMatrix"/>
		</subtasks>
		
		<subtasks id="RowWise" ordered="true">
			<step name="fillrow" task="FillInRow"/>
			<step name="fillrest" task="FillInMatrix"/>
		</subtasks>
		
		<subtasks id="ColWise" ordered="true">
			<step name="fillcol" task="FillInColumn"/>
			<step name="fillrest" task="FillInMatrix"/>
		</subtasks>
	</task>
	
	<task id="FillInCell">
		<input name="row" type="string"/>
		<input name="col" type="string"/>
		<input name="val" type="ACDecision"/>
		<postcondition> $matrix.get($this.row,$this.col) != undefined </postcondition>
		<script> $matrix.set($this.row,$this.col,$this.val); </script>
	</task>
	
	<task id="FillInRow">
		<input name="row" type="string"/>
		<postcondition> $matrix.isRowFull($this.row) </postcondition>
		
		<subtasks id="fill">
			<step name="fillcell" task="FillInCell" maxOccurs="unbounded"/>
			<binding slot="$fillcell.row" value="$this.row"/>
		</subtasks>
	</task>
	
	<task id="FillInCol">
		<input name="col" type="string"/>
		<postcondition> $matrix.isColFull($this.col) </postcondition>
		
		<subtasks id="fill">
			<step name="fillcell" task="FillInCell" maxOccurs="unbounded"/>
			<binding slot="$fillcell.col" value="$this.col"/>
		</subtasks>
	</task>
	
	<task id="SanityCheck">
		<postcondition> $matrix != undefined &amp;&amp; $constraints != undefined &amp;&amp; $matrix.isFull() &amp;&amp; checkConsistent($matrix,$constraints) </postcondition>
		
		<subtasks id="checkandfix">
			<step name="findconflicts" task="FindConflicts"/>
			<step name="resolveconflict" task="ResolveConflict" maxOccurs="unbounded"/>
			<step name="again" task="SanityCheck"/>
		</subtasks>
	</task>
	
	<task id="FindConflicts">
		<output name="output" type="Array"/>
		
		<script>
			$conflicts = findConflicts($matrix,$constraints); //make global so it's easily reachable from Java.
			$this.output = $conflicts;
		</script>
	</task>
	
	<task id="ResolveConflict">
		<input name="resolver" type="ConflictResolver"/>
		
		<script>
			$this.resolver.apply($matrix,$constraints);
		</script>
	</task>
	
	<task id="CreatePolicy">
		<output name="output" type="string"/>
		
		<script>
			$policy = createPolicy($matrix,$constraints);
			$this.output = $policy;
		</script>
	</task>
	
	<script init="true">
		<!-- This is just the basic initialization stuff...
				The definition of all the important functions and classes is in:
					 ACInit.xml : definitions for all objects and functions 
					 	related to the access control matrix
					 ConflictInit.xml : definitions for all objects and 
					 	functions related to conflicts between the access
					 	control matrix and the constraints list
					 ConstraintInit.xml : definitions for all objects and
					 	functions related to constraints
					 UtilitiesInit.xml : utility functions, mostly used by
					 	the tasks in this file.
					 XacmlInit.xml : functions that output an XACML policy
					 -->
		$matrix = undefined;
		$constraints = undefined;
		$conflicts = undefined;
		$policy = undefined;
		$debug = true;
	</script>
	
</taskModel>