ResponseMapping> element provides an instance of the HTTPResponseMappingStrategy interface that produces result attributes from a web service response, in real time, using a script. The supplied script is expected to consume the HttpResponse instance and produce any desired results. It may raise exceptions if necessary.
For simple use cases, the HttpClientSupport class includes a number of
toString methods that can translate the entire response into a string using appropriate character set handling and while enforcing size limits. This supports chunked responses for which the server doesn't know the actual size ahead of time, which is common with web services.
JSON object that automates the parsing of JSON data.
Schema Name and Location
<ResponseMapping> element is a configuration element of type
ScriptType. Both the element and its type are defined in the
namespace, the schema for which is located at http://shibboleth.net/schema/idp/shibboleth-attribute-resolver.xsd.
The following sections describe the attributes and elements of the
An element of type Name Type Default Description If the An element of type The script may be stored in a local file (with Always wrap inline scripts with a CDATA section Always wrap inline scripts with a CDATA section, even if the script contains no special XML characters. This will future-proof your script.
ScriptType has the following XML attributes:
Defines the JSR-223 language to use. The default is ECMAScript using either the Rhino (Java 7) or Nashorn (Java 8) engines.
string optional The ID of a Spring bean defined elsewhere in the configuration.
customObjectRef attribute is present, the result of the referenced Spring bean is made available to the script in a variable named
custom. This is in addition to the normal script context discussed below.
ScriptType has the following child elements:
Name Cardinality Description
An inline script
Path to a local file or classpath resource containing the script
<ScriptFile>) or written inline (with
<Script>). An inline script should be wrapped with a CDATA section to prevent interpretation of any special XML characters that may be included in the script.
An element of type
An element of type
The script may be stored in a local file (with
Always wrap inline scripts with a CDATA section
Always wrap inline scripts with a CDATA section, even if the script contains no special XML characters. This will future-proof your script.
As enumerated below, several variables are available in the template context.
Instance of HttpResponse to process
|A class logger for debugging|
|Custom object supplied via |
|Pre-defined Set<IdPAttribute> variable to populate with output results|
Unlike a lot of the scripted versions of objects across the system, there is no direct access to the ProfileRequestContext tree that exposes the state of the request. However, it's easy to get access to it by using a servlet request attribute named "opensamlProfileRequestContext". You can inject the servlet request object through the
customObjectRef hook (set it to "shibboleth.HttpServletRequest").