using Transform AttributeResolver to get first value of multi-value attribute

Wesley Schaft wesley.schaft at gmail.com
Tue Mar 22 04:22:36 EDT 2016


Hi all,

I would like to strip the multi-value mail attribute
(urn:mace:dir:attribute-def:mail) we're receiving from an IDP and only use
the first value found.

For example:

- if the mail attribute is a multi-value: Jordan.Belfort at harvard-example.edu
;jordan at harvard-example.edu , then only return
Jordan.Belfort at harvard-example.edu
- if the mail attribute is a single value: s1869831907 at example.org , then
only return s1869831907 at example.org

I thought I could fix that with the Transform AttributeResolver, but it
didn't gave me the correct results. This is what I've tried:

<AttributeResolver type="Transform" source="Shib-email">
    <Regex match="^([\w\. at -]+)" dest="mymail1">$1</Regex>
</AttributeResolver>

Result for "s1869831907 at example.org":
mymail1:
(yes, empty result)

Result for "Jordan.Belfort at harvard-example.edu;jordan at harvard-example.edu":
mymail1:
(yes, also empty)

First I thought it had something to do with my regex, so I've tried many
different ones. They all worked with online regex testers based on Java.
But with Shibboleth, the results were all empty.
So I've changed the output from $1 to |$1| to see what happens:

<AttributeResolver type="Transform" source="Shib-email">
    <Regex match="^([\w\. at -]+)" dest="mymail">$1</Regex>
    <Regex match="^([\w\. at -]+)" dest="mymail1">|$1|</Regex>
</AttributeResolver>

Result for "s1869831907 at example.org":
mymail:
mymail1: |s1869831907 at example.org|

Result for "Jordan.Belfort at harvard-example.edu;jordan at harvard-example.edu":
mymail:
mymail1: |Jordan.Belfort at harvard-example.edu|;|jordan at harvard-example.edu|

Ok, the output is now visible, even if I replace the | character with a
space.
But still not the first value if the mail attribute consist of more than
one value.

What am I doing wrong here?

Best regards,
Wesley
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://shibboleth.net/pipermail/users/attachments/20160322/2c4ffb6a/attachment.html>


More information about the users mailing list