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.slf4j.Logger;
035import org.slf4j.LoggerFactory;
036
037/**
038 * 
039 */
040public class ProxyConnectionVerifierFilter
041    implements Filter
042{
043    private static Logger logger = LoggerFactory.getLogger( ProxyConnectionVerifierFilter.class );
044
045    public void destroy()
046    {
047    }
048
049    @SuppressWarnings( "unchecked" )
050    public void doFilter( final ServletRequest req, final ServletResponse resp, final FilterChain chain )
051        throws IOException, ServletException
052    {
053        HttpServletRequest request = (HttpServletRequest) req;
054        // HttpServletResponse response = (HttpServletResponse) resp;
055
056        Enumeration<String> kEn = request.getHeaderNames();
057        for ( String key : Collections.list( kEn ) )
058        {
059            if ( key == null )
060            {
061                continue;
062            }
063
064            Enumeration<String> vEn = request.getHeaders( key );
065            if ( vEn != null )
066            {
067                for ( String val : Collections.list( vEn ) )
068                {
069                    logger.info( key + ": " + val );
070                }
071            }
072        }
073
074        chain.doFilter( req, resp );
075    }
076
077    public void init( final FilterConfig filterConfig )
078        throws ServletException
079    {
080    }
081
082}