Checking contextual integrity
Rod Widdowson
rdw at steadingsoftware.com
Thu May 23 14:32:18 EDT 2013
I just tripped over myself while filling in the missing Attribute filters,
and I think this might have a tie into an earlier discussion about Actions
not having boilerplate code to check that all the ducks have been lined up.
In my situation the filtering code has been given an AttributeFilterContext
and it needs to locate and AttributeRecipientContext (as per
https://wiki.shibboleth.net/confluence/display/IDP30/Attribute+Filtering+Eng
ine).
If it cannot find one of these it is in a bad situation. Within filters
there is no failsafe response; the filter could be a Deny - in which case
the fail safe is 'true', or a permit - in which case the failsafe is
'false'.
What I was considering was throwing an AttributeResolutionException if I
cannot find the recipient context. For structural reasons this will be
cumbersome - we are actually implementing a
Predicate<AttributeFilterContext> and Predicate#apply() does not throw
exceptions. Obviously this is easy to fix, although Tom and I are slightly
queasy about introducing a "ThrowingPredicate".
But I was wondering whether there is analogue here to the Action situation
and we can demand that (in the usual flow) before the attribute filtering
occurs, the context is inspected and the ability to find the
AttributeRecipientContext confirmed. That way the filtering code can just
locate the AttributeRecipientContext and its contents without fear of an NPE
and without throwing an exception. I suppose in this case it is "one step
out" and what I am proposing is an Action to check the context. Perhaps
even it is the same as the Action which populates it?
Or do I just learn to love living with ThrowingPredicates?
Rod
More information about the dev
mailing list