Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <AttributeDefinition xsi:type="ScriptedAttribute" id="schacPersonalUniqueCode">
- <InputDataConnector ref="myLDAP" attributeNames="eduPersonAffiliation matricolaStudente schacPersonalUniqueCode"/>
- <Script>
- <![CDATA[
- logger = Java.type("org.slf4j.LoggerFactory").getLogger("net.shibboleth.idp.attribute.resolver.schacPersonalUniqueCodeBuilder");
- var isMyAcademicID = false;
- var student = false;
- var member = false;
- var id = "https://proxy.prod.erasmus.eduteams.org/metadata/backend.xml";
- // specify the child context of the root ProfileRequestContext
- var subcontextClass = "net.shibboleth.idp.profile.context.RelyingPartyContext";
- var subcontext;
- // check if the MyAcademicID IAM Service
- if (profileContext!== null) {
- // check the entityID of the relying party
- subcontext = profileContext.getSubcontext(subcontextClass);
- if (subcontext !== null) {
- isMyAcademicID = subcontext.getRelyingPartyId().equals(id);
- }
- }
- // check existance of matricolaStudente attribute and use it to enrich schacPersonalUniqueCode attribute
- if (matricolaStudente != null && matricolaStudente.getValues().size() > 0) {
- matricola = matricolaStudente.getValues().get(0);
- } else {
- matricola = null;
- }
- for ( i = 0; eduPersonAffiliation != null && i < eduPersonAffiliation.getValues().size(); i++ ){
- value = eduPersonAffiliation.getValues().get(i);
- if (value == 'student') student = true;
- if (value == 'member') member = true;
- }
- // if MyAcademicID
- if (isMyAcademicID == true){
- if ( member == true && student == true ){
- logger.info('The user is able to receive ESI');
- schacPersonalUniqueCode.addValue('urn:schac:personalUniqueCode:int:esi:it:foo.bar:' + matricola);
- }
- }
- ]]>
- </Script>
- </AttributeDefinition>
Add Comment
Please, Sign In to add comment