Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Expand
titleHTTP connector for a JSON-based web service
Code Block
languagexml
 <DataConnector id="myHTTP" xsi:type="HTTP"
		httpClientRef="WebServiceHttpClient"
		httpClientSecurityParametersRef="ExampleOrgWSSecurity">
	<URLTemplate>
		<![CDATA[
		https://webservice.example.org/api/subject/$pathEscaper.escape($resolutionContext.principal)/groups
		]]>
	</URLTemplate>

	<ResponseMapping>
		<Script>
		<![CDATA[
		var HashSetArrayList = Java.type("java.util.HashSetArrayList");
		var HttpClientSupport = Java.type("net.shibboleth.shared.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);
		var result = JSON.parse(body);
 
		var attr = new IdPAttribute("group");
		var values = new HashSetArrayLit();
		if (result.groups != null) {
			for (var i=0; i<result.groups.length; i++) {
				values.add(new StringAttributeValue(result.groups[i].name));
			}
		}
		attr.setValues(values);
		connectorResults.add(attr);
		]]>
		</Script>
	</ResponseMapping>

	<ResultCache expireAfterWrite="PT5M"/>
</DataConnector>

...

Expand
titleSpecific XML Elements

Name

Cardinality

Description

<URLTemplate>

0 or 1

Template of a URL to execute via HTTP GET or POST

<BodyTemplate>

0 or 1

Template for a request body to submit via HTTP POST, requires use of <URLTemplate>

<CacheKeyTemplate>

0 or 1

Template to produce a cache key to associate with the result of an HTTP POST, requires use of <BodyTemplate>

<ResponseMapping>

0 or 1

Inline or external script to execute to process the response body

<ResultCache>

0 or 1

Defines how results should be cached.

<ResultCacheBean>

Bean ID (in the element content) defining how results should be cached as an externally defined com.google.common.cache.Cache<String,Map<String,IdPAttribute>> 

Expand
titleCommon XML Attributes
Include Page
DataConnectorCommonAttributes
DataConnectorCommonAttributes

...