Name
EntityExtractFilter — extract pattern from message entity
Description
Extracts regular expression patterns from a message entity. The
extraction results are stored in a target object. For a
given matched pattern, 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": regex-pattern,
"template": pattern-template
}, ...
]
}
}Properties
"messageType": string, required-
The message type in the exchange to extract patterns from. Must be one of:
"REQUEST","RESPONSE". "charset": 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.
"key": string, required-
Name of element in target object to contain an extraction result.
"pattern": pattern, required-
The regular expression pattern to find in the entity.
"template": pattern-template, optional-
The template to apply to the pattern and store in the named target element. Default: store the match result itself.
Examples
Extracts a nonce from the response, which is typically a login page,
and sets its value in the exchange to be used by the downstream filter
posting the login form. The nonce value would be accessed using the following
expression ${exchange.wikiNonce.wpLoginToken}. The pattern
is finding all matches in the HTTP body of the form
wpLogintoken value="abc". Setting the template to
$1 assigns the value abc to
exchange.wikiNonce.wpLoginToken:
{
"name": "WikiNoncePageExtract",
"type": "EntityExtractFilter",
"config": {
"messageType": "response",
"target": "${exchange.wikiNonce}",
"bindings": [
{
"key": "wpLoginToken",
"pattern": "wpLoginToken\"\s.*value=\"(.*)\"",
"template": "$1"
}
]
}
}Reads the response looking for the OpenAM login page. When found it
sets loginPage.found = true to be used in a SwitchFilter
to post the login credentials:
{
"name": "FindLoginPage",
"type": "EntityExtractFilter",
"config": {
"messageType": "response",
"target": "${exchange.isLoginPage}",
"bindings": [
{
"key": "found",
"pattern": "OpenAM\s\(Login\)",
"template": "true"
}
]
}
}
