resolver script checking no value of attribute; .length vs size()
Les LaCroix
llacroix at carleton.edu
Mon Apr 25 21:05:27 UTC 2022
David,
The code isn't quite the same as the working examples. The broken one says
"...size != 0" but the working examples say "size() != 0" (method call).
-Les
<http://www.carleton.edu/>
*Les LaCroix '79*
Strategic Technologist
Information Technology Services
t: (507) 222-5455
On Mon, Apr 25, 2022 at 1:31 PM IAM David Bantz via users <
users at shibboleth.net> wrote:
> This little script (inside the EdReadyRole attribute definition) to add a
> default value if a dependent attribute did not assign value:
>
> if (typeof EdReadyEntitlement != “undefined” && EdReadyEntitlement != null && EdReadyEntitlement.getValues().size !=0)
> {value = EdReadyEntitlement.getValues().get(0);
> EdReadyRole.addValue(value);}
> else
> {EdReadyRole.addValue(“Student”);}
>
>
> triggers this error if the attribute EdReadyEntitlement is in fact empty:
>
> 'EdReadyRole':Script did not run successfully
> at net.shibboleth.idp.attribute.resolver.ad.impl.ScriptedAttributeDefinition$AttributeDefinitionScriptEvaluator.execute(ScriptedAttributeDefinition.java:228)
> Caused by: java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
>
>
> A colleague smartly told me to replace .size() with .length, which does in
> fact work without triggering the error. I do not really understand why,
> given the existence of > 20 other instances of precisely parallel tests of
> non-existence of dependent attribute in my resolver, accumulated over many
> years. e.g.,
>
> if (typeof uakStudentMAU != "undefined" && uakStudentMAU != null &&
> uakStudentMAU.getValues().*size()* != 0)
>
> if (typeof mauPrimaryAffiliation != "undefined" && mauPrimaryAffiliation
> != null && mauPrimaryAffiliation.getValues().*size()* != 0)
>
> …
>
>
> Should I replace all the .size() with .length condition?
>
>
> *Feel free to administer virtual dope slap if accompanied by good
> explanation!*
>
>
> David St Pierre Bantz
>
>
> --
> For Consortium Member technical support, see
> https://shibboleth.atlassian.net/wiki/x/ZYEpPw
> To unsubscribe from this list send an email to
> users-unsubscribe at shibboleth.net
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://shibboleth.net/pipermail/users/attachments/20220425/dca70c60/attachment.htm>
More information about the users
mailing list