+ WebACL definition based on imported WebACLs and local Authorizations webacl
authorbertails
Fri, 18 Nov 2011 16:40:25 -0500
branchwebacl
changeset 127 550497ea4999
parent 126 ec7f77470ced
child 130 aa09c5e9d204
+ WebACL definition based on imported WebACLs and local Authorizations
src/main/scala/webacl/RWWacls.scala
src/main/scala/webacl/webacl.scala
--- a/src/main/scala/webacl/RWWacls.scala	Fri Nov 18 16:15:55 2011 -0500
+++ b/src/main/scala/webacl/RWWacls.scala	Fri Nov 18 16:40:25 2011 -0500
@@ -6,4 +6,6 @@
 case object append extends RWWAction
 case object control extends RWWAction
 
-trait RWWAuthorization extends Authorization[RWWAction]
\ No newline at end of file
+trait RWWAuthorization extends Authorization {
+  override val actions: Seq[RWWAction]
+}
\ No newline at end of file
--- a/src/main/scala/webacl/webacl.scala	Fri Nov 18 16:15:55 2011 -0500
+++ b/src/main/scala/webacl/webacl.scala	Fri Nov 18 16:40:25 2011 -0500
@@ -3,15 +3,28 @@
 import java.net.{URI, URL}
 import scala.util.matching.Regex
 
-trait Authorization[A <: Action] {
+case class WebACL(
+    imports: Seq[WebACL],
+    authorizations: Seq[Authorization]) {
   
-  val agentPolicies: Set[AcceptedAgentPolicy]
-  val actions: Set[A]
-  val accessTo: Set[ResourcePolicy]
+  def authorized(
+      agent: Agent,
+      action: Action,
+      accessedResource: URL): Boolean =
+    (authorizations exists { _.authorized(agent, action, accessedResource) }) ||
+    (imports exists { _.authorized(agent, action, accessedResource) })
+}
+
+
+trait Authorization {
+  
+  val agentPolicies: Seq[AcceptedAgentPolicy]
+  val actions: Seq[Action]
+  val accessTo: Seq[ResourcePolicy]
   
   final def authorized(
       agent: Agent,
-      action: A,
+      action: Action,
       accessedResource: URL): Boolean = {
     def agentIsConcernedBySomePolicy = agentPolicies exists { _ concerns agent }
     def knownAction = actions contains action