For applications that return the login page when the user tries to
access a page without a valid session. This template shows how to use the
ExtractFilter to find the login page on the response and
use the CookieFilter to ensure the cookies from the
application are replayed on each request. The sample application in this
template is OpenAM. If you change the TARGETIP:PORT to be
the IP address of OpenAM, the TARGETDN:PORT to be the
fully qualified name and port of OpenAM and modify USERNAME
and PASSWORD in the LoginRequest you
automatically log USERNAME into OpenAM.
![]() |
Note |
|---|---|
|
Without the |
{
"heap": {
"objects": [
{
"name": "HandlerServlet",
"comment": "Entry point that transforms Servlet request to handler request.",
"type": "HandlerServlet",
"config": {
"handler": "FindLoginPageChain",
"baseURI":"http://TARGETIP:PORT"
}
},
{
"name": "FindLoginPageChain",
"type": "Chain",
"config": {
"filters": ["IsLoginPage","FindLoginPage"],
"handler": "OutgoingChain"
}
},
{
"name": "FindLoginPage",
"type": "EntityExtractFilter",
"config": {
"messageType": "response",
"target": "${exchange.isLoginPage}",
"bindings": [
{
"key": "found",
"pattern": "OpenAM\s\(Login\)",
"template": "true"
}
]
}
},
{
"name": "IsLoginPage",
"type": "SwitchFilter",
"config": {
"onResponse": [
{
"condition": "${exchange.isLoginPage.found == 'true'}",
"handler": "LoginChain"
}
]
}
},
{
"name": "LoginChain",
"type": "Chain",
"config": {
"filters": ["LoginRequest"],
"handler": "OutgoingChain"
}
},
{
"name": "LoginRequest",
"type": "StaticRequestFilter",
"config": {
"method": "POST",
"uri": "http://TARGETIP:PORT/openam/UI/Login"
"form": {
"IDToken0":[""]
"IDToken1":["USERNAME"]
"IDToken2":["PASSWORD"]
"IDButton":["Log+In"]
"encoded":["false"]
},
"headers": {
"host":["TARGETFQDN:PORT"]
}
}
},
{
"name": "OutgoingChain",
"type": "Chain",
"config": {
"filters": ["CookieFilter","CaptureFilter"],
"handler": "ClientHandler"
}
},
{
"name": "CookieFilter",
"type": "CookieFilter",
"config": {
}
},
{
"name": "CaptureFilter",
"type": "CaptureFilter",
"config": {
"captureEntity": true,
"file": "/tmp/gateway.log",
}
},
{
"name": "LogSink",
"comment": "Default sink for logging information.",
"type": "ConsoleLogSink",
"config": {
"level": "DEBUG",
}
}
{
"name": "ClientHandler",
"comment": "Responsible for sending all requests to remote servers.",
"type": "ClientHandler",
"config": {
}
}
]
},
"servletObject": "HandlerServlet",
}

![[Note]](common/images/admon/note.png)
