【发布时间】:2016-07-01 16:45:20
【问题描述】:
我想编写一个使用条件语句构建一个规则的规则
XACML 函数:“urn:oasis:names:tc:xacml:2.0:function:time-in-range”使用 ALFA 语言语法。出于易于处理义务的原因,我更愿意在条件函数中使用它,而不是在目标表达式中。
这可能吗?我在手册中没有找到任何参考。
@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 工具默认生成“字符串”,而 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。参考 ALFA 语言的 .doc 规范“授权版本 1.0 的缩写语言”,工作草案 01。我正在 ALFA eclipse 代码编辑器下重写一些 XACML 策略。条件的构造很有用,它对程序员和代码更友好,因为它支持常见的算法,如布尔逻辑。范围内的时间函数会很有用。
标签: authorization access-control xacml abac alfa