public boolean handle(String pathInContext, String pathParams, RequestHandlerRequest request, RequestHandlerResponse response)
throws RequestHandlerException, IOException {
if (log.isDebugEnabled())
log.debug("Checking for Replacement proxy request: " + pathInContext);
LaunchSession launchSession = null;
String launchId;
try {
String requestPath = request.getPath();
if (requestPath.startsWith("/replacementProxyEngine")) {
/* The launch session and URL may be provided in one of two ways.
*
* 1. As a request to /replacementProxyEngine with the launch session
* and target URL provided as sslx_launchId and sslx_url respectively
*
* 2. In the new format /replacementProxyEngine/[launchId]/[encodedURL]
*/
if(requestPath.startsWith("/replacementProxyEngine/")) {
int idx = requestPath.indexOf('/', 1);
int idx2 = requestPath.indexOf('/', idx + 1);
launchId = requestPath.substring(idx + 1, idx2);
}
else {
launchId = (String) request.getParameters().get(LaunchSession.LONG_LAUNCH_ID);
}
if (launchId != null) {
LaunchSession foundLaunchSession = LaunchSessionFactory.getInstance().getLaunchSession(launchId);
if (foundLaunchSession == null) {
response.sendError(404, "Invalid launch session. Your login session has probobably timed out.");
return true;
}
if (foundLaunchSession.isTracked() && foundLaunchSession.getResource()
.getResourceType()
.equals(WebForwardPlugin.WEBFORWARD_RESOURCE_TYPE)) {
launchSession = foundLaunchSession;
if (log.isDebugEnabled()) {
log.debug("Found a web forward launch session provided by " + LaunchSession.LONG_LAUNCH_ID