001package org.apache.maven.wagon.tck.http.fixture;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *   http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import java.io.IOException;
023import java.util.Collections;
024import java.util.Enumeration;
025
026import javax.servlet.Filter;
027import javax.servlet.FilterChain;
028import javax.servlet.FilterConfig;
029import javax.servlet.ServletException;
030import javax.servlet.ServletRequest;
031import javax.servlet.ServletResponse;
032import javax.servlet.http.HttpServletRequest;
033
034import org.apache.log4j.Logger;
035
036public class ProxyConnectionVerifierFilter
037    implements Filter
038{
039    private static Logger logger = Logger.getLogger( ProxyConnectionVerifierFilter.class );
040
041    public void destroy()
042    {
043    }
044
045    @SuppressWarnings( "unchecked" )
046    public void doFilter( final ServletRequest req, final ServletResponse resp, final FilterChain chain )
047        throws IOException, ServletException
048    {
049        HttpServletRequest request = (HttpServletRequest) req;
050        // HttpServletResponse response = (HttpServletResponse) resp;
051
052        Enumeration<String> kEn = request.getHeaderNames();
053        for ( String key : Collections.list( kEn ) )
054        {
055            if ( key == null )
056            {
057                continue;
058            }
059
060            Enumeration<String> vEn = request.getHeaders( key );
061            if ( vEn != null )
062            {
063                for ( String val : Collections.list( vEn ) )
064                {
065                    logger.info( key + ": " + val );
066                }
067            }
068        }
069
070        chain.doFilter( req, resp );
071    }
072
073    public void init( final FilterConfig filterConfig )
074        throws ServletException
075    {
076    }
077
078}