Transform SP Attribute Resolver: merging several into one value
Peter Schober
peter.schober at univie.ac.at
Thu Jan 16 08:48:28 EST 2014
The documentation[1] has this example for creating new 'sn' and
'givenName' attributes based on an existing 'displayName' attribute:
<AttributeResolver type="Transform" source="displayName">
<Regex match="^(.+) (.+)$" dest="givenName">$1</Regex>
<Regex match="^(.+) (.+)$" dest="sn">$2</Regex>
<Regex match="^(.+) (.+)$">$2, $1</Regex>
</AttributeResolver>
Now, how would I go about doing it the other way round, creating
displayName from "$sn $givenName"?
I tried starting with
<AttributeResolver type="Transform" source="sn givenName">
but source only seems to take a single attribute's id. (The
grammatical plural in the docs probably just takes into account that
more than one attribute can map to the same id).
So it seems I'd have to use several Resolver elements, one for each
source attribute? Something like
<AttributeResolver type="Transform" source="givenName">
<Regex match="^(.+)$" dest="displayName">$1</Regex>
</AttributeResolver>
<AttributeResolver type="Transform" source="sn">
<Regex match="^(.+)$" dest="displayName"> $1</Regex>
</AttributeResolver>
But that has two other issues:
1. A Regex rule with $1 as the only CDATA content (such as the one
with source="giveName" above) does not seem to create any values. If I
change it to e.g. '$1 ' (by adding a space to the end of the CDATA
string) the value from source get's though (and the space appended).
2. When resorting to several Attribute Resolver elements, several
values for the dest attribute are generated, so the result would be a
multi-valued attribute with "Firstname" and "Lastname" as
values. Which seems only logical.
Is merging several attributes's values into a single value of a single
attribute not possible with the current code, or am I Doing It Wrong?
Cheers,
-peter
[1] https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPAttributeResolver
More information about the users
mailing list