Shibboleth HTTP Dataconnector: Difference between revisions
Jump to navigation
Jump to search
(Created page with "==About== This is a sample of the [https://wiki.shibboleth.net/confluence/display/IDP30/HTTPConnector Shibboleth HTTP DataConnector]. ==IIR Sample== The URL seen on line 6 is...") |
|||
| Line 23: | Line 23: | ||
<![CDATA[ | <![CDATA[ | ||
var logger = Java.type("org.slf4j.LoggerFactory").getLogger("net.shibboleth.idp.attribute"); | var logger = Java.type("org.slf4j.LoggerFactory").getLogger("net.shibboleth.idp.attribute"); | ||
var HashSet = Java.type("java.util.HashSet"); | var HashSet = Java.type("java.util.HashSet"); | ||
| Line 33: | Line 32: | ||
var body = HttpClientSupport.toString(response.getEntity(), "UTF-8", 65536); | var body = HttpClientSupport.toString(response.getEntity(), "UTF-8", 65536); | ||
logger.info("Query Response = " + body); | |||
var result = JSON.parse(body); | var result = JSON.parse(body); | ||
Revision as of 15:34, 9 December 2019
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>