EntityExtractFilter
Extracts regular expression patterns from a message entity, and stores their
values in a target
object. Use this object in password replay, to find a login
path or extract a nonce.
If the message type
is REQUEST
, the pattern is extracted before the request
is handled. If the message type
is RESPONSE
, the pattern is extracted out of
the response body.
Each pattern can have an associated template, which is applied to its match result.
For information, see Patterns.
Usage
{
"name": string,
"type": "EntityExtractFilter",
"config": {
"messageType": configuration expression<enumeration>,
"charset": configuration expression<string>,
"target": lvalue-expression,
"bindings": [
{
"key": configuration expression<string>,
"pattern": pattern,
"template": pattern
}, ...
]
}
}
Properties
"messageType"
: configuration expression<enumeration>, required-
The message type to extract patterns from.
Must be
REQUEST
orRESPONSE
. "charset"
: configuration expression<string>, optional-
Overrides the character set encoding specified in message.
Default: The message encoding is used.
"target"
: <lvalue-expression>, required-
Expression 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"
: configuration expression<string>, required-
Name of the element in the target object to contain an extraction result.
"pattern"
: pattern, required-
The regular expression pattern to find in the entity.
See also Patterns.
"template"
: pattern-template, optional-
The 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
wpLogintokenvalue="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"
}
]
}
}