2014-10-09 5 views

답변

3

사용 사례는 매우 간단합니다. 난 당신이 ALFA 먼저하고 영어로 쓰기 추천 :

  • 사용자는 type==bank account의 자원에 action==transfer을 할 수있는 경우에만 경우 amount transferred < the amount limit (귀하의 경우 예를 들어, 2000) ==>허가
  • 다른 모든 경우 ==>

는 ALFA, 상기 정책이 될 거부 ​​

namespace policies{ 
    attribute actionId{ 
     category = actionCat 
     id = "actionId" 
     type = string 
    } 

    attribute resourceType{ 
     category = resourceCat 
     id = "resourceType" 
     type = string 
    } 

    attribute amount{ 
     category = resourceCat 
     id = "amount" 
     type = double 
    } 
    /** 
    * The limit could be a subject attribute in the case it's user-specific 
    */ 
    attribute limit{ 
     category = subjectCat 
     id = "limit" 
     type = double 
    } 

    /* 
    * A user can do the `action==transfer` on a resource of `type==bank account` if and only if the `amount transferred 
    * < the amount limit` (e.g. 2000 in your case) ==> **permit** 
    * 
    */ 
    policy transfer{ 
     target clause actionId == "transfer" and resourceType=="bank account" 
     apply firstApplicable 
     rule allow{ 
      condition amount <= limit 
      permit 
     } 
     rule denyTransfer{ 
      deny 
     } 
    } 
}