Examples of IpLocator


Examples of de.forsthaus.backend.util.IpLocator

   * @param log
   */
  private void saveCompleteIPDataFromLookUpHost(SecLoginlog log) {

    final Ip2Country ip2c = getIp2CountryService().getNewIp2Country();
    final IpLocator ipl = getIp2CountryService().hostIpLookUpIp(log.getLglIp());
    /** For testing on a local tomcat */
    // IpLocator ipl =
    // getIp2CountryService().hostIpLookUpIp("95.111.227.104");

    if (ipl != null) {

      ip2c.setI2cCity(ipl.getCity());
      ip2c.setI2cLatitude(ipl.getLatitude());
      ip2c.setI2cLongitude(ipl.getLongitude());
      ip2c.setCountryCode(getCountryCodeService().getCountryCodeByCode2(ipl.getCountryCode()));

      getIp2CountryService().saveOrUpdate(ip2c);

      // update the LoginLog with a relation to Ip2Country
      log.setIp2Country(ip2c);
View Full Code Here

Examples of de.forsthaus.backend.util.IpLocator

          if (inetAddress.isLoopbackAddress() || inetAddress.isSiteLocalAddress()) {
            continue;
          }

          if (StringUtils.isEmpty(ip2c.getI2cCity())) {
            final IpLocator ipl = getIp2CountryService().hostIpLookUpIp(secLoginlog.getLglIp());
            // /** For testing on a local tomcat */
            // IpLocator ipl =
            // getIp2CountryService().hostIpLookUpIp("95.111.227.104");

            if (ipl != null) {

              if (logger.isDebugEnabled()) {
                logger.debug("hostLookUp resolved for : " + secLoginlog.getLglIp());
              }

              ip2c.setI2cCity(ipl.getCity());
              ip2c.setI2cLatitude(ipl.getLatitude());
              ip2c.setI2cLongitude(ipl.getLongitude());
              getIp2CountryService().saveOrUpdate(ip2c);

              secLoginlog.setIp2Country(ip2c);
              getLoginLoggingService().saveOrUpdate(secLoginlog);

              countRec = countRec + 1;
            }
          }
        } catch (final Exception e) {
          logger.warn("", e);
          continue;
        }

      } else {
        // create a new entry
        final Ip2Country ip2 = getIp2CountryService().getNewIp2Country();

        try {
          // try to get a ipToCountry for the IP from the table
          final InetAddress inetAddress = InetAddress.getByName(secLoginlog.getLglIp());

          // Skip a local ip. Therefore is no country to identify.
          if (inetAddress.isLoopbackAddress() || inetAddress.isSiteLocalAddress()) {
            continue;
          }

          final IpLocator ipl = getIp2CountryService().hostIpLookUpIp(secLoginlog.getLglIp());
          // /** For testing on a local tomcat */
          // IpLocator ipl =
          // getIp2CountryService().hostIpLookUpIp("95.111.227.104");

          if (ipl != null) {

            if (logger.isDebugEnabled()) {
              logger.debug("hostLookUp resolved for : " + secLoginlog.getLglIp());
            }

            final CountryCode sysCC = getCountryCodeService().getCountryCodeByCode2(ipl.getCountryCode());
            ip2.setCountryCode(sysCC);

            ip2.setI2cCity(ipl.getCity());
            ip2.setI2cLatitude(ipl.getLatitude());
            ip2.setI2cLongitude(ipl.getLongitude());
            getIp2CountryService().saveOrUpdate(ip2);

            secLoginlog.setIp2Country(ip2);
            getLoginLoggingService().saveOrUpdate(secLoginlog);

View Full Code Here

Examples of de.forsthaus.backend.util.IpLocator

  @Override
  public IpLocator hostIpLookUpIp(String ip) {
    // TODO how we can catch a timeout and get the ip-data later
    try {
      IpLocator ipl = IpLocator.locate(ip);
      if (ipl.getCountry().length() > 0) {
        return ipl;
      }
      return null;
    } catch (Exception e) {
      throw new RuntimeException(e);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.