HTTPConnector
Mundry, Marvin
Marvin.Mundry at uni-hamburg.de
Mon Oct 22 02:20:51 EDT 2018
I am trying to use the HTTPConnector to obtain attributes from a web service. For this reason I copied the example from the shibboleth wiki. When the idp resolves the attributes it produces an "Attempted read from closed stream" error. How can I fix this?
<DataConnector id="myHTTP" xsi:type="HTTP"
httpClientRef="shibboleth.NonCachingHttpClient">
<URLTemplate>
<![CDATA[
http://localhost:8080/m1.php?act=${uid.get(0)}
]]>
</URLTemplate>
<ResponseMapping>
<Script>
<![CDATA[
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);
var result = JSON.parse(body);
var attr = new IdPAttribute("xyzGroups");
var values = new HashSet();
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>
<InputAttributeDefinition ref="uid" />
<!--ResultCache expireAfterWrite="PT5M"/-->
</DataConnector>
2018-10-22 08:10:57,881 - ERROR [net.shibboleth.idp.profile.impl.ResolveAttributes:314] - Profile Action ResolveAttributes: Error resolving attributes
net.shibboleth.idp.attribute.resolver.ResolutionException: Data Connector 'myHTTP': HTTP request failed
at net.shibboleth.idp.attribute.resolver.dc.http.impl.HTTPDataConnector.retrieveAttributes(HTTPDataConnector.java:109)
Caused by: java.io.IOException: myHTTP: Script did not run successfully
at net.shibboleth.idp.attribute.resolver.dc.http.impl.ScriptedResponseMappingStrategy.handleResponse(ScriptedResponseMappingStrategy.java:155)
Caused by: java.lang.RuntimeException: java.io.IOException: Attempted read from closed stream.
at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:397)
Caused by: java.io.IOException: Attempted read from closed stream.
at org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:165)
Thanks,
Marvin
More information about the users
mailing list