EntityExtractFilter
Extracts regular expression patterns from a message entity. The extraction results are stored in a "target" object. For a given matched pattern, as described in "Patterns", the value stored in the object is either the result of applying its associated pattern template (if specified) or the match result itself otherwise.
Usage
{ "name": string, "type": "EntityExtractFilter", "config": { "messageType": string, "charset": string, "target": lvalue-expression, "bindings": [ { "key": string, "pattern": pattern, "template": pattern-template }, ... ] } }
Properties
"messageType"
: string, requiredThe message type to extract patterns from.
Must be one of:
REQUEST
,RESPONSE
."charset"
: string, optionalOverrides the character set encoding specified in message.
Default: the message encoding is used.
"target"
: lvalue-expression, requiredExpression that yields the target object that contains the extraction results.
The bindings determine what type of object is stored in the target location.
The object stored in the target location is a Map<String, String>. You can then access its content with
${target.key}
or${target['key']}
.See also "Expressions".
"key"
: string, requiredName of element in target object to contain an extraction result.
"pattern"
: pattern, requiredThe regular expression pattern to find in the entity.
See also "Patterns".
"template"
: pattern-template, optionalThe template to apply to the pattern and store in the named target element.
Default: store the match result itself.
See also "Patterns".
Examples
Extracts a nonce from the response, which is typically a login page, and sets its value in the attributes context to be used by the downstream filter posting the login form. The nonce value would be accessed using the following expression: ${attributes.extract.wpLoginToken}
.
The pattern finds all matches in the HTTP body of the form wpLogintoken value="abc"
. Setting the template to $1
assigns the value abc
to attributes.extract.wpLoginToken
:
{ "name": "WikiNoncePageExtract", "type": "EntityExtractFilter", "config": { "messageType": "response", "target": "${attributes.extract}", "bindings": [ { "key": "wpLoginToken", "pattern": "wpLoginToken\"\\s.*value=\"(.*)\"", "template": "$1" } ] } }
The following example reads the response looking for the AM login page. When found, it sets isLoginPage = true
to be used in a SwitchFilter to post the login credentials:
{ "name": "FindLoginPage", "type": "EntityExtractFilter", "config": { "messageType": "response", "target": "${attributes.extract}", "bindings": [ { "key": "isLoginPage", "pattern": "OpenAM\s\(Login\)", "template": "true" } ] } }