Skip to main content
Skip table of contents

GeoIpService

Name

GeoIpService

Class Path

be.securit.trustbuilder.service.geoip.GeoIpService

Versions

9 10 11

Overview

The GeoIpService provides functionality for resolving IP addresses to geographic locations using a GeoIP database. It allows for loading a database file and performing lookups to retrieve city-level location information.


Available Functions

setDatabaseFileLocation(String databaseFileLocation)

Sets the location of the GeoIP database file and initializes the database reader.

  • Parameters:

    • databaseFileLocation (String): The file path of the GeoIP database.

  • Exceptions:

    • Throws RuntimeException if the file cannot be read.


resolveIpToLocation(String ip): String

Resolves an IP address to a geographic location.

  • Parameters:

    • ip (String): The IP address to look up.

  • Returns:

    • String: A JSON string representing the resolved location details.

    • {"error" : "invalid IP"} if the provided IP address is invalid.

    • {"error" : "Not found"} if no location data is found for the IP.

    • Throws RuntimeException if there is an issue reading the database.


Internal Components

(For internal processing, not intended for direct use.)

  • GeoDatabaseReaderFactory
    A factory interface for creating DatabaseReader instances.

  • DatabaseReader databaseReader
    The MaxMind DatabaseReader instance used to look up IP addresses.


Summary

The GeoIpService allows applications to:

  • Load a GeoIP database file.

  • Perform city-level lookups for given IP addresses.

  • Handle invalid or missing IP data gracefully.

This service is essential for integrating geographic IP resolution into security or analytics workflows.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.