On Wed, 2014-02-26 at 18:14 +0000, Jon Warbrick wrote:
>
> I'm fairly sure that's because (in this case)
> extensionAttribute1.getValues() is an array of length zero, hence the
> IndexOutOfBoundsException when you try to access element 0.
>
> I suspect (though I haven't tested it) that you want something like
>
> if (extensionAttribute1.getValues().length() == 1) {
>
> (or perhaps >= 1 if there might be more than one value. And I'm slightly
> puzzled because as far as I can see that should be
>
> if (extensionAttribute1.getValues().length == 1) {
>
> because I think length is a property of an array, not a method [1]...
>
Hello Jon,
Thanks for the reply. However...
(Easy bit first) - if I use 'length()' I get an error:
...ScriptletAttributeDefinition eduPersonAffiliation unable to execute
script
...Cannot find function length in object [].
If I use just 'length' then I don't get an error.
However, if I ask what the length is I get undefined:
...Resolved attribute extensionAttribute1 containing 1 values
...
...JH: EA1 length is: undefined
That was from the line:
if (typeof extensionAttribute1 != "undefined" &&
extensionAttribute1 != null) {
logger.debug("JH: EA1 length is: " +
extensionAttribute1.getValues().length);
I think I have tried most options regarding this now. As said before, it
seems that shibboleth will create variables from the returned LDAP
attributes. As such the 'typeof' and '!= null' conditions will always be
true.
The problem is that I have no idea what type of object
'extensionAttribute1' actually is - I assume it is just created using
'var extensionAttribute1'. Because of that, it is probably not an array
- hence why the getValues doesn't seem to work. Yet if I do something
like 'extensionAttribute1.length' it doesn't like that either.
If ask the typeof for extensionAttribute1 it just returns 'object'.
As can be seen above shibboleth says that EA1 has one value, but trying
to find out what that value is is proving difficult.
I'll do more testing.
> BTW I managed to setup real logging in my attribute resolver with e.g:
>
> importPackage(Packages.org.slf4j);
> logger = LoggerFactory.getLogger("edu.internet2.middleware.shibboleth.resolver.Script.eResources");
>
> after which I could go
>
> logger.debug("staff = true");
>
Ah! Thanks very much for that. I got the import bit, but couldn't work
out the 'edu.internet2...' bit in the second line.
John.
--
----------------------------------------------------
John Horne Tel: +44 (0)1752 587287
Plymouth University, UK Fax: +44 (0)1752 587001
|