当前位置: 首页>>代码示例>>Java>>正文


Java IPLike类代码示例

本文整理汇总了Java中org.opennms.core.utils.IPLike的典型用法代码示例。如果您正苦于以下问题:Java IPLike类的具体用法?Java IPLike怎么用?Java IPLike使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IPLike类属于org.opennms.core.utils包,在下文中一共展示了IPLike类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testMatchRangeHex

import org.opennms.core.utils.IPLike; //导入依赖的package包/类
@Test
public void testMatchRangeHex() {
    // Test a bunch of case-sensitivity cases
    assertTrue(IPLike.matchRangeHex("C0", "BF-C1"));
    assertTrue(IPLike.matchRangeHex("c0", "BF-C1"));
    assertTrue(IPLike.matchRangeHex("C0", "bf-C1"));
    assertTrue(IPLike.matchRangeHex("C0", "BF-c1"));
    assertTrue(IPLike.matchRangeHex("C0", "bF-c1"));
    assertTrue(IPLike.matchRangeHex("C0", "Bf-c1"));
    assertTrue(IPLike.matchRangeHex("C0", "bf-c1"));
    assertTrue(IPLike.matchRangeHex("c0", "bf-c1"));

    assertTrue(IPLike.matchRangeHex("C0", "C0"));
    assertTrue(IPLike.matchRangeHex("c0", "C0"));
    assertTrue(IPLike.matchRangeHex("C0", "c0"));
    assertTrue(IPLike.matchRangeHex("c0", "c0"));

    assertTrue(IPLike.matchRangeHex("C0", "C0-C8"));
    assertTrue(IPLike.matchRangeHex("C0", "B4-C0"));

    assertTrue(IPLike.matchRangeHex("c0", "01-FF"));
    assertTrue(IPLike.matchRangeHex("c0", "*"));
    assertFalse(IPLike.matchRangeHex("c0", "01-09"));
    assertFalse(IPLike.matchRangeHex("c0", "1-9"));
    assertTrue(IPLike.matchRangeHex("5", "1-9"));
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:27,代码来源:IPLikeTest.java

示例2: isIpBlackListed

import org.opennms.core.utils.IPLike; //导入依赖的package包/类
public Boolean isIpBlackListed(String ipAddress) {
    for (String blackedIp : ipBlackList) {
        if (IPLike.matches(ipAddress, blackedIp)) {
            LOGGER.debug("IpAddress Black: {} \t vs \t {} \t OK", ipAddress, blackedIp);
            return true;
        } else {
            LOGGER.debug("IpAddress Black: {} \t vs \t {} \t no", ipAddress, blackedIp);
        }
    }
    return false;
}
 
开发者ID:OpenNMS,项目名称:opennms-provisioning-integration-server,代码行数:12,代码来源:InterfaceUtils.java

示例3: isIpWhiteListed

import org.opennms.core.utils.IPLike; //导入依赖的package包/类
public Boolean isIpWhiteListed(String ipAddress) {
    for (String whiteIp : ipWhiteList) {
        if (IPLike.matches(ipAddress, whiteIp)) {
            LOGGER.debug("IpAddress White: {} \t vs \t {} \t OK", ipAddress, whiteIp);
            return true;
        } else {
            LOGGER.debug("IpAddress White: {} \t vs \t {} \t no", ipAddress, whiteIp);
        }
    }
    return false;
}
 
开发者ID:OpenNMS,项目名称:opennms-provisioning-integration-server,代码行数:12,代码来源:InterfaceUtils.java

示例4: addIpWhite

import org.opennms.core.utils.IPLike; //导入依赖的package包/类
public void addIpWhite(String ip) {
    try {
        //This check forces valid IPLike syntax
        IPLike.matches("1.1.1.1", ip);
        ipWhiteList.add(ip);
    } catch (Exception ex) {
        LOGGER.error("WhiteList rejected illegal entry {}", ip, ex);
    }
}
 
开发者ID:OpenNMS,项目名称:opennms-provisioning-integration-server,代码行数:10,代码来源:InterfaceUtils.java

示例5: addIpBlack

import org.opennms.core.utils.IPLike; //导入依赖的package包/类
public void addIpBlack(String ip) {
    try {
        //This check forces valid IPLike syntax
        IPLike.matches("1.1.1.1", ip);
        ipBlackList.add(ip);
    } catch (Exception ex) {
        LOGGER.error("BlackList rejected illegal entry {}", ip, ex);
    }
}
 
开发者ID:OpenNMS,项目名称:opennms-provisioning-integration-server,代码行数:10,代码来源:InterfaceUtils.java

示例6: validateIPMatch

import org.opennms.core.utils.IPLike; //导入依赖的package包/类
/**
 * <p>validateIPMatch</p>
 *
 * @param ip a {@link java.lang.String} object.
 * @return a boolean.
 */
public boolean validateIPMatch(String ip){
  if(IPLike.matches(m_address, ip)){
      return m_isSupported;
  }else{
    return false;  
  }
    
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:15,代码来源:LoopResponse.java

示例7: isProtocolSupported

import org.opennms.core.utils.IPLike; //导入依赖的package包/类
/** {@inheritDoc} */
public boolean isProtocolSupported(InetAddress address, Map<String, Object> qualifiers) {
    
    if (qualifiers == null) {
        return false;
    }
    
    String ipMatch = getIpMatch(qualifiers);
    if (IPLike.matches(InetAddressUtils.str(address), ipMatch)) {
        return isSupported(qualifiers);
    } else {
        return false;
    }
    
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:16,代码来源:LoopPlugin.java

示例8: determineServerInitialResponse

import org.opennms.core.utils.IPLike; //导入依赖的package包/类
private void determineServerInitialResponse() {
    int serverResponseValue = -1;

    if (m_currentLine != null) {

        if (m_currentLine.startsWith("HTTP/")) {
            serverResponseValue = parseHttpResponse();

            if (IPLike.matchNumericListOrRange(String.valueOf(serverResponseValue), determineResponse(m_parameters))) {
                if (log().isDebugEnabled()) {
                    log().debug("determineServerResponse: valid server response: "+serverResponseValue+" found.");
                }
                m_serviceStatus = PollStatus.SERVICE_AVAILABLE;
            } else {
                m_serviceStatus = PollStatus.SERVICE_UNAVAILABLE;
                final StringBuffer sb = new StringBuffer();
                sb.append("HTTP response value: ");
                sb.append(serverResponseValue);
                sb.append(". Expecting: ");
                sb.append(determineResponse(m_parameters));
                sb.append(".");
                m_reason = sb.toString();
            }
        }
    }
    m_serverResponseCode = serverResponseValue;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:28,代码来源:HttpMonitor.java

示例9: testMatchRange

import org.opennms.core.utils.IPLike; //导入依赖的package包/类
@Test
public void testMatchRange() {
    assertTrue(IPLike.matchRange("192", "191-193"));
    assertTrue(IPLike.matchRange("192", "192"));
    assertTrue(IPLike.matchRange("192", "192-200"));
    assertTrue(IPLike.matchRange("192", "1-255"));
    assertTrue(IPLike.matchRange("192", "*"));
    assertFalse(IPLike.matchRange("192", "1-9"));
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:10,代码来源:IPLikeTest.java

示例10: testMatchOctet

import org.opennms.core.utils.IPLike; //导入依赖的package包/类
@Test
public void testMatchOctet() {
    assertTrue(IPLike.matchNumericListOrRange("192", "191,192,193"));
    assertFalse(IPLike.matchNumericListOrRange("192", "190,191,194"));
    assertTrue(IPLike.matchNumericListOrRange("192", "10,172,190-193"));
    assertFalse(IPLike.matchNumericListOrRange("192", "10,172,193-199"));
    assertTrue(IPLike.matchNumericListOrRange("205", "200-300,400-500"));
    assertTrue(IPLike.matchNumericListOrRange("405", "200-300,400-500"));
    assertFalse(IPLike.matchNumericListOrRange("505", "200-300,400-500"));
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:11,代码来源:IPLikeTest.java

示例11: getAgentConfig

import org.opennms.core.utils.IPLike; //导入依赖的package包/类
/**
 * <p>getAgentConfig</p>
 *
 * @param agentInetAddress a {@link java.net.InetAddress} object.
 * @return a {@link org.opennms.protocols.nsclient.NSClientAgentConfig} object.
 */
public NSClientAgentConfig getAgentConfig(final InetAddress agentInetAddress) {
    getReadLock().lock();

    try {
        if (m_config == null) {
            return new NSClientAgentConfig(agentInetAddress);
        }

        final NSClientAgentConfig agentConfig = new NSClientAgentConfig(agentInetAddress);

        //Now set the defaults from the m_config
        setNSClientAgentConfig(agentConfig, new Definition());

        // Attempt to locate the node
        DEFLOOP: for (final Definition def : m_config.getDefinitionCollection()) {
            // check the specifics first

            for (final String saddr : def.getSpecificCollection()) {
                final InetAddress addr = InetAddressUtils.addr(saddr);
                if (addr.equals(agentConfig.getAddress())) {
                    setNSClientAgentConfig(agentConfig, def);
                    break DEFLOOP;
                }
            }

            // check the ranges
            //
            for (final Range rng : def.getRangeCollection()) {
                if (InetAddressUtils.isInetAddressInRange(InetAddressUtils.str(agentConfig.getAddress()), rng.getBegin(), rng.getEnd())) {
                    setNSClientAgentConfig(agentConfig, def);
                    break DEFLOOP;
                }
            }

            // check the matching IP expressions
            for (final String ipMatch : def.getIpMatchCollection()) {
                if (IPLike.matches(InetAddressUtils.str(agentInetAddress), ipMatch)) {
                    setNSClientAgentConfig(agentConfig, def);
                    break DEFLOOP;
                }
            }

        } // end DEFLOOP

        if (agentConfig == null) {
            setNSClientAgentConfig(agentConfig, new Definition());
        }

        return agentConfig;
    } finally {
        getReadLock().unlock();
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:60,代码来源:NSClientPeerFactory.java

示例12: getAgentConfig

import org.opennms.core.utils.IPLike; //导入依赖的package包/类
/**
 * <p>getAgentConfig</p>
 *
 * @param agentInetAddress a {@link java.net.InetAddress} object.
 * @return a {@link org.opennms.protocols.ami.AmiAgentConfig} object.
 */
public AmiAgentConfig getAgentConfig(final InetAddress agentInetAddress) {
    getReadLock().lock();
    
    try {
        if (m_config == null) return new AmiAgentConfig(agentInetAddress);
        
        final AmiAgentConfig agentConfig = new AmiAgentConfig(agentInetAddress);
        
        //Now set the defaults from the m_config
        setAmiAgentConfig(agentConfig, new Definition());

        // Attempt to locate the node
        DEFLOOP: for (final Definition def : m_config.getDefinitionCollection()) {
            // check the specifics first
            for (String saddr : def.getSpecificCollection()) {
                saddr = saddr.trim();
                final InetAddress addr = InetAddressUtils.addr(saddr);
                if (addr.equals(agentConfig.getAddress())) {
                    setAmiAgentConfig(agentConfig, def);
                    break DEFLOOP;
                }
            }

            // check the ranges
            for (final Range rng : def.getRangeCollection()) {
                if (InetAddressUtils.isInetAddressInRange(InetAddressUtils.str(agentConfig.getAddress()), rng.getBegin(), rng.getEnd())) {
                    setAmiAgentConfig(agentConfig, def );
                    break DEFLOOP;
                }
            }
            
            // check the matching IP expressions
            for (final String ipMatch : def.getIpMatchCollection()) {
                if (IPLike.matches(InetAddressUtils.str(agentInetAddress), ipMatch)) {
                    setAmiAgentConfig(agentConfig, def);
                    break DEFLOOP;
                }
            }
            
        } // end DEFLOOP

        if (agentConfig == null) setAmiAgentConfig(agentConfig, new Definition());

        return agentConfig;
    } finally {
        getReadLock().unlock();
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:55,代码来源:AmiPeerFactory.java

示例13: testCountChar

import org.opennms.core.utils.IPLike; //导入依赖的package包/类
@Test
public void testCountChar() {
    assertEquals(2, IPLike.countChar('-', "test-this-please"));
    assertEquals(3, IPLike.countChar('-', "test-this-please-"));
    assertEquals(4, IPLike.countChar('-', "-test-this-please-"));
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:7,代码来源:IPLikeTest.java

示例14: testVerifyIpMatch

import org.opennms.core.utils.IPLike; //导入依赖的package包/类
@Test
public void testVerifyIpMatch() {
    assertTrue(IPLike.matches("192.168.0.1", "*.*.*.*"));
    assertTrue(IPLike.matches("192.168.0.1", "192.*.*.*"));
    assertTrue(IPLike.matches("192.168.0.1", "*.168.*.*"));
    assertTrue(IPLike.matches("192.168.0.1", "*.*.0.*"));
    assertTrue(IPLike.matches("192.168.0.1", "*.*.*.1"));
    assertTrue(IPLike.matches("192.168.0.1", "*.*.*.0-7"));
    assertTrue(IPLike.matches("192.168.0.1", "192.168.0.0-7"));
    assertTrue(IPLike.matches("192.168.0.1", "192.166,167,168.*.0,1,5-10"));
    assertFalse(IPLike.matches("192.168.0.1", "10.0.0.1"));
    assertFalse(IPLike.matches("192.168.0.1", "*.168.*.2"));
    assertFalse(IPLike.matches("192.168.0.1", "10.168.0.1"));
    assertTrue(IPLike.matches("10.1.1.1", "10.1.1.1"));

    assertTrue(IPLike.matches("fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd", "*:*:*:*:*:*:*:*"));
    assertTrue(IPLike.matches("fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd%4", "*:*:*:*:*:*:*:*"));
    assertTrue(IPLike.matches("fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd%4", "*:*:*:*:*:*:*:*%4"));
    assertFalse(IPLike.matches("fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd", "*:*:*:*:*:*:*:*%4"));

    assertTrue(IPLike.matches("fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd", "fe80:*:*:*:*:*:*:*"));
    assertTrue(IPLike.matches("fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd%4", "fe80:*:*:*:*:*:*:*"));
    assertTrue(IPLike.matches("fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd%4", "fe80:*:*:*:*:*:*:*%4"));
    assertFalse(IPLike.matches("fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd", "fe80:*:*:*:*:*:*:*%4"));

    assertTrue(IPLike.matches("fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd", "*:*:*:0:*:*:*:*"));
    assertTrue(IPLike.matches("fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd%4", "*:*:*:0:*:*:*:*"));
    assertTrue(IPLike.matches("fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd%4", "*:*:*:0:*:*:*:*%4"));
    assertFalse(IPLike.matches("fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd", "*:*:*:0:*:*:*:*%4"));

    assertTrue(IPLike.matches("fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd", "*:*:*:*:*:bbbb:*:*"));
    assertTrue(IPLike.matches("fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd%4", "*:*:*:*:*:bbbb:*:*"));
    assertTrue(IPLike.matches("fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd%4", "*:*:*:*:*:bbbb:*:*%4"));
    assertFalse(IPLike.matches("fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd", "*:*:*:*:*:bbbb:*:*%4"));

    assertTrue(IPLike.matches("fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd", "*:*:*:*:*:bbb0-bbbf:*:*"));
    assertTrue(IPLike.matches("fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd%4", "*:*:*:*:*:bbb0-bbbf:*:*"));
    assertTrue(IPLike.matches("fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd%4", "*:*:*:*:*:bbb0-bbbf:*:*%4"));
    assertFalse(IPLike.matches("fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd", "*:*:*:*:*:bbb0-bbbf:*:*%4"));

    assertTrue(IPLike.matches("fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd", "fe80:0000:0000:0000:aaaa:bbb0-bbbf:cccc:dddd"));
    assertTrue(IPLike.matches("fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd%4", "fe80:0000:0000:0000:aaaa:bbb0-bbbf:cccc:dddd"));
    assertTrue(IPLike.matches("fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd%4", "fe80:0000:0000:0000:aaaa:bbb0-bbbf:cccc:dddd%4"));
    assertFalse(IPLike.matches("fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd", "fe80:0000:0000:0000:aaaa:bbb0-bbbf:cccc:dddd%4"));

    assertTrue(IPLike.matches("fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd", "fe20,fe70-fe90:0000:0000:0000:*:bbb0,bbb1,bbb2,bbb3,bbb4,bbbb,bbbc:cccc:dddd"));
    assertTrue(IPLike.matches("fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd%4", "fe20,fe70-fe90:0000:0000:0000:*:bbb0,bbb1,bbb2,bbb3,bbb4,bbbb,bbbc:cccc:dddd"));
    assertTrue(IPLike.matches("fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd%4", "fe20,fe70-fe90:0000:0000:0000:*:bbb0,bbb1,bbb2,bbb3,bbb4,bbbb,bbbc:cccc:dddd%4"));
    assertFalse(IPLike.matches("fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd", "fe20,fe70-fe90:0000:0000:0000:*:bbb0,bbb1,bbb2,bbb3,bbb4,bbbb,bbbc:cccc:dddd%4"));

    assertTrue(IPLike.matches("fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd", "fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd"));
    assertTrue(IPLike.matches("fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd%4", "fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd"));
    assertTrue(IPLike.matches("fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd%4", "fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd%4"));
    assertFalse(IPLike.matches("fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd", "fe80:0000:0000:0000:aaaa:bbbb:cccc:dddd%4"));
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:56,代码来源:IPLikeTest.java


注:本文中的org.opennms.core.utils.IPLike类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。