Does XACML distinguish between "attribute value is null" and "attribute is missing" - xacml

I am reading latest XACML specification and as far as I can see, there is no notion of null for attribute values. Is this true?
So, am I right saying that AttributeDesignator with MustBePresent=false should return empty bag if requested attribute's value is null? And vice versa, AttributeDesignator with MustBePresent=true should return Indeterminate if requested attribute's value is null?
So, is it true that XACML is not able to distinguish between "attribute value is null" and "attribute is missing" situations?
Or is that just out of the scope of the standard and is implementation-dependent?

In XACML an AttributeDesignator conceptually evaluates to a bag of attribute values. That bag may be empty.
As far as I know none of the XACML datatypes can have null values. i.e. there is no concept of null attribute value in XACML.
However, do note though that an empty string is a valid string, although it's not null.

Related

What are the truthy and falsy values in Raku?

While it is always possible to use mixins or method overrides to modify the Bool coercions, by default what values are considered to be truthy and what values are considered to be falsy?
Note: this question was asked previously, but unfortunately it is so old its content is completely out of date and useless is modern Raku.
There are no truthy values, as each type decides for itself via a .Bool method that is called in boolean contexts. For built-in types, the following return False when their .Bool method is called.
0 (except Rat of x/0 where x≠0)
Empty list/collection types (List, Array, Hash, Map, Set, Bag, etc)
Empty string
Failure
Promise prior to being kept/broken.
StrDistance whose before/after is the same.
Junction, when you expect it to.
Type objects
Nil (technically type object)
Any undefined value (technically type objects)
Otherwise, any defined value by default returns True when its .Bool method is called. This includes the Str '0', NaN, and zero-length range (0^..^0) that in other languages might not be truthy.
This answer is intended as a quick reference. See this answer for a more detailed discussion.
TL;DR This answer is an exhaustive summary based on the relevant doc.1
The base case2 is True for a defined object (an instance) and False for an undefined one (a type object).
Numerically 0 values or 0/0 are False. (But a Rational with a non-zero numerator eg 1/0 is True and (0/0).Num (which evaluates to NaN) is True.)
An empty collection (List, Hash, Set, Buf, etc) is False.
An empty string (eg literal "") is False. (NB. "0", "0.0" etc. are True.)
A defined Failure is False.
A defined Promise is False until its status becomes Kept/Broken.
A defined StrDistance is False if the string transformation it represents had no effect on the string being transformed.
A defined Junction is True or False depending on the junction's type and the True/False values of its elements.
Footnotes
1 I wrote the first bullet item based on just knowing it to be true because it's fundamental to P6 and also confirming it by checking the compiler's code.2 The other bullet points summarize the content at the time of writing this answer of the .Bool doc page at which point it listed 20 types. If the latter page was incomplete then this answer is incomplete.
2 The base case can be seen by looking at the Rakudo implementation code, in particular the core's Mu.pm6. See my answer to a similarish SO for relevant code links.

Just check for existence in ALFA target clause

I want write a target clause that says "If a certain attribute is set (oneAndOnly), then the policy applies". I have seen the [mustbepresent] thing, however, it always requires a comparator (like ==).
This was my approch, but the syntax checker complains...
policy reportPolicies {
target clause stringBagSize(my.company.person.doctor.id)==1
}
I've seen you defining a string attribute "resourceType" but I don't like to define such a meta attribute. I'd rather like to check for existence of certain attributes.
Again, great questions. Yes I often use an artificial attribute e.g. resourceType and compare it to values e.g. medical record or transaction. You do not have to do that because the attribute identifiers themselves convey the fact that you are dealing with one or another. However, I do think that it helps the policy be more readable.
On to the other issue: how to make sure an attribute has at least one value. In a Target element you can use the mustBePresent tag but I do not like it. If the attribute has no value, then the PDP returns Indeterminate and it short-circuits evaluation.
An alternative is to compare an attribute using > (greater than). For instance:
clause user.role > ""
clause user.age>0
That will force the value to be defined.
The cleaner way to do this, though, is to use bag functions inside a condition. For instance
condition stringBagSize(user.role)>0 // True if the user has at least one role

Mulesoft MEL Expression Get String Value Of Payload Data Type

I want to extract my payload's class name in a MUnit assert so I can verify the payload is always of the correct type. I've tried 2 MEL expressions, but both return null in the MEL expression evaluator. The funny thing is that if I remove the .name part of the expression then I see a key called "name" with the value that I need. Any ideas?
payload.class.name
message.dataType.type.name
One way is: #[payload.getClass().getSimpleName()]

Check/display the declared type of an entity (variable, expression...)

I am investigating types in VB especially in VBA. Generally, given an entity there are two types: Effective value type, I guess, is defined as value types in this part of the specification; Declared Type is defined in this part of the specification.
To do tests, I need to use some functions to check types. There are TypeName and VarType. I think they are used to check effective value type of an entity, because TypeName can return DBNull, Decimal and Nothing; VarType can return vbNull, vbEmpty, vbError and vbDecimal. These types exist in the table of effective value types, but not in the table of declared type.
So now, my question is, does anyone know how to check/display the declared type of an entity (variable, expression...)?
Edit 1: Probably for a variable, its declared type is just the type that the declaration of the variable specifies. I would like to insist that, it seems that VBA has declared type for expressions. For instance, Operator Declared Type is mentioned in this link. I think that refers to the declared type of the result of an operation. That means such entities as -i, i+5, i>6... can have a declared type. I would like to know how to display their declared type.
If,
Dim i as integer
i = 6/3
then you do, TypeName(i>3)
it returns Boolean which is the expression's Type based on the Type of the resulting value it holds not operand's declare type. And it complies with the specification given in your link for msdn 2.2 Entities and Declared Types.
Or else are you looking for a syntax/function (e.g. DType, imaginative function) that could return DType(i>3) as integer which is operand's (i) Type? Or rather it's more useful when you have multiple variables within some expression, so you can find all their Types in one go?
e.g. some String that combined all sorts of different TYPE variables in one expressoin.
Just trying to understand when and how this can be useful to you and what could be the end result you are looking for.. Seems like this is more to lanague root definitions.
PS: I do not have reps points to comment. So I added as an answer.

Core Data - Fetch object with optional attribute

I have an EntityA which has an optional attribute int32 result. When I create EntityA I do not set the result attribute. Then later on when I fetch it I expect it to have nil value but for some reason it's set to 3 even though I have not set this attribute.
What's going on here?
1st possible issue:
You have set a default value in the model editor. Select the attribute and check the inspector.
2nd possible issue:
You are retrieving or showing the wrong value. Show the code you are using to find out that result is '3'.
3rd possible issue:
You are setting the value later inadvertently, perhaps in a loop or something similar. Do a text search for the attribute to find a possible occurrence in your code.
Your int32 will be stored wrapped into a NSNumber object. If you don't provide a value, no NSNumber object will be created - sql will treat it as NULL.
The iOS Core Data Programming Guide says:
You can specify that an attribute is optional—that is, it is not
required to have a value. In general, however, you are discouraged
from doing so—especially for numeric values (typically you can get
better results using a mandatory attribute with a default value—in the
model—of 0). The reason for this is that SQL has special comparison
behavior for NULL that is unlike Objective-C's nil. NULL in a database
is not the same as 0, and searches for 0 will not match columns with
NULL.
So, it may be better to either make the attribute mandatory and set it to a distinct value, or to pass in NSNumber from the start.