【问题标题】:XACML - How to express "not male" rather than "not gender == male" [duplicate]XACML - 如何表达“非男性”而不是“非性别==男性”[重复]
【发布时间】:2014-05-15 06:10:04
【问题描述】:

不在 XACML 中的函数要求一个布尔参数。但是,我想表达“非男性”等“非字符串”之类的政策。我不能用“非性别 == 男性”来代替它。我搜索了谷歌和stackoverflow,但我未能解决这个问题。我怎么能这样做?

【问题讨论】:

    标签: xacml alfa


    【解决方案1】:

    当您发送 XACML 请求时,您总是会发送一组带有一个或多个值的属性。您可以发送:

    • 具有标识符性别、数据类型字符串和类别主题的属性,或
    • 具有标识符 male、数据类型 boolean 和类别主题的属性。

    无论哪种方式,您仍然可以发送属性。在一种情况下,该值是一个字符串。在另一个值是一个字符串。在下面的解释中,我采用了字符串方法。如果您想要布尔方法,只需将 gender=="male" 替换为 male。

    请注意,在 XACML 中,属性可能没有值。这使得 XACML 布尔值不仅仅是布尔值。男性可以是真、假或未定义。编写策略/规则时请记住这一点。

    表达否定条件,例如not(gender==male),你有两种选择:

    • 任一可能值的集合都是有限的,例如真/假、男/女、热/暖/冷,您很乐意为每个案例制定政策或规则。
    • 或可能值集太长或无限,例如数值或公民身份列表(其中 180 多个)。

    在前一种情况下,您可以编写以下内容(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
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-03-04
      • 1970-01-01
      • 2017-04-04
      • 2015-07-10
      • 1970-01-01
      • 1970-01-01
      • 2017-04-13
      • 2020-03-09
      相关资源
      最近更新 更多