2017-03-21 7 views
1

ブール値のバッグがあるとします。 「本当の」値の数がいくつかの定数(例えば5)よりも大きいかどうかを知る関数がありますか?XACMLバッグ操作

私は "n-of"関数に出くわしましたが、入力として複数の別個の属性を必要としました...おそらく "map"関数は助けになるかもしれませんが、バッグ内のアイテムの数を減らすことができます。

ありがとうございます!マイケル 。あなたが探しているものを達成するために

答えて

0

、あなたは2つの機能を使用する必要があります。

  • 例えば、袋の大きさを測定機能booleanBagSize(someAttribute)
  • バッグの各値が真であることをチェックするファンクション。例えばbooleanEqualsは、より高次の関数、例えば、 AllOf

ALFAにおける結果のコードは次のようになります。

namespace axiomatics{ 
    attribute allowed{ 
     category = subjectCat 
     id = "axiomatics.allowed" 
     type = boolean 
    } 
    policy allowIf5True{ 
     apply firstApplicable 
     rule allow{ 
      permit 
      condition booleanBagSize(allowed)>5 && allOf(function[booleanEqual], true, allowed) 
     } 
    } 
} 

そして、XACML 3.0の出力は、袋が唯一の真の値が含まれている場合にのみ動作し、このアプローチ

<?xml version="1.0" encoding="UTF-8"?> 
<!--This file was generated by the ALFA Plugin for Eclipse from Axiomatics AB (http://www.axiomatics.com). 
Any modification to this file will be lost upon recompilation of the source ALFA file--> 
<xacml3:Policy xmlns:xacml3="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17" 
    PolicyId="http://axiomatics.com/alfa/identifier/axiomatics.allowIf5True" 
    RuleCombiningAlgId="urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:first-applicable" 
    Version="1.0"> 
    <xacml3:Description /> 
    <xacml3:PolicyDefaults> 
     <xacml3:XPathVersion>http://www.w3.org/TR/1999/REC-xpath-19991116</xacml3:XPathVersion> 
    </xacml3:PolicyDefaults> 
    <xacml3:Target /> 
    <xacml3:Rule 
      Effect="Permit" 
      RuleId="http://axiomatics.com/alfa/identifier/axiomatics.allowIf5True.allow"> 
     <xacml3:Description /> 
     <xacml3:Target /> 
     <xacml3:Condition> 
      <xacml3:Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:and"> 
       <xacml3:Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:integer-greater-than"> 
        <xacml3:Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:boolean-bag-size" > 
         <xacml3:AttributeDesignator 
          AttributeId="axiomatics.allowed" 
          DataType="http://www.w3.org/2001/XMLSchema#boolean" 
          Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" 
          MustBePresent="false" 
         /> 
        </xacml3:Apply> 
        <xacml3:AttributeValue 
         DataType="http://www.w3.org/2001/XMLSchema#integer">5</xacml3:AttributeValue> 
       </xacml3:Apply> 
       <xacml3:Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:all-of" > 
        <xacml3:Function FunctionId="urn:oasis:names:tc:xacml:1.0:function:boolean-equal"/> 
        <xacml3:AttributeValue 
         DataType="http://www.w3.org/2001/XMLSchema#boolean">true</xacml3:AttributeValue> 
        <xacml3:AttributeDesignator 
         AttributeId="axiomatics.allowed" 
         DataType="http://www.w3.org/2001/XMLSchema#boolean" 
         Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" 
         MustBePresent="false" 
        /> 
       </xacml3:Apply> 
      </xacml3:Apply> 
     </xacml3:Condition> 
    </xacml3:Rule> 
</xacml3:Policy> 

だろう。

+0

返信ありがとうDavid!私の主な使用事例は、バッグに真の値だけでなく偽の値が含まれている場合です。バッグに複数の真偽値がある場合、「真の」値の数を調べる/カウントする/チェックする方法はありますか? – Michael

+0

私はそれを少し考えさせてください。 Axiomatics Policy Serverでは、いつでもカスタム機能をコーディングすることができます。しかし、XACMLでは一般に、いくつかの値の数は気にしません。あなたは彼らの存在を気にします。 –

+0

私は標準のXACML関数のみを使用したいと思います...あなたがこれを解決する方法を知っていれば教えてください。ありがとう! – Michael