【发布时间】:2014-05-15 06:10:04
【问题描述】:
不在 XACML 中的函数要求一个布尔参数。但是,我想表达“非男性”等“非字符串”之类的政策。我不能用“非性别 == 男性”来代替它。我搜索了谷歌和stackoverflow,但我未能解决这个问题。我怎么能这样做?
【问题讨论】:
不在 XACML 中的函数要求一个布尔参数。但是,我想表达“非男性”等“非字符串”之类的政策。我不能用“非性别 == 男性”来代替它。我搜索了谷歌和stackoverflow,但我未能解决这个问题。我怎么能这样做?
【问题讨论】:
当您发送 XACML 请求时,您总是会发送一组带有一个或多个值的属性。您可以发送:
无论哪种方式,您仍然可以发送属性。在一种情况下,该值是一个字符串。在另一个值是一个字符串。在下面的解释中,我采用了字符串方法。如果您想要布尔方法,只需将 gender=="male" 替换为 male。
请注意,在 XACML 中,属性可能没有值。这使得 XACML 布尔值不仅仅是布尔值。男性可以是真、假或未定义。编写策略/规则时请记住这一点。
表达否定条件,例如not(gender==male),你有两种选择:
在前一种情况下,您可以编写以下内容(ALFA 中的伪代码):
policy checkGender{
apply firstApplicable
rule male{
target clause gender=="male"
permit
}
rule female{
target clause gender=="female"
permit
}
/**
* Optionally add a catch all case
*/
rule other{
target clause ... // Here you'd have to define other checks you are interested in
}
}
在后一种情况下,你需要写一个否定条件。为此,您需要使用 XACML 条件。由于 XACML 条件只存在于规则中,因此您需要深入到 XACML 规则级别。
policy checkGender{
apply firstApplicable
rule notMale{
condition not(gender=="male")
permit
}
}
【讨论】: