@@ -0,0 +1,2655 @@
+/*%0A * Copyright 2008-2009 Xebia and the original author or authors.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage org.apache.catalina.connector;%0A%0Aimport static junit.framework.Assert.assertEquals;%0A%0Aimport java.io.IOException;%0Aimport java.util.concurrent.atomic.AtomicBoolean;%0A%0Aimport javax.servlet.ServletException;%0A%0Aimport org.apache.catalina.Valve;%0Aimport org.apache.catalina.valves.ValveBase;%0Aimport org.junit.Test;%0A%0Apublic class SecuredRemoteAddressValveTest %7B%0A%0A    private void testRemoteAddr(String remoteAddr, boolean expected) throws ServletException, IOException %7B%0A%0A        // PREPARE%0A        SecuredRemoteAddressValve securedRemoteAddressValve = new SecuredRemoteAddressValve();%0A        final AtomicBoolean secured = new AtomicBoolean();%0A%0A        Valve securedRequestTrackerValve = new ValveBase() %7B%0A%0A            @Override%0A            public void invoke(Request request, Response response) throws IOException, ServletException %7B%0A                secured.set(request.getRequest().isSecure());%0A            %7D%0A        %7D;%0A        securedRemoteAddressValve.setNext(securedRequestTrackerValve);%0A%0A        Request request = new Request();%0A        request.remoteAddr = remoteAddr;%0A%0A        // TEST%0A        securedRemoteAddressValve.invoke(request, new Response());%0A%0A        // VERIFY%0A        assertEquals(expected, secured.get());%0A    %7D%0A    %0A%0A    @Test%0A    public void testSecuredPrivateClassAAddress() throws Exception %7B%0A        testRemoteAddr(%2210.0.0.0%22, true);%0A        testRemoteAddr(%2210.0.0.1%22, true);%0A        testRemoteAddr(%2210.255.255.255%22, true);%0A    %7D%0A%0A    @Test%0A    public void testSecuredPrivateClassBAddress() throws Exception %7B%0A        testRemoteAddr(%22172.16.0.0%22, true);%0A        testRemoteAddr(%22172.16.0.5%22, true);%0A        testRemoteAddr(%22172.31.255.255%22, true);%0A    %7D%0A%0A    @Test%0A    public void testSecuredPrivateClassCAddress() throws Exception %7B%0A        testRemoteAddr(%22192.168.0.0%22, true);%0A        testRemoteAddr(%22192.168.0.5%22, true);%0A        testRemoteAddr(%22192.168.255.255%22, true);%0A    %7D%0A%0A    @Test%0A    public void testUnsecuredAddress() throws Exception %7B%0A        testRemoteAddr(%2282.66.240.18%22, false);%0A    %7D%0A%7D%0A

Add unit tests