List of usage examples for org.apache.commons.httpclient URI toString
@Override
public String toString()
From source file:org.parosproxy.paros.core.scanner.Kb.java
public synchronized void add(URI uri, String key, Object value) { // ZAP: catch CloneNotSupportedException as introduced with version 3.1 of HttpClient try {/*from ww w . jav a2 s .com*/ uri = (URI) uri.clone(); } catch (CloneNotSupportedException e1) { return; } // ZAP: Removed variable (TreeMap map). try { uri.setQuery(null); } catch (URIException e) { // ZAP: Added logging. logger.error(e.getMessage(), e); return; } // ZAP: Moved to after the try catch block. String uriKey = uri.toString(); // ZAP: Added the type arguments. TreeMap<String, Object> map = mapURI.get(uriKey); if (map == null) { // ZAP: Added the type argument. map = new TreeMap<>(); mapURI.put(uriKey, map); } // ZAP: Removed else branch. add(map, key, value); }
From source file:org.parosproxy.paros.core.scanner.Kb.java
public synchronized Vector<Object> getList(URI uri, String key) { // ZAP: catch CloneNotSupportedException as introduced with version 3.1 of HttpClient try {//from www.j a v a 2 s. co m uri = (URI) uri.clone(); } catch (CloneNotSupportedException e1) { return null; } // ZAP: Removed variable (TreeMap map). try { uri.setQuery(null); } catch (URIException e) { // ZAP: Added logging. logger.error(e.getMessage(), e); return null; } // ZAP: Moved to after the try catch block. String uriKey = uri.toString(); // ZAP: Added the type argument and removed the instanceof. TreeMap<String, Object> map = mapURI.get(uriKey); if (map == null) { return null; } // ZAP: Removed else branch. return getList(map, key); }
From source file:org.parosproxy.paros.core.scanner.plugin.TestDirectoryBrowsing.java
private void checkIfDirectory(HttpMessage msg) throws URIException { URI uri = msg.getRequestHeader().getURI(); uri.setQuery(null);/* ww w . java2 s . c om*/ String sUri = uri.toString(); if (!sUri.endsWith("/")) { sUri = sUri + "/"; } msg.getRequestHeader().setURI(new URI(sUri, true)); }
From source file:org.parosproxy.paros.core.scanner.plugin.TestInfoGatheringObsoleteFile.java
/** * Test existence of obsolete file with the suffix. * /*from w w w . j a v a2s .c o m*/ * @param suffix * suffix to run scan with. * @param replaceSuffix * true = replace the suffix for checking. false = append the * suffix. */ private void testSuffix(String suffix, boolean replaceSuffix) throws IOException { HttpMessage msg = getNewMsg(); URI uri = msg.getRequestHeader().getURI(); String path = uri.getPath(); if (path == null || path.equals("")) { return; } if (replaceSuffix) { int pos = path.lastIndexOf("."); if (pos > -1) { path = path.substring(0, pos); } } path = path + suffix; uri.setPath(path); msg.getRequestHeader().setURI(uri); sendAndReceive(msg); if (!isFileExist(msg)) { return; } bingo(Alert.RISK_LOW, Alert.WARNING, uri.toString(), "", "", msg); }
From source file:org.parosproxy.paros.core.spider.SpiderParam.java
public boolean isSkipURL(URI uri) { if (patternSkipURL == null || uri == null) { return false; }/*from w ww . j a v a 2s . co m*/ String sURI = uri.toString(); return patternSkipURL.matcher(sURI).find(); }
From source file:org.parosproxy.paros.extension.filter.FilterLogCookie.java
@Override public void onHttpRequestSend(HttpMessage msg) { HttpRequestHeader header = msg.getRequestHeader(); if (header != null) { String cookie = header.getHeader("Cookie"); synchronized (cookieList) { if (cookie != null && cookieList.indexOf(cookie) == -1) { try { // ZAP: catch CloneNotSupportedException as introduced with version 3.1 of HttpClient URI uri; try { uri = (URI) header.getURI().clone(); } catch (CloneNotSupportedException e) { throw new URIException(e.getMessage()); }/*from www. j a va 2 s . c om*/ uri.setQuery(null); String sUri = uri.toString(); cookieList.add(cookie); getView().getOutputPanel().append(sUri + DELIM + cookie + "\n"); } catch (URIException e) { // ZAP: Print stack trace to Output tab getView().getOutputPanel().append(e); } } } } }
From source file:org.parosproxy.paros.extension.filter.FilterLogGetQuery.java
@Override public void onHttpRequestSend(HttpMessage httpMessage) { HttpRequestHeader reqHeader = httpMessage.getRequestHeader(); if (reqHeader != null && reqHeader.isText() && !reqHeader.isImage()) { if (reqHeader.getMethod().equalsIgnoreCase(HttpRequestHeader.GET)) { try { URI uri = reqHeader.getURI(); // ZAP: Removed unused variable (int pos). String firstline; URI newURI = (URI) uri.clone(); String query = newURI.getQuery(); if (query != null) { newURI.setQuery(null); firstline = newURI.toString(); // ZAP: Added type arguments. Hashtable<String, String> param = parseParameter(query); writeLogFile(firstline, param); } else { firstline = uri.toString(); writeLogFile(firstline, null); }//w w w .j ava2 s . co m } catch (Exception aa) { logger.error(aa.getMessage(), aa); } } } }
From source file:org.parosproxy.paros.extension.filter.FilterLogPostQuery.java
@Override public void onHttpRequestSend(HttpMessage httpMessage) { HttpRequestHeader reqHeader = httpMessage.getRequestHeader(); if (reqHeader != null && reqHeader.isText() && !reqHeader.isImage()) { if (reqHeader.getMethod().equalsIgnoreCase(HttpRequestHeader.POST)) { try { URI uri = reqHeader.getURI(); // ZAP: Removed unused variable (int pos). String firstline; URI newURI = (URI) uri.clone(); String query = httpMessage.getRequestBody().toString(); if (query != null) { newURI.setQuery(null); firstline = newURI.toString(); // ZAP: Added type arguments. Hashtable<String, String> param = parseParameter(query); writeLogFile(firstline, param); } else { firstline = uri.toString(); writeLogFile(firstline, null); }/* w w w. j av a2s . c o m*/ } catch (Exception e) { logger.error(e.getMessage(), e); } } } }
From source file:org.parosproxy.paros.extension.spider.ExtensionSpider.java
public void spiderProgress(final URI uri, final int percentageComplete, final int numberCrawled, final int numberToCrawl) { String uriString = ""; if (dialog != null) { if (EventQueue.isDispatchThread()) { dialog.getTxtNumCrawled().setText(Integer.toString(numberCrawled)); dialog.getTxtOutstandingCrawl().setText(Integer.toString(numberToCrawl)); dialog.getProgressBar().setValue(percentageComplete); uriString = ""; if (uri != null) { uriString = uri.toString(); }/*from w w w .j a v a2 s .c o m*/ dialog.getTxtDisplay().setText(uriString); //dialog.getTxtDisplay().setCaretPosition(0); return; } try { EventQueue.invokeAndWait(new Runnable() { public void run() { String uriString = ""; dialog.getTxtNumCrawled().setText(Integer.toString(numberCrawled)); dialog.getTxtOutstandingCrawl().setText(Integer.toString(numberToCrawl)); dialog.getProgressBar().setValue(percentageComplete); if (uri != null) { uriString = uri.toString(); } dialog.getTxtDisplay().setText(uriString); //dialog.getTxtDisplay().setCaretPosition(0); } }); } catch (Exception e) { } } }
From source file:org.parosproxy.paros.extension.trap.ProxyListenerTrap.java
private boolean isSkipFilter(HttpMessage msg) { try {/* w w w. ja va 2 s. c o m*/ URI uri = (URI) msg.getRequestHeader().getURI().clone(); uri.setQuery(null); String sUri = uri.toString(); if (trapParam.isExclude(sUri)) { return true; } if (!trapParam.isInclude(sUri)) { return true; } } catch (URIException e) { } return false; }