Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add shortcut functions for testing bag sizes. #23

Open
steven-legg opened this issue May 20, 2024 · 2 comments
Open

Add shortcut functions for testing bag sizes. #23

steven-legg opened this issue May 20, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@steven-legg
Copy link

steven-legg commented May 20, 2024

I regularly need to test whether a bag of values (usually from an attribute designator) is empty or non-empty. With the current XACML functions that means comparing the bag size to zero.

<!-- empty -->
<Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:integer-equal">
  <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-bag-size">
    <AttributeDesignator
                Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource"
                AttributeId="http://example.com/some-attribute"
                DataType="http://www.w3.org/2001/XMLSchema#string"  MustBePresent="false"/>
   </Apply>
  <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#integer"
    >0</AttributeValue>
</Apply>

<!-- non-empty -->
<Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:integer-greater-than">
  <Apply FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-bag-size">
    <AttributeDesignator
                Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource"
                AttributeId="http://example.com/some-attribute"
                DataType="http://www.w3.org/2001/XMLSchema#string"  MustBePresent="false"/>
   </Apply>
  <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#integer"
    >0</AttributeValue>
</Apply>

There would be less clutter if there were shortcut functions to perform these tests, which could be added to both XACML 3.0 and XACML 4.0 .

urn:oasis:names:tc:xacml:3.0:function:empty-bag
urn:oasis:names:tc:xacml:3.0:function:non-empty-bag

An alternative name for non-empty-bag would be populated-bag. It would be a simple matter to define a pair of functions that take bags of any data type rather than a pair for each data-type.

<Apply FunctionId="urn:oasis:names:tc:xacml:3.0:function:empty-bag">
  <AttributeDesignator
              Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource"
              AttributeId="http://example.com/some-attribute"
              DataType="http://www.w3.org/2001/XMLSchema#string"  MustBePresent="false"/>
 </Apply>

<Apply FunctionId="urn:oasis:names:tc:xacml:3.0:function:non-empty-bag">
  <AttributeDesignator
              Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource"
              AttributeId="http://example.com/some-attribute"
              DataType="http://www.w3.org/2001/XMLSchema#string"  MustBePresent="false"/>
</Apply>
@steven-legg steven-legg added the enhancement New feature or request label May 20, 2024
@steven-legg
Copy link
Author

steven-legg commented May 21, 2024

The XPath test for a non-empty sequence is called "exists".
The test is analogous to an LDAP present match.

@cdanger
Copy link

cdanger commented Jul 8, 2024

Just a suggestion: I'm ok with this, but considering there is the alternative with the bag-size function, should we rather specify these shortcut functions as optional / not mandatory? Part of a profile?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants