use of com.tremolosecurity.proxy.postProcess.UriRequestProcess in project OpenUnison by TremoloSecurity.
the class ProxySys method doURI.
public void doURI(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
boolean isText = false;
UrlHolder holder = (UrlHolder) req.getAttribute(ProxyConstants.AUTOIDM_CFG);
HashMap<String, String> uriParams = (HashMap<String, String>) req.getAttribute("TREMOLO_URI_PARAMS");
if (uriParams == null) {
uriParams = new HashMap<String, String>();
req.setAttribute("TREMOLO_URI_PARAMS", uriParams);
}
uriParams.put("fullURI", req.getRequestURI());
HttpFilterRequest filterReq = new HttpFilterRequestImpl(req, null);
HttpFilterResponse filterResp = new HttpFilterResponseImpl(resp);
PostProcess postProc = null;
if (holder.getUrl().getProxyTo() == null || holder.getUrl().getProxyTo().isEmpty()) {
FilterChain filterChain = (FilterChain) req.getAttribute(ProxyConstants.TREMOLO_FILTER_CHAIN);
if (filterChain == null) {
logger.warn("Could not find filter chain");
}
postProc = new EmbPostProc(filterChain);
} else {
postProc = new UriRequestProcess();
}
HttpFilterChain chain = new HttpFilterChainImpl(holder, postProc);
try {
chain.nextFilter(filterReq, filterResp, chain);
} catch (Exception e) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintWriter err = new PrintWriter(new OutputStreamWriter(baos));
e.printStackTrace(err);
Throwable t = e.getCause();
while (t != null) {
t.printStackTrace(err);
t = t.getCause();
}
logger.error("Error Executing Request : " + new String(baos.toByteArray()));
throw new ServletException("Could not execute request", e);
}
ProxyData pd = new ProxyData();
pd.setHolder(holder);
pd.setIns(chain.getIns());
pd.setPostProc(postProc);
pd.setRequest(filterReq);
pd.setResponse(filterResp);
pd.setText(chain.isText());
pd.setLogout(chain.isLogout());
pd.setHttpRequestBase(chain.getHttpRequestBase());
req.setAttribute(ProxyConstants.TREMOLO_PRXY_DATA, pd);
}
Aggregations