Package org.apache.ftpserver.ipfilter

Examples of org.apache.ftpserver.ipfilter.DefaultIpFilter


        Element blacklistElm = SpringUtil.getChildElement(element,
                FtpServerNamespaceHandler.FTPSERVER_NS, "blacklist");
        if (blacklistElm != null) {
          LOG.warn("Element 'blacklist' is deprecated, and may be removed in a future release. Please use 'ip-filter' instead. ");
          try {
        DefaultIpFilter ipFilter = new DefaultIpFilter(IpFilterType.DENY, blacklistElm.getTextContent());
              factoryBuilder.addPropertyValue("ipFilter", ipFilter);
      }
      catch (UnknownHostException e) {
        throw new IllegalArgumentException("Invalid IP address or subnet in the 'blacklist' element", e);
      }
        }
       
        Element ipFilterElement = SpringUtil.getChildElement(element, FtpServerNamespaceHandler.FTPSERVER_NS, "ip-filter");
        if(ipFilterElement != null) {
          if(blacklistElm != null) {
            throw new FtpServerConfigurationException("Element 'ipFilter' may not be used when 'blacklist' element is specified. ");
          }
          String filterType = ipFilterElement.getAttribute("type");
          try {
        DefaultIpFilter ipFilter = new DefaultIpFilter(IpFilterType.parse(filterType), ipFilterElement.getTextContent());
              factoryBuilder.addPropertyValue("ipFilter", ipFilter);
      }
      catch (UnknownHostException e) {
        throw new IllegalArgumentException("Invalid IP address or subnet in the 'ip-filter' element");
      }
View Full Code Here


      List<Subnet> blockedSubnets) {
      if(blockedAddresses == null && blockedSubnets == null) {
        return null;
      }
    //Initialize the IP filter with Deny type
    DefaultIpFilter ipFilter = new DefaultIpFilter(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(InetAddress.getByName("1.2.3.4"), InetAddress.getByName(((NioListener) listener)
            .getDataConnectionConfiguration().getActiveLocalAddress()) );
        assertEquals("123-125", ((NioListener) listener)
                .getDataConnectionConfiguration().getPassivePorts());

        DefaultIpFilter filter = (DefaultIpFilter) listener.getIpFilter();
        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.DefaultIpFilter

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.