//
// Check that the request is coming from a valid widget
//
IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager();
IWidgetInstance instance = persistenceManager.findWidgetInstanceByIdKey(request.getParameter("instanceid_key"));
if(instance == null && !isDefaultGadget(request)){
response.sendError(HttpServletResponse.SC_FORBIDDEN,"<error>"+UNAUTHORISED_MESSAGE+"</error>");
return;
}
//
// Create the proxy bean for the request
//
ProxyURLBean bean;
try {
bean = new ProxyURLBean(request);
} catch (MalformedURLException e) {
response.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage());
return;
}
//
// should we filter urls?
//
if (properties.getBoolean("widget.proxy.usewhitelist") && !isAllowed(bean.getNewUrl().toURI(), instance)){
response.sendError(HttpServletResponse.SC_FORBIDDEN,"<error>URL Blocked</error>");
fLogger.warn("URL " + bean.getNewUrl().toExternalForm() + " Blocked for scope "+instance.getWidget().getGuid());
return;
}
//
// Create a ProxyClient instance for the request