Package host.anzo.core.service
Class GeoIpService
java.lang.Object
host.anzo.core.service.GeoIpService
Provides GeoIP lookup services using MaxMind databases and web services.
This service initializes on startup and offers methods to retrieve geographical information based on IP addresses. It supports both local database lookups (GeoLite2-City) and web service-based insights (requires valid MaxMind credentials).
Configuration:
- Requires
GeoLite2-City.mmdbin classpath - Web service requires system properties
maxMindAccountIdandmaxMindLicenseKey
- Since:
- 10/24/2018
-
Method Summary
Modifier and TypeMethodDescriptioncom.maxmind.geoip2.model.CityResponseRetrieves city-level information for a given IP address using the local database.getCountryName(String ipAddress) Retrieves the country name associated with an IP address using the local database.Builds aStatsSetwith geo-location data for an IP address.com.maxmind.geoip2.model.InsightsResponsegetInsights(String ipAddress) Retrieves detailed insights for an IP address using MaxMind's web service.
-
Method Details
-
getCity
Retrieves city-level information for a given IP address using the local database.- Parameters:
ipAddress- IP address to query (e.g., "192.168.1.1")- Returns:
CityResponsewith geographical data, ornullif:- Database not initialized
- Invalid IP format
- Lookup error occurs
-
getCountryName
Retrieves the country name associated with an IP address using the local database.- Parameters:
ipAddress- IP address to query- Returns:
- Country name as String, or
nullif:- Database not initialized
- Country data unavailable
- Lookup error occurs
-
getInsights
Retrieves detailed insights for an IP address using MaxMind's web service.Requires valid
maxMindAccountIdandmaxMindLicenseKeysystem properties.- Parameters:
ipAddress- IP address to query- Returns:
InsightsResponsewith extended data, ornullif:- Web service client not initialized
- Invalid credentials
- Lookup error occurs
-
getInfo
Builds aStatsSetwith geo-location data for an IP address.Includes different data tiers based on the
fullparameter:- Basic (
full=false): City, country, coordinates, network traits - Full (
full=true): ISP, organization, proxy detection, mobile codes
- Parameters:
ipAddress- IP address to analyzefull-trueto include extended insights data- Returns:
- Populated
StatsSet, ornullon any error - See Also:
- Basic (
-