Search in sources :

Example 1 with PersistentConnectionListener

use of org.zaproxy.zap.PersistentConnectionListener in project zaproxy by zaproxy.

the class ProxyThread method notifyPersistentConnectionListener.

/**
	 * Go thru each listener and offer him to take over the connection. The
	 * first observer that returns true gets exclusive rights.
	 * 
	 * @param httpMessage Contains HTTP request & response.
	 * @param inSocket Encapsulates the TCP connection to the browser.
	 * @param method Provides more power to process response.
	 * 
	 * @return Boolean to indicate if socket should be kept open.
	 */
private boolean notifyPersistentConnectionListener(HttpMessage httpMessage, Socket inSocket, ZapGetMethod method) {
    boolean keepSocketOpen = false;
    PersistentConnectionListener listener = null;
    List<PersistentConnectionListener> listenerList = parentServer.getPersistentConnectionListenerList();
    for (int i = 0; i < listenerList.size(); i++) {
        listener = listenerList.get(i);
        try {
            if (listener.onHandshakeResponse(httpMessage, inSocket, method)) {
                // inform as long as one listener wishes to overtake the connection
                keepSocketOpen = true;
                break;
            }
        } catch (Exception e) {
            log.error("An error occurred while notifying listener:", e);
        }
    }
    return keepSocketOpen;
}
Also used : PersistentConnectionListener(org.zaproxy.zap.PersistentConnectionListener) HttpMalformedHeaderException(org.parosproxy.paros.network.HttpMalformedHeaderException) SocketException(java.net.SocketException) SocketTimeoutException(java.net.SocketTimeoutException) HttpException(org.apache.commons.httpclient.HttpException) MissingRootCertificateException(org.parosproxy.paros.security.MissingRootCertificateException) IOException(java.io.IOException) SSLException(javax.net.ssl.SSLException)

Example 2 with PersistentConnectionListener

use of org.zaproxy.zap.PersistentConnectionListener in project zaproxy by zaproxy.

the class ExtensionLoader method removePersistentConnectionListener.

private void removePersistentConnectionListener(ExtensionHook hook) {
    Proxy proxy = Control.getSingleton().getProxy();
    List<PersistentConnectionListener> listenerList = hook.getPersistentConnectionListener();
    for (PersistentConnectionListener listener : listenerList) {
        try {
            if (listener != null) {
                proxy.removePersistentConnectionListener(listener);
            }
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
        }
    }
}
Also used : Proxy(org.parosproxy.paros.control.Proxy) PersistentConnectionListener(org.zaproxy.zap.PersistentConnectionListener) DatabaseException(org.parosproxy.paros.db.DatabaseException) DatabaseUnsupportedException(org.parosproxy.paros.db.DatabaseUnsupportedException)

Example 3 with PersistentConnectionListener

use of org.zaproxy.zap.PersistentConnectionListener in project zaproxy by zaproxy.

the class HttpPanelSender method notifyPersistentConnectionListener.

/**
     * Go thru each listener and offer him to take over the connection. The
     * first observer that returns true gets exclusive rights.
     *
     * @param httpMessage Contains HTTP request & response.
     * @param inSocket Encapsulates the TCP connection to the browser.
     * @param method Provides more power to process response.
     *
     * @return Boolean to indicate if socket should be kept open.
     */
private boolean notifyPersistentConnectionListener(HttpMessage httpMessage, Socket inSocket, ZapGetMethod method) {
    boolean keepSocketOpen = false;
    PersistentConnectionListener listener = null;
    synchronized (persistentConnectionListener) {
        for (int i = 0; i < persistentConnectionListener.size(); i++) {
            listener = persistentConnectionListener.get(i);
            try {
                if (listener.onHandshakeResponse(httpMessage, inSocket, method)) {
                    // inform as long as one listener wishes to overtake the connection
                    keepSocketOpen = true;
                    break;
                }
            } catch (Exception e) {
                logger.warn(e.getMessage(), e);
            }
        }
    }
    return keepSocketOpen;
}
Also used : PersistentConnectionListener(org.zaproxy.zap.PersistentConnectionListener) HttpMalformedHeaderException(org.parosproxy.paros.network.HttpMalformedHeaderException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) SSLException(javax.net.ssl.SSLException)

Aggregations

PersistentConnectionListener (org.zaproxy.zap.PersistentConnectionListener)3 IOException (java.io.IOException)2 SSLException (javax.net.ssl.SSLException)2 HttpMalformedHeaderException (org.parosproxy.paros.network.HttpMalformedHeaderException)2 SocketException (java.net.SocketException)1 SocketTimeoutException (java.net.SocketTimeoutException)1 UnknownHostException (java.net.UnknownHostException)1 HttpException (org.apache.commons.httpclient.HttpException)1 Proxy (org.parosproxy.paros.control.Proxy)1 DatabaseException (org.parosproxy.paros.db.DatabaseException)1 DatabaseUnsupportedException (org.parosproxy.paros.db.DatabaseUnsupportedException)1 MissingRootCertificateException (org.parosproxy.paros.security.MissingRootCertificateException)1