我想寫一條規則,使用條件語句構建一個 XACML函數:「urn:oasis:names:tc:xacml:2.0:function:time-in-範圍「使用ALFA語言語法。爲了方便義務處理,我寧願在條件函數中使用它,而不是在目標表達式中使用它。
這可能嗎?手冊中沒有提及它。XACML規則的時間範圍作爲條件
at @David Brossard。根據該協議在下面,我用下面的代碼ALFA測試的政策:
namespace com.ibm.XACML {
import Attributes.*
import attributes.*
import com.ibm.XACML.Attributes.*
attribute currentTime {
id = "urn:oasis:names:tc:xacml:1.0:environment:current-time"
type = time
category = environmentCat
}
function timeInRange = "urn:oasis:names:tc:xacml:2.0:function:time-in-range" : time time time -> boolean
// lowerBound = "09:00:00-03:00"
// upperBound = "18:00:00-03:00"
// current-time = "02:00:00-03:00" decision permit
// current-time = "10:00:00-03:00" decision permit
// current-time = "22:00:00-03:00" decision permit
policy checkTimeInRange{
apply firstApplicable
rule allowWithinRange{
permit
condition timeInRange(timeOneAndOnly(currentTime), timeOneAndOnly(timeBag("09:00:00-03:00":time)), timeOneAndOnly(timeBag("19:00:00-03:00":time)))
}
}
}
的語法驗證運行正常,但在評價結果從WSO2 PDP代碼返回一個錯誤,給人一種「證「對於所有三項測試,02:00:00,10:00:00和22:00:00。
我已經隔離了這個問題。 WSO2 Try-It工具默認生成「String」,而XACML需要時間數據類型。爲了解決這個問題,必須提供手動請求,@David Brossard顯示的邏輯完美運行。這裏有一個示例請求,生成一個「許可證」。
<Request xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" CombinedDecision="false" ReturnPolicyIdList="false">
<Attributes Category="urn:oasis:names:tc:xacml:3.0:attribute-category:environment">
<Attribute AttributeId="urn:oasis:names:tc:xacml:1.0:environment:current-time" IncludeInResult="false">
<AttributeValue DataType="http://www.w3.org/2001/XMLSchema#time">11:00:00-03:00</AttributeValue>
</Attribute>
</Attributes>
</Request>
將「TimeInRange」函數與條件語句相結合非常有用。
你指的是什麼手冊? WSO2不支持ALFA ... –
親愛的@David Brossard。參考.doc規範「用於ALFA語言的授權版本1.0的縮寫語言」,工作草案01.我正在ALFA eclipse代碼編輯器下重寫一些XACML策略。由於它支持常見的算法,比如布爾邏輯,條件的構建是有用的,它的程序員和代碼更友好。範圍函數中的時間將是有用的。 –