Package org.apache.ftpserver.ipfilter

Examples of org.apache.ftpserver.ipfilter.RemoteIpFilter


                FtpServerNamespaceHandler.FTPSERVER_NS, "blacklist");
        if (blacklistElm != null) {
            LOG
                    .warn("Element 'blacklist' is deprecated, and may be removed in a future release. Please use 'remote-ip-filter' instead. ");
            try {
                RemoteIpFilter remoteIpFilter = new RemoteIpFilter(IpFilterType.DENY,
                        blacklistElm.getTextContent());
                factoryBuilder.addPropertyValue("sessionFilter", remoteIpFilter);
            } catch (UnknownHostException e) {
                throw new IllegalArgumentException(
                        "Invalid IP address or subnet in the 'blacklist' element",
                        e);
            }
        }

        Element remoteIpFilterElement = SpringUtil.getChildElement(element,
                FtpServerNamespaceHandler.FTPSERVER_NS, "remote-ip-filter");
        if (remoteIpFilterElement != null) {
            if (blacklistElm != null) {
                throw new FtpServerConfigurationException(
                        "Element 'remote-ip-filter' may not be used when 'blacklist' element is specified. ");
            }
            String filterType = remoteIpFilterElement.getAttribute("type");
            try {
                RemoteIpFilter remoteIpFilter = new RemoteIpFilter(IpFilterType
                        .parse(filterType), remoteIpFilterElement
                        .getTextContent());
                factoryBuilder
                        .addPropertyValue("sessionFilter", remoteIpFilter);
            } catch (UnknownHostException e) {
View Full Code Here


            List<InetAddress> blockedAddresses, List<Subnet> blockedSubnets) {
        if (blockedAddresses == null && blockedSubnets == null) {
            return null;
        }
        // Initialize the IP filter with Deny type
        RemoteIpFilter ipFilter = new RemoteIpFilter(IpFilterType.DENY);
        if (blockedSubnets != null) {
            ipFilter.addAll(blockedSubnets);
        }
        if (blockedAddresses != null) {
            for (InetAddress address : blockedAddresses) {
                ipFilter.add(new Subnet(address, 32));
            }
        }
        return ipFilter;
    }
View Full Code Here

        assertEquals("123-125", ((NioListener) listener)
                .getDataConnectionConfiguration().getPassivePorts());
        assertEquals(false, ((NioListener) listener)
                .getDataConnectionConfiguration().isPassiveIpCheck());
       
        RemoteIpFilter filter = (RemoteIpFilter) listener.getSessionFilter();
        assertEquals(3, filter.size());
        assertTrue(filter.contains(new Subnet(InetAddress.getByName("1.2.3.0"), 16)));
        assertTrue(filter.contains(new Subnet(InetAddress.getByName("1.2.4.0"), 16)));
        assertTrue(filter.contains(new Subnet(InetAddress.getByName("1.2.3.4"), 32)));
        listener = listeners.get("listener1");
        assertNotNull(listener);
        assertTrue(listener instanceof MyCustomListener);
        assertEquals(2223, listener.getPort());
View Full Code Here

TOP

Related Classes of org.apache.ftpserver.ipfilter.RemoteIpFilter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.