Search in sources :

Example 1 with ChainedProxyManager

use of org.littleshoot.proxy.ChainedProxyManager in project jbossws-cxf by jbossws.

the class HTTPProxyTestCaseForked method initProxyServer.

private void initProxyServer() throws Exception {
    org.littleshoot.proxy.ProxyAuthenticator proxyAuthenticator = new org.littleshoot.proxy.ProxyAuthenticator() {

        @Override
        public boolean authenticate(String user, String pwd) {
            return (PROXY_USER.equals(user) && PROXY_PWD.equals(pwd));
        }
    };
    InetSocketAddress address = new InetSocketAddress(getServerHost(), ++proxyPort);
    ChainedProxyManager chainProxyManager = new ChainedProxyManager() {

        @Override
        public void lookupChainedProxies(HttpRequest httpRequest, Queue<ChainedProxy> chainedProxies) {
            chainedProxies.add(new ChainedProxyAdapter() {

                @Override
                public InetSocketAddress getChainedProxyAddress() {
                    return new InetSocketAddress(getServerHost(), getServerPort());
                }
            });
        }
    };
    proxyServer = org.littleshoot.proxy.impl.DefaultHttpProxyServer.bootstrap().withChainProxyManager(chainProxyManager).withAddress(address).withProxyAuthenticator(proxyAuthenticator).start();
}
Also used : HttpRequest(io.netty.handler.codec.http.HttpRequest) ChainedProxyManager(org.littleshoot.proxy.ChainedProxyManager) InetSocketAddress(java.net.InetSocketAddress) Queue(java.util.Queue) ChainedProxyAdapter(org.littleshoot.proxy.ChainedProxyAdapter)

Aggregations

HttpRequest (io.netty.handler.codec.http.HttpRequest)1 InetSocketAddress (java.net.InetSocketAddress)1 Queue (java.util.Queue)1 ChainedProxyAdapter (org.littleshoot.proxy.ChainedProxyAdapter)1 ChainedProxyManager (org.littleshoot.proxy.ChainedProxyManager)1