Help with MappedAttributeDefinition
Mohamed Lrhazi
lrhazi at cua.edu
Fri Aug 19 17:18:49 UTC 2022
Thanks a lot Keith. The scripting you suggested seems to have worked well:
<AttributeDefinition id="isEligible" xsi:type="ScriptedAttribute">
<InputDataConnector ref="sqliteConnector" attributeNames="
eduPersonAffiliation"/>
<Script><![CDATA[
logger =
Java.type("org.slf4j.LoggerFactory").getLogger("net.shibboleth.idp.attribute.resolver.eppnbuilder");
result=0;
for(i = 0; i < eduPersonAffiliation.getValues().size(); i++) {
value = eduPersonAffiliation.getValues().get(i);
// logger.info("isEligible: eduPersonAffiliation: " + value);
if (value=='student') {
result=1
}
}
isEligible.getValues().add(result.toString());
]]>
</Script>
<AttributeEncoder xsi:type="SAML1String" name="isEligible" encodeType="false
" />
<AttributeEncoder xsi:type="SAML2String" name="isEligible" friendlyName="
isEligible" encodeType="false" />
</AttributeDefinition>
On Thu, Aug 18, 2022 at 9:58 PM Wessel, Keith <kwessel at illinois.edu> wrote:
> The problem is your map is evaluating every value of eduPersonAffiliation.
> Any chance you could do what you’re hoping with something single-valued
> like eduPersonPrimaryAffiliation?
>
>
>
> Shy of that, I think your best bet is a script. Set the attribute to 0 at
> the beginning. Then iterate over all values of eduPersonAffiliation in a
> for loop. If you find “student”, change that variable to 1. Should be a
> pretty simple script.
>
>
>
> Keith
>
>
>
>
>
> *From:* users <users-bounces at shibboleth.net> *On Behalf Of *Mohamed
> Lrhazi via users
> *Sent:* Thursday, August 18, 2022 6:26 PM
> *To:* Shib Users <users at shibboleth.net>
> *Cc:* Mohamed Lrhazi <lrhazi at cua.edu>
> *Subject:* Help with MappedAttributeDefinition
>
>
>
> Hello,
>
>
>
> I am trying to add an attribute that resolves to "1" if the user is a
> student, but "0" otherwise... I thought it would be as simple as below....
> but this actually returns "1" and "0" if the user is both a student and
> also a member or any other affiliation....
>
>
>
> How do I implement this logic?
>
>
>
> Thanks a lot!
>
> Mohamed.
>
>
>
>
>
>
>
> <AttributeDefinition *id*="isEligible" *xsi**:**type*="Mapped">
>
> <InputDataConnector *ref*="sqliteConnector" *attributeNames*="
> eduPersonAffiliation"/>
>
> <DefaultValue>0</DefaultValue>
>
> <ValueMap>
>
> <ReturnValue>1</ReturnValue>
>
> <SourceValue>student</SourceValue>
>
> </ValueMap>
>
> <AttributeEncoder *xsi**:**type*="SAML1String" *name*="isEligible"
> *encodeType*="false" />
>
> <AttributeEncoder *xsi**:**type*="SAML2String" *name*="isEligible"
> *friendlyName*="isEligible" *encodeType*="false" />
>
> </AttributeDefinition>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://shibboleth.net/pipermail/users/attachments/20220819/a37ee22b/attachment.htm>
More information about the users
mailing list