Shibboleth HTTP Dataconnector
About
This is a sample of the Shibboleth HTTP DataConnector.
IIR Sample
The URL seen on line 6 is a test URL that always returns false. You will also need to contact IIR to get an authorization code to use the service.
<DataConnector id="myHTTP" xsi:type="HTTP" httpClientRef="shibboleth.NonCachingHttpClient"> <InputAttributeDefinition ref="EmailAddress" /> <URLTemplate> <![CDATA[ https://tca.iir.com/api/LookupTestNotCompleted?code=[get code from IIR] ]]> </URLTemplate> <BodyTemplate MIMEType="application/json"> <![CDATA[ { 'email': '$EmailAddress.get(0)' } ]]> </BodyTemplate> <ResponseMapping> <Script> <![CDATA[ var logger = Java.type("org.slf4j.LoggerFactory").getLogger("net.shibboleth.idp.attribute"); var HashSet = Java.type("java.util.HashSet"); var HttpClientSupport = Java.type("net.shibboleth.utilities.java.support.httpclient.HttpClientSupport"); var IdPAttribute = Java.type("net.shibboleth.idp.attribute.IdPAttribute"); var StringAttributeValue = Java.type("net.shibboleth.idp.attribute.StringAttributeValue"); // Limits length to 64k var body = HttpClientSupport.toString(response.getEntity(), "UTF-8", 65536); logger.info("Query Response = " + body); var result = JSON.parse(body); //logger.info("Parsed JSON Completed = " + result.completed); var attr = new IdPAttribute("CFRCertified"); var values = new HashSet(); if (result.completed) { values.add(new StringAttributeValue("true")); } else { values.add(new StringAttributeValue("false")); } attr.setValues(values); connectorResults.add(attr); ]]> </Script> </ResponseMapping> <ResultCache expireAfterWrite="PT5M"/> </DataConnector>