Package org.apache.james.util.netmatcher

Examples of org.apache.james.util.netmatcher.NetMatcher


    public void init() throws MessagingException {
       
        Collection<String> nets = allowedNetworks();
       
        if (nets != null) {
            authorizedNetworks = new NetMatcher(allowedNetworks(), dnsServer) {
                protected void log(String s) {
                    AbstractNetworkMatcher.this.log(s);
                }
            };
            log("Authorized addresses: " + authorizedNetworks.toString());
View Full Code Here


                selectRS = selectStmt.executeQuery();
                List<String> nets = new ArrayList<String>();
                while (selectRS.next()) {
                    nets.add(selectRS.getString(1));
                }
                NetMatcher matcher = new NetMatcher(nets, dns);
                boolean matched = matcher.matchInetNetwork(mail.getRemoteAddr());

                if (matched == false) {
                    selectStmt = conn.prepareStatement(selectNetworks);
                    selectStmt.setString(1, "*");
                    selectStmt.setString(2, recipientHost);
                    selectRS = selectStmt.executeQuery();
                    nets = new ArrayList<String>();
                    while (selectRS.next()) {
                        nets.add(selectRS.getString(1));
                    }
                    matcher = new NetMatcher(nets, dns);
                    matched = matcher.matchInetNetwork(mail.getRemoteAddr());
                }
                return matched;
            } finally {
                theJDBCUtil.closeJDBCResultSet(selectRS);
            }
View Full Code Here

            String[] whitelistArray = nets.split(",");
            List<String> wList = new ArrayList<String>(whitelistArray.length);
            for (int i = 0 ; i< whitelistArray.length; i++) {
                wList.add(whitelistArray[i].trim());
            }
            setWhiteListedNetworks( new NetMatcher(wList ,dnsService));
            serviceLog.info("Whitelisted addresses: " + getWhiteListedNetworks().toString());
           
        }            

        // Get the SQL file location
View Full Code Here

   
    /**
     *
     */
    public void testIpV4NetworksUniqueness() {
        netMatcher = new NetMatcher(DNSFixture.LOCALHOST_IP_V4_ADDRESSES_DUPLICATE, DNSFixture.DNS_SERVER_IPV4_MOCK);
        assertEquals("[172.16.0.0/255.255.0.0, 192.168.1.0/255.255.255.0]", netMatcher.toString());
    }
View Full Code Here

   
    /**
     *
     */
    public void testIpV6NetworksUniqueness() {
        netMatcher = new NetMatcher(DNSFixture.LOCALHOST_IP_V6_ADDRESSES_DUPLICATE, DNSFixture.DNS_SERVER_IPV6_MOCK);
        assertEquals("[0:0:0:0:0:0:0:1/32768, 2781:db8:1234:0:0:0:0:0/48]", netMatcher.toString());
    }
View Full Code Here

    /**
     * @throws UnknownHostException
     */
    public void testIpV4Matcher() throws UnknownHostException {
       
        netMatcher = new NetMatcher(DNSFixture.LOCALHOST_IP_V4_ADDRESSES, DNSFixture.DNS_SERVER_IPV4_MOCK);
       
        assertEquals(true, netMatcher.matchInetNetwork("127.0.0.1"));
        assertEquals(true, netMatcher.matchInetNetwork("localhost"));
        assertEquals(true, netMatcher.matchInetNetwork("172.16.15.254"));
        assertEquals(true, netMatcher.matchInetNetwork("192.168.1.254"));
View Full Code Here

    /**
     * @throws UnknownHostException
     */
    public void testIpV4MatcherWithIpV6() throws UnknownHostException {
       
        netMatcher = new NetMatcher(DNSFixture.LOCALHOST_IP_V4_ADDRESSES, DNSFixture.DNS_SERVER_IPV4_MOCK);
       
        assertEquals(false, netMatcher.matchInetNetwork("0:0:0:0:0:0:0:1%0"));
        assertEquals(false, netMatcher.matchInetNetwork("00:00:00:00:00:00:00:1"));
        assertEquals(false, netMatcher.matchInetNetwork("00:00:00:00:00:00:00:2"));
        assertEquals(false, netMatcher.matchInetNetwork("2781:0db8:1234:8612:45ee:ffff:fffe:0001"));
View Full Code Here

    /**
     * @throws UnknownHostException
     */
    public void testIpV6Matcher() throws UnknownHostException {
       
        netMatcher = new NetMatcher(DNSFixture.LOCALHOST_IP_V6_ADDRESSES, DNSFixture.DNS_SERVER_IPV6_MOCK);
       
        assertEquals(true, netMatcher.matchInetNetwork("0:0:0:0:0:0:0:1%0"));
        assertEquals(true, netMatcher.matchInetNetwork("00:00:00:00:00:00:00:1"));
        assertEquals(false, netMatcher.matchInetNetwork("00:00:00:00:00:00:00:2"));
        assertEquals(true, netMatcher.matchInetNetwork("2781:0db8:1234:8612:45ee:ffff:fffe:0001"));
View Full Code Here

    /**
     * @throws UnknownHostException
     */
    public void testIpV6MatcherWithIpV4() throws UnknownHostException {
       
        netMatcher = new NetMatcher(DNSFixture.LOCALHOST_IP_V6_ADDRESSES, DNSFixture.DNS_SERVER_IPV6_MOCK);
       
        assertEquals(false, netMatcher.matchInetNetwork("127.0.0.1"));
        assertEquals(false, netMatcher.matchInetNetwork("localhost"));
        assertEquals(false, netMatcher.matchInetNetwork("172.16.15.254"));
        assertEquals(false, netMatcher.matchInetNetwork("192.168.1.254"));
View Full Code Here

                java.util.Collection<String> networks = new java.util.ArrayList<String>();
                while (st.hasMoreTokens()) {
                    String addr = st.nextToken();
                    networks.add(addr);
                }
                authorizedNetworks = new NetMatcher(networks, getDNSService());
            }

            if (authorizedNetworks != null) {
                getLogger().info("Authorized addresses: " + authorizedNetworks.toString());
            }
View Full Code Here

TOP

Related Classes of org.apache.james.util.netmatcher.NetMatcher

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.