diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 70d7efa9b..d2d0620a2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,7 +9,7 @@ jobs: matrix: distribution: ['zulu'] os: [ubuntu-latest, windows-latest, macos-latest] - version: [ 11, 17, 21, 22 ] + version: [ 17, 21, 24 ] steps: - uses: actions/checkout@v5 with: diff --git a/CHANGELOG.md b/CHANGELOG.md index 58c65c933..c9af60e58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,28 @@ CHANGELOG ========= +5.0.0 +------------------ + +* The deprecation notices for IP Risk database support have been removed. + IP Risk database support will continue to be maintained. +* **BREAKING:** The deprecated `WebServiceClient.Builder` methods + `connectTimeout(int)`, `readTimeout(int)`, and `proxy(Proxy)` have been + removed. Use `connectTimeout(Duration)`, `requestTimeout(Duration)`, and + `proxy(ProxySelector)` respectively. +* **BREAKING:** The deprecated `WebServiceClient.close()` method has been + removed along with the `Closeable` interface implementation. +* **BREAKING:** The deprecated `getUrl()` methods in `HttpException` and + `InvalidRequestException` have been removed. Use `getUri()` instead. +* **BREAKING:** The deprecated `Traits` constructors and methods + `isAnonymousProxy()` and `isSatelliteProvider()` have been removed. Use the + GeoIP2 Anonymous IP database for anonymous proxy detection instead. +* **BREAKING:** The deprecated `Location.getMetroCode()` method has been + removed. Metro code values are no longer maintained. +* **BREAKING:** Java 11 support has been dropped. Java 17 or later is now required. +* **BREAKING:** Removed explicit `serialVersionUID` from all exception classes. + Java will auto-generate serialVersionUID when needed, following modern practices. + 4.4.0 (2025-08-28) ------------------ diff --git a/pom.xml b/pom.xml index 91472e22e..dfc540e70 100644 --- a/pom.xml +++ b/pom.xml @@ -148,7 +148,7 @@ https://maxmind.github.io/MaxMind-DB-Reader-java/doc/latest/ - 11 + 17 -missing @@ -198,8 +198,8 @@ maven-compiler-plugin 3.14.0 - 11 - 11 + 17 + 17 11 diff --git a/src/main/java/com/maxmind/geoip2/DatabaseProvider.java b/src/main/java/com/maxmind/geoip2/DatabaseProvider.java index c7c28d577..68f75d49d 100644 --- a/src/main/java/com/maxmind/geoip2/DatabaseProvider.java +++ b/src/main/java/com/maxmind/geoip2/DatabaseProvider.java @@ -89,9 +89,7 @@ Optional tryAnonymousPlus(InetAddress ipAddress) throws I * @return an IpRiskResponse for the requested IP address. * @throws com.maxmind.geoip2.exception.GeoIp2Exception if there is an error looking up the IP * @throws java.io.IOException if there is an IO error - * @deprecated This database has been discontinued. */ - @Deprecated IpRiskResponse ipRisk(InetAddress ipAddress) throws IOException, GeoIp2Exception; @@ -102,9 +100,7 @@ IpRiskResponse ipRisk(InetAddress ipAddress) throws IOException, * @return an IPRiskResponse for the requested IP address or empty if it is not in the DB. * @throws com.maxmind.geoip2.exception.GeoIp2Exception if there is an error looking up the IP * @throws java.io.IOException if there is an IO error - * @deprecated This database has been discontinued. */ - @Deprecated Optional tryIpRisk(InetAddress ipAddress) throws IOException, GeoIp2Exception; diff --git a/src/main/java/com/maxmind/geoip2/DatabaseReader.java b/src/main/java/com/maxmind/geoip2/DatabaseReader.java index 0109e45a6..1c220e1c1 100644 --- a/src/main/java/com/maxmind/geoip2/DatabaseReader.java +++ b/src/main/java/com/maxmind/geoip2/DatabaseReader.java @@ -24,7 +24,6 @@ import java.io.IOException; import java.io.InputStream; import java.net.InetAddress; -import java.util.Collections; import java.util.List; import java.util.Optional; @@ -150,9 +149,8 @@ private int getDatabaseType() { type |= DatabaseType.ISP.type; } if (type == 0) { - // XXX - exception type - throw new UnsupportedOperationException( - "Invalid attempt to open an unknown database type: " + databaseType); + throw new IllegalArgumentException( + "Unsupported database type: " + databaseType); } return type; } @@ -174,7 +172,7 @@ public static final class Builder { final File database; final InputStream stream; - List locales = Collections.singletonList("en"); + List locales = List.of("en"); FileMode mode = FileMode.MEMORY_MAPPED; NodeCache cache = NoCache.getInstance(); @@ -239,28 +237,7 @@ public DatabaseReader build() throws IOException { } } - static final class LookupResult { - final T model; - final String ipAddress; - final Network network; - - LookupResult(T model, String ipAddress, Network network) { - this.model = model; - this.ipAddress = ipAddress; - this.network = network; - } - - T getModel() { - return this.model; - } - - String getIpAddress() { - return this.ipAddress; - } - - Network getNetwork() { - return this.network; - } + static record LookupResult(T model, String ipAddress, Network network) { } /** @@ -333,15 +310,15 @@ private Optional getCountry( CountryResponse.class, DatabaseType.COUNTRY ); - CountryResponse response = result.getModel(); + CountryResponse response = result.model(); if (response == null) { return Optional.empty(); } return Optional.of( new CountryResponse( response, - result.getIpAddress(), - result.getNetwork(), + result.ipAddress(), + result.network(), locales ) ); @@ -372,15 +349,15 @@ private Optional getCity( CityResponse.class, DatabaseType.CITY ); - CityResponse response = result.getModel(); + CityResponse response = result.model(); if (response == null) { return Optional.empty(); } return Optional.of( new CityResponse( response, - result.getIpAddress(), - result.getNetwork(), + result.ipAddress(), + result.network(), locales ) ); @@ -419,15 +396,15 @@ private Optional getAnonymousIp( AnonymousIpResponse.class, DatabaseType.ANONYMOUS_IP ); - AnonymousIpResponse response = result.getModel(); + AnonymousIpResponse response = result.model(); if (response == null) { return Optional.empty(); } return Optional.of( new AnonymousIpResponse( response, - result.getIpAddress(), - result.getNetwork() + result.ipAddress(), + result.network() ) ); } @@ -466,15 +443,15 @@ private Optional getAnonymousPlus( AnonymousPlusResponse.class, DatabaseType.ANONYMOUS_PLUS ); - AnonymousPlusResponse response = result.getModel(); + AnonymousPlusResponse response = result.model(); if (response == null) { return Optional.empty(); } return Optional.of( new AnonymousPlusResponse( response, - result.getIpAddress(), - result.getNetwork() + result.ipAddress(), + result.network() ) ); } @@ -487,9 +464,7 @@ private Optional getAnonymousPlus( * @return a IPRiskResponse for the requested IP address. * @throws GeoIp2Exception if there is an error looking up the IP * @throws IOException if there is an IO error - * @deprecated This database has been discontinued. */ - @Deprecated @Override public IpRiskResponse ipRisk(InetAddress ipAddress) throws IOException, GeoIp2Exception { @@ -501,14 +476,12 @@ public IpRiskResponse ipRisk(InetAddress ipAddress) throws IOException, return r.get(); } - @Deprecated @Override public Optional tryIpRisk(InetAddress ipAddress) throws IOException, GeoIp2Exception { return getIpRisk(ipAddress); } - @Deprecated private Optional getIpRisk(InetAddress ipAddress) throws IOException, GeoIp2Exception { LookupResult result = this.get( @@ -516,15 +489,15 @@ private Optional getIpRisk(InetAddress ipAddress) throws IOExcep IpRiskResponse.class, DatabaseType.IP_RISK ); - IpRiskResponse response = result.getModel(); + IpRiskResponse response = result.model(); if (response == null) { return Optional.empty(); } return Optional.of( new IpRiskResponse( response, - result.getIpAddress(), - result.getNetwork() + result.ipAddress(), + result.network() ) ); } @@ -561,15 +534,15 @@ private Optional getAsn(InetAddress ipAddress) AsnResponse.class, DatabaseType.ASN ); - AsnResponse response = result.getModel(); + AsnResponse response = result.model(); if (response == null) { return Optional.empty(); } return Optional.of( new AsnResponse( response, - result.getIpAddress(), - result.getNetwork() + result.ipAddress(), + result.network() ) ); } @@ -607,15 +580,15 @@ private Optional getConnectionType( ConnectionTypeResponse.class, DatabaseType.CONNECTION_TYPE ); - ConnectionTypeResponse response = result.getModel(); + ConnectionTypeResponse response = result.model(); if (response == null) { return Optional.empty(); } return Optional.of( new ConnectionTypeResponse( response, - result.getIpAddress(), - result.getNetwork() + result.ipAddress(), + result.network() ) ); } @@ -653,15 +626,15 @@ private Optional getDomain( DomainResponse.class, DatabaseType.DOMAIN ); - DomainResponse response = result.getModel(); + DomainResponse response = result.model(); if (response == null) { return Optional.empty(); } return Optional.of( new DomainResponse( response, - result.getIpAddress(), - result.getNetwork() + result.ipAddress(), + result.network() ) ); } @@ -699,15 +672,15 @@ private Optional getEnterprise( EnterpriseResponse.class, DatabaseType.ENTERPRISE ); - EnterpriseResponse response = result.getModel(); + EnterpriseResponse response = result.model(); if (response == null) { return Optional.empty(); } return Optional.of( new EnterpriseResponse( response, - result.getIpAddress(), - result.getNetwork(), + result.ipAddress(), + result.network(), locales ) ); @@ -746,15 +719,15 @@ private Optional getIsp( IspResponse.class, DatabaseType.ISP ); - IspResponse response = result.getModel(); + IspResponse response = result.model(); if (response == null) { return Optional.empty(); } return Optional.of( new IspResponse( response, - result.getIpAddress(), - result.getNetwork() + result.ipAddress(), + result.network() ) ); } diff --git a/src/main/java/com/maxmind/geoip2/WebServiceClient.java b/src/main/java/com/maxmind/geoip2/WebServiceClient.java index c612b9171..02a31f94b 100644 --- a/src/main/java/com/maxmind/geoip2/WebServiceClient.java +++ b/src/main/java/com/maxmind/geoip2/WebServiceClient.java @@ -16,12 +16,10 @@ import com.maxmind.geoip2.model.CityResponse; import com.maxmind.geoip2.model.CountryResponse; import com.maxmind.geoip2.model.InsightsResponse; -import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.net.InetAddress; import java.net.InetSocketAddress; -import java.net.Proxy; import java.net.ProxySelector; import java.net.URI; import java.net.URISyntaxException; @@ -30,9 +28,7 @@ import java.net.http.HttpResponse; import java.nio.charset.StandardCharsets; import java.time.Duration; -import java.util.ArrayList; import java.util.Base64; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -107,7 +103,7 @@ * throws a {@link GeoIp2Exception}. *

*/ -public class WebServiceClient implements WebServiceProvider, Closeable { +public class WebServiceClient implements WebServiceProvider { private final String host; private final List locales; private final String authHeader; @@ -179,7 +175,7 @@ public static final class Builder { Duration connectTimeout = null; Duration requestTimeout = Duration.ofSeconds(20); - List locales = Collections.singletonList("en"); + List locales = List.of("en"); private ProxySelector proxy = null; private HttpClient httpClient = null; @@ -192,17 +188,6 @@ public Builder(int accountId, String licenseKey) { this.licenseKey = licenseKey; } - /** - * @param val Timeout in milliseconds to establish a connection to the - * web service. The default is 3000 (3 seconds). - * @return Builder object - * @deprecated Use connectTimeout(Duration) instead - */ - @Deprecated - public Builder connectTimeout(int val) { - this.connectTimeout = Duration.ofMillis(val); - return this; - } /** * @param val Timeout duration to establish a connection to the @@ -254,22 +239,10 @@ public WebServiceClient.Builder port(int val) { * @return Builder object */ public Builder locales(List val) { - this.locales = new ArrayList<>(val); + this.locales = List.copyOf(val); return this; } - /** - * @param val readTimeout in milliseconds to read data from an - * established connection to the web service. The default is - * 20000 (20 seconds). - * @return Builder object - * @deprecated Use requestTimeout(Duration) instead - */ - @Deprecated - public Builder readTimeout(int val) { - this.requestTimeout = Duration.ofMillis(val); - return this; - } /** * @param val Request timeout duration. The default is 20 seconds. @@ -280,18 +253,6 @@ public Builder requestTimeout(Duration val) { return this; } - /** - * @param val the proxy to use when making this request. - * @return Builder object - * @deprecated Use proxy(ProxySelector) - */ - @Deprecated - public Builder proxy(Proxy val) { - if (val != null && val != Proxy.NO_PROXY) { - this.proxy = ProxySelector.of((InetSocketAddress) val.address()); - } - return this; - } /** * @param val the proxy to use when making this request. @@ -538,13 +499,6 @@ private void exhaustBody(HttpResponse response) throws HttpExceptio } } - /** - * @deprecated Closing is no longer necessary with java.net.http.HttpClient. - */ - @Deprecated - @Override - public void close() throws IOException { - } @Override public String toString() { diff --git a/src/main/java/com/maxmind/geoip2/exception/AddressNotFoundException.java b/src/main/java/com/maxmind/geoip2/exception/AddressNotFoundException.java index 40007797b..880dd7f0c 100644 --- a/src/main/java/com/maxmind/geoip2/exception/AddressNotFoundException.java +++ b/src/main/java/com/maxmind/geoip2/exception/AddressNotFoundException.java @@ -6,7 +6,6 @@ */ public final class AddressNotFoundException extends GeoIp2Exception { - private static final long serialVersionUID = -639962574626980783L; /** * @param message A message explaining the cause of the error. diff --git a/src/main/java/com/maxmind/geoip2/exception/AuthenticationException.java b/src/main/java/com/maxmind/geoip2/exception/AuthenticationException.java index f5ecba095..2dcb0899d 100644 --- a/src/main/java/com/maxmind/geoip2/exception/AuthenticationException.java +++ b/src/main/java/com/maxmind/geoip2/exception/AuthenticationException.java @@ -5,7 +5,6 @@ */ public final class AuthenticationException extends GeoIp2Exception { - private static final long serialVersionUID = 2255398691576141427L; /** * @param message A message explaining the cause of the error. diff --git a/src/main/java/com/maxmind/geoip2/exception/GeoIp2Exception.java b/src/main/java/com/maxmind/geoip2/exception/GeoIp2Exception.java index 07019c346..967cd034a 100644 --- a/src/main/java/com/maxmind/geoip2/exception/GeoIp2Exception.java +++ b/src/main/java/com/maxmind/geoip2/exception/GeoIp2Exception.java @@ -6,7 +6,6 @@ */ public class GeoIp2Exception extends Exception { - private static final long serialVersionUID = -1923104535309628719L; /** * @param message A message describing the reason why the exception was thrown. diff --git a/src/main/java/com/maxmind/geoip2/exception/HttpException.java b/src/main/java/com/maxmind/geoip2/exception/HttpException.java index 5a3faaa71..a73d8f9dc 100644 --- a/src/main/java/com/maxmind/geoip2/exception/HttpException.java +++ b/src/main/java/com/maxmind/geoip2/exception/HttpException.java @@ -1,9 +1,7 @@ package com.maxmind.geoip2.exception; import java.io.IOException; -import java.net.MalformedURLException; import java.net.URI; -import java.net.URL; /** * This class represents an HTTP transport error. This is not an error returned @@ -11,7 +9,6 @@ * GeoIp2Exception. */ public final class HttpException extends IOException { - private static final long serialVersionUID = -8301101841509056974L; private final int httpStatus; private final URI uri; @@ -53,17 +50,5 @@ public URI getUri() { return this.uri; } - /** - * @return the URL queried. - * @deprecated Use getUri() instead - */ - @Deprecated - public URL getUrl() { - try { - return this.uri.toURL(); - } catch (MalformedURLException e) { - return null; - } - } } diff --git a/src/main/java/com/maxmind/geoip2/exception/InvalidRequestException.java b/src/main/java/com/maxmind/geoip2/exception/InvalidRequestException.java index e33e1cc18..58c845d7f 100644 --- a/src/main/java/com/maxmind/geoip2/exception/InvalidRequestException.java +++ b/src/main/java/com/maxmind/geoip2/exception/InvalidRequestException.java @@ -1,8 +1,6 @@ package com.maxmind.geoip2.exception; -import java.net.MalformedURLException; import java.net.URI; -import java.net.URL; /** * This class represents a non-specific error returned by MaxMind's GeoIP2 web @@ -10,7 +8,6 @@ * but the request sent was invalid in some way. */ public final class InvalidRequestException extends GeoIp2Exception { - private static final long serialVersionUID = 8662062420258379643L; private final String code; private final URI uri; @@ -53,16 +50,4 @@ public URI getUri() { return this.uri; } - /** - * @return the URL queried. - * @deprecated Use getUri() instead - */ - @Deprecated - public URL getUrl() { - try { - return this.uri.toURL(); - } catch (MalformedURLException e) { - return null; - } - } } diff --git a/src/main/java/com/maxmind/geoip2/exception/OutOfQueriesException.java b/src/main/java/com/maxmind/geoip2/exception/OutOfQueriesException.java index 8b6c0d54f..4acf9d937 100644 --- a/src/main/java/com/maxmind/geoip2/exception/OutOfQueriesException.java +++ b/src/main/java/com/maxmind/geoip2/exception/OutOfQueriesException.java @@ -5,7 +5,6 @@ * remaining for the called service. */ public final class OutOfQueriesException extends GeoIp2Exception { - private static final long serialVersionUID = 3843736987256336967L; /** * @param message A message explaining the cause of the error. diff --git a/src/main/java/com/maxmind/geoip2/model/ConnectionTypeResponse.java b/src/main/java/com/maxmind/geoip2/model/ConnectionTypeResponse.java index cdce0418a..58b65fe77 100644 --- a/src/main/java/com/maxmind/geoip2/model/ConnectionTypeResponse.java +++ b/src/main/java/com/maxmind/geoip2/model/ConnectionTypeResponse.java @@ -55,20 +55,14 @@ public static ConnectionType fromString(String s) { return null; } - switch (s) { - case "Dialup": - return ConnectionType.DIALUP; - case "Cable/DSL": - return ConnectionType.CABLE_DSL; - case "Corporate": - return ConnectionType.CORPORATE; - case "Cellular": - return ConnectionType.CELLULAR; - case "Satellite": - return ConnectionType.SATELLITE; - default: - return null; - } + return switch (s) { + case "Dialup" -> ConnectionType.DIALUP; + case "Cable/DSL" -> ConnectionType.CABLE_DSL; + case "Corporate" -> ConnectionType.CORPORATE; + case "Cellular" -> ConnectionType.CELLULAR; + case "Satellite" -> ConnectionType.SATELLITE; + default -> null; + }; } } diff --git a/src/main/java/com/maxmind/geoip2/model/IpRiskResponse.java b/src/main/java/com/maxmind/geoip2/model/IpRiskResponse.java index 07428baf3..f48a2bb4e 100644 --- a/src/main/java/com/maxmind/geoip2/model/IpRiskResponse.java +++ b/src/main/java/com/maxmind/geoip2/model/IpRiskResponse.java @@ -11,9 +11,7 @@ /** * This class provides the GeoIP2 IP Risk model. * - * @deprecated This database has been discontinued. */ -@Deprecated public class IpRiskResponse extends IpBaseResponse { private final double ipRisk; diff --git a/src/main/java/com/maxmind/geoip2/record/Location.java b/src/main/java/com/maxmind/geoip2/record/Location.java index b457ad138..a1be28a28 100644 --- a/src/main/java/com/maxmind/geoip2/record/Location.java +++ b/src/main/java/com/maxmind/geoip2/record/Location.java @@ -15,7 +15,6 @@ public class Location extends AbstractRecord { private final Integer averageIncome; private final Double latitude; private final Double longitude; - private final Integer metroCode; private final Integer populationDensity; private final String timeZone; @@ -23,7 +22,7 @@ public class Location extends AbstractRecord { * Constructs a {@code Location} record with {@code null} values for all the fields. */ public Location() { - this(null, null, null, null, null, null, null); + this(null, null, null, null, null, null); } /** @@ -43,10 +42,6 @@ public Location() { * @param longitude The approximate longitude of the location associated * with the IP address. This value is not precise and should not be used * to identify a particular address or household. - * @param metroCode The metro code of the location if the location is in - * the US. MaxMind returns the same metro codes as the Google AdWords API. * @param populationDensity The estimated population per square kilometer * associated with the IP address. This attribute is only available from * the Insights web service. @@ -62,7 +57,6 @@ public Location( Integer averageIncome, @JsonProperty("latitude") @MaxMindDbParameter(name = "latitude") Double latitude, @JsonProperty("longitude") @MaxMindDbParameter(name = "longitude") Double longitude, - @JsonProperty("metro_code") @MaxMindDbParameter(name = "metro_code") Integer metroCode, @JsonProperty("population_density") @MaxMindDbParameter(name = "population_density") Integer populationDensity, @JsonProperty("time_zone") @MaxMindDbParameter(name = "time_zone") String timeZone @@ -71,7 +65,6 @@ public Location( this.averageIncome = averageIncome; this.latitude = latitude; this.longitude = longitude; - this.metroCode = metroCode; this.populationDensity = populationDensity; this.timeZone = timeZone; } @@ -118,16 +111,6 @@ public Integer getAccuracyRadius() { return this.accuracyRadius; } - /** - * @return The metro code is a no-longer-maintained code for targeting - * advertisements in Google. - * @deprecated Code values are no longer maintained. - */ - @JsonProperty("metro_code") - @Deprecated - public Integer getMetroCode() { - return this.metroCode; - } /** * @return The approximate latitude of the location associated with the diff --git a/src/main/java/com/maxmind/geoip2/record/Traits.java b/src/main/java/com/maxmind/geoip2/record/Traits.java index 39a995e43..2b816cd84 100644 --- a/src/main/java/com/maxmind/geoip2/record/Traits.java +++ b/src/main/java/com/maxmind/geoip2/record/Traits.java @@ -22,14 +22,12 @@ public final class Traits extends AbstractRecord { private final String domain; private final String ipAddress; private final boolean isAnonymous; - private final boolean isAnonymousProxy; private final boolean isAnonymousVpn; private final boolean isAnycast; private final boolean isHostingProvider; private final boolean isLegitimateProxy; private final boolean isPublicProxy; private final boolean isResidentialProxy; - private final boolean isSatelliteProvider; private final boolean isTorExitNode; private final String isp; private final String mobileCountryCode; @@ -45,8 +43,8 @@ public final class Traits extends AbstractRecord { */ public Traits() { this(null, null, null, null, - null, false, false, false, false, false, - false, false, false, false, false, null, + null, false, false, false, false, + false, false, false, false, null, null, null, null, null, null, null, null); } @@ -58,8 +56,8 @@ public Traits() { */ public Traits(String ipAddress, Network network) { this(null, null, null, null, - ipAddress, false, false, false, false, false, - false, false, false, false, false, null, + ipAddress, false, false, false, false, + false, false, false, false, null, null, null, network, null, null, null, null); } @@ -72,14 +70,12 @@ public Traits(String ipAddress, Network network) { * @param domain the domain * @param ipAddress the IP address * @param isAnonymous the anonymous flag - * @param isAnonymousProxy the anonymous proxy flag * @param isAnonymousVpn the anonymous VPN flag * @param isAnycast the anycast flag * @param isHostingProvider the hosting provider flag * @param isLegitimateProxy the legitimate proxy flag * @param isPublicProxy the public proxy flag * @param isResidentialProxy the residential proxy flag - * @param isSatelliteProvider the satellite provider flag * @param isTorExitNode the Tor exit node flag * @param isp the ISP * @param mobileCountryCode the mobile country code @@ -97,14 +93,12 @@ public Traits( @JsonProperty("domain") String domain, @JacksonInject("ip_address") @JsonProperty("ip_address") String ipAddress, @JsonProperty("is_anonymous") boolean isAnonymous, - @JsonProperty("is_anonymous_proxy") boolean isAnonymousProxy, @JsonProperty("is_anonymous_vpn") boolean isAnonymousVpn, @JsonProperty("is_anycast") boolean isAnycast, @JsonProperty("is_hosting_provider") boolean isHostingProvider, @JsonProperty("is_legitimate_proxy") boolean isLegitimateProxy, @JsonProperty("is_public_proxy") boolean isPublicProxy, @JsonProperty("is_residential_proxy") boolean isResidentialProxy, - @JsonProperty("is_satellite_provider") boolean isSatelliteProvider, @JsonProperty("is_tor_exit_node") boolean isTorExitNode, @JsonProperty("isp") String isp, @JsonProperty("mobile_country_code") String mobileCountryCode, @@ -122,14 +116,12 @@ public Traits( this.domain = domain; this.ipAddress = ipAddress; this.isAnonymous = isAnonymous; - this.isAnonymousProxy = isAnonymousProxy; this.isAnonymousVpn = isAnonymousVpn; this.isAnycast = isAnycast; this.isHostingProvider = isHostingProvider; this.isLegitimateProxy = isLegitimateProxy; this.isPublicProxy = isPublicProxy; this.isResidentialProxy = isResidentialProxy; - this.isSatelliteProvider = isSatelliteProvider; this.isTorExitNode = isTorExitNode; this.isp = isp; this.mobileCountryCode = mobileCountryCode; @@ -150,14 +142,12 @@ public Traits( * @param domain the domain * @param ipAddress the IP address * @param isAnonymous the anonymous flag - * @param isAnonymousProxy the anonymous proxy flag * @param isAnonymousVpn the anonymous VPN flag * @param isAnycast the anycast flag * @param isHostingProvider the hosting provider flag * @param isLegitimateProxy the legitimate proxy flag * @param isPublicProxy the public proxy flag * @param isResidentialProxy the residential proxy flag - * @param isSatelliteProvider the satellite provider flag * @param isTorExitNode the Tor exit node flag * @param isp the ISP * @param mobileCountryCode the mobile country code @@ -177,14 +167,12 @@ public Traits( @MaxMindDbParameter(name = "domain") String domain, @MaxMindDbParameter(name = "ip_address") String ipAddress, @MaxMindDbParameter(name = "is_anonymous") Boolean isAnonymous, - @MaxMindDbParameter(name = "is_anonymous_proxy") Boolean isAnonymousProxy, @MaxMindDbParameter(name = "is_anonymous_vpn") Boolean isAnonymousVpn, @MaxMindDbParameter(name = "is_anycast") Boolean isAnycast, @MaxMindDbParameter(name = "is_hosting_provider") Boolean isHostingProvider, @MaxMindDbParameter(name = "is_legitimate_proxy") Boolean isLegitimateProxy, @MaxMindDbParameter(name = "is_public_proxy") Boolean isPublicProxy, @MaxMindDbParameter(name = "is_residential_proxy") Boolean isResidentialProxy, - @MaxMindDbParameter(name = "is_satellite_provider") Boolean isSatelliteProvider, @MaxMindDbParameter(name = "is_tor_exit_node") Boolean isTorExitNode, @MaxMindDbParameter(name = "isp") String isp, @MaxMindDbParameter(name = "mobile_country_code") String mobileCountryCode, @@ -201,14 +189,12 @@ public Traits( this.domain = domain; this.ipAddress = ipAddress; this.isAnonymous = isAnonymous != null ? isAnonymous : false; - this.isAnonymousProxy = isAnonymousProxy != null ? isAnonymousProxy : false; this.isAnonymousVpn = isAnonymousVpn != null ? isAnonymousVpn : false; this.isAnycast = isAnycast != null ? isAnycast : false; this.isHostingProvider = isHostingProvider != null ? isHostingProvider : false; this.isLegitimateProxy = isLegitimateProxy != null ? isLegitimateProxy : false; this.isPublicProxy = isPublicProxy != null ? isPublicProxy : false; this.isResidentialProxy = isResidentialProxy != null ? isResidentialProxy : false; - this.isSatelliteProvider = isSatelliteProvider != null ? isSatelliteProvider : false; this.isTorExitNode = isTorExitNode != null ? isTorExitNode : false; this.isp = isp; this.mobileCountryCode = mobileCountryCode; @@ -220,161 +206,7 @@ public Traits( this.staticIpScore = staticIpScore; } - /** - * @deprecated will be removed in the next major version. - * - * @param autonomousSystemNumber the autonomous system number - * @param autonomousSystemOrganization the autonomous system organization - * @param connectionType the connection type - * @param domain the domain - * @param ipAddress the IP address - * @param isAnonymous the anonymous flag - * @param isAnonymousProxy the anonymous proxy flag - * @param isAnonymousVpn the anonymous VPN flag - * @param isHostingProvider the hosting provider flag - * @param isLegitimateProxy the legitimate proxy flag - * @param isPublicProxy the public proxy flag - * @param isResidentialProxy the residential proxy flag - * @param isSatelliteProvider the satellite provider flag - * @param isTorExitNode the Tor exit node flag - * @param isp the ISP - * @param mobileCountryCode the mobile country code - * @param mobileNetworkCode the mobile network code - * @param network the network - * @param organization the organization - * @param userType the user type - * @param userCount the user count - * @param staticIpScore the static IP score - */ - @Deprecated - public Traits( - Long autonomousSystemNumber, - String autonomousSystemOrganization, - ConnectionType connectionType, - String domain, - String ipAddress, - boolean isAnonymous, - boolean isAnonymousProxy, - boolean isAnonymousVpn, - boolean isHostingProvider, - boolean isLegitimateProxy, - boolean isPublicProxy, - boolean isResidentialProxy, - boolean isSatelliteProvider, - boolean isTorExitNode, - String isp, - String mobileCountryCode, - String mobileNetworkCode, - Network network, - String organization, - String userType, - Integer userCount, - Double staticIpScore - ) { - this( - autonomousSystemNumber, - autonomousSystemOrganization, - connectionType, - domain, - ipAddress, - isAnonymous, - isAnonymousProxy, - isAnonymousVpn, - false, // isAnycast - isHostingProvider, - isLegitimateProxy, - isPublicProxy, - isResidentialProxy, - isSatelliteProvider, - isTorExitNode, - isp, - mobileCountryCode, - mobileNetworkCode, - network, - organization, - userType, - userCount, - staticIpScore - ); - } - /** - * @deprecated will be removed in the next major version. - * - * @param autonomousSystemNumber the autonomous system number - * @param autonomousSystemOrganization the autonomous system organization - * @param connectionType the connection type - * @param domain the domain - * @param ipAddress the IP address - * @param isAnonymous the anonymous flag - * @param isAnonymousProxy the anonymous proxy flag - * @param isAnonymousVpn the anonymous VPN flag - * @param isHostingProvider the hosting provider flag - * @param isLegitimateProxy the legitimate proxy flag - * @param isPublicProxy the public proxy flag - * @param isResidentialProxy the residential proxy flag - * @param isSatelliteProvider the satellite provider flag - * @param isTorExitNode the Tor exit node flag - * @param isp the ISP - * @param mobileCountryCode the mobile country code - * @param mobileNetworkCode the mobile network code - * @param network the network - * @param organization the organization - * @param userType the user type - * @param userCount the user count - * @param staticIpScore the static IP score - */ - @Deprecated - public Traits( - Long autonomousSystemNumber, - String autonomousSystemOrganization, - String connectionType, - String domain, - String ipAddress, - Boolean isAnonymous, - Boolean isAnonymousProxy, - Boolean isAnonymousVpn, - Boolean isHostingProvider, - Boolean isLegitimateProxy, - Boolean isPublicProxy, - Boolean isResidentialProxy, - Boolean isSatelliteProvider, - Boolean isTorExitNode, - String isp, - String mobileCountryCode, - String mobileNetworkCode, - Network network, - String organization, - String userType, - Integer userCount, - Double staticIpScore - ) { - this( - autonomousSystemNumber, - autonomousSystemOrganization, - connectionType, - domain, - ipAddress, - isAnonymous, - isAnonymousProxy, - isAnonymousVpn, - false, // isAnycast - isHostingProvider, - isLegitimateProxy, - isPublicProxy, - isResidentialProxy, - isSatelliteProvider, - isTorExitNode, - isp, - mobileCountryCode, - mobileNetworkCode, - network, - organization, - userType, - userCount, - staticIpScore - ); - } /** * Constructs an instance of {@code Traits}. @@ -395,14 +227,12 @@ public Traits( traits.getDomain(), ipAddress, traits.isAnonymous(), - traits.isAnonymousProxy(), traits.isAnonymousVpn(), traits.isAnycast(), traits.isHostingProvider(), traits.isLegitimateProxy(), traits.isPublicProxy(), traits.isResidentialProxy(), - traits.isSatelliteProvider(), traits.isTorExitNode(), traits.getIsp(), traits.getMobileCountryCode(), @@ -511,17 +341,6 @@ public boolean isAnonymous() { return this.isAnonymous; } - /** - * @return This is true if the IP is an anonymous proxy. - * @deprecated Use our - * GeoIP2 - * Anonymous IP database instead. - */ - @Deprecated - @JsonProperty("is_anonymous_proxy") - public boolean isAnonymousProxy() { - return this.isAnonymousProxy; - } /** * @return This is true if the IP address is registered to an anonymous @@ -584,16 +403,6 @@ public boolean isResidentialProxy() { return this.isResidentialProxy; } - /** - * @return This is true if the IP belong to a satellite Internet provider. - * @deprecated Due to increased mobile usage, we have insufficient data to - * maintain this field. - */ - @Deprecated - @JsonProperty("is_satellite_provider") - public boolean isSatelliteProvider() { - return this.isSatelliteProvider; - } /** * @return This is true if the IP address belongs to a Tor exit node. diff --git a/src/test/java/com/maxmind/geoip2/WebServiceClientTest.java b/src/test/java/com/maxmind/geoip2/WebServiceClientTest.java index 9d79a37bb..035003819 100644 --- a/src/test/java/com/maxmind/geoip2/WebServiceClientTest.java +++ b/src/test/java/com/maxmind/geoip2/WebServiceClientTest.java @@ -99,7 +99,6 @@ public void test200WithDefaultValues() throws Exception { assertNull(location.getAccuracyRadius()); assertNull(location.getLatitude()); assertNull(location.getLongitude()); - assertNull(location.getMetroCode()); assertNull(location.getTimeZone()); assertThat(location.toString(), CoreMatchers.equalTo("com.maxmind.geoip2.record.Location [ {} ]")); @@ -145,9 +144,7 @@ public void test200WithDefaultValues() throws Exception { assertNull(traits.getUserType()); assertNull(traits.getStaticIpScore()); assertNull(traits.getUserCount()); - assertFalse(traits.isAnonymousProxy()); assertFalse(traits.isAnycast()); - assertFalse(traits.isSatelliteProvider()); for (Country c : new Country[] {country, registeredCountry, representedCountry}) { diff --git a/src/test/java/com/maxmind/geoip2/model/InsightsResponseTest.java b/src/test/java/com/maxmind/geoip2/model/InsightsResponseTest.java index 95f71bdc7..34dab71e7 100644 --- a/src/test/java/com/maxmind/geoip2/model/InsightsResponseTest.java +++ b/src/test/java/com/maxmind/geoip2/model/InsightsResponseTest.java @@ -139,12 +139,10 @@ public void testTraits() { "traits.getIpAddress() does not return 1.2.3.4" ); assertTrue(traits.isAnonymous(), "traits.isAnonymous() returns true"); - assertTrue(traits.isAnonymousProxy(), "traits.isAnonymousProxy() returns true"); assertTrue(traits.isAnonymousVpn(), "traits.isAnonymousVpn() returns true"); assertTrue(traits.isHostingProvider(), "traits.isHostingProvider() returns true"); assertTrue(traits.isPublicProxy(), "traits.isPublicProxy() returns true"); assertTrue(traits.isResidentialProxy(), "traits.isResidentialProxy() returns true"); - assertTrue(traits.isSatelliteProvider(), "traits.isSatelliteProvider() returns true"); assertTrue(traits.isTorExitNode(), "traits.isTorExitNode() returns true"); assertEquals( "Comcast", @@ -207,11 +205,6 @@ public void testLocation() { 0.1, "location.getLongitude() does not return 93.2636" ); - assertEquals( - Integer.valueOf(765), - location.getMetroCode(), - "location.getMetroCode() does not return 765" - ); assertEquals( Integer.valueOf(1341), location.getPopulationDensity(), diff --git a/src/test/java/com/maxmind/geoip2/model/JsonTest.java b/src/test/java/com/maxmind/geoip2/model/JsonTest.java index 716d7fd8b..1a59fce6e 100644 --- a/src/test/java/com/maxmind/geoip2/model/JsonTest.java +++ b/src/test/java/com/maxmind/geoip2/model/JsonTest.java @@ -36,14 +36,12 @@ public void testInsightsSerialization() throws IOException { .put("isp", "Comcast") .put("ip_address", "1.2.3.4") .put("is_anonymous", true) - .put("is_anonymous_proxy", true) .put("is_anonymous_vpn", true) .put("is_anycast", true) .put("is_hosting_provider", true) .put("is_legitimate_proxy", true) .put("is_public_proxy", true) .put("is_residential_proxy", true) - .put("is_satellite_provider", true) .put("is_tor_exit_node", true) .put("network", "1.2.3.0/24") .put("organization", "Blorg") @@ -73,7 +71,6 @@ public void testInsightsSerialization() throws IOException { .put("population_density", 1341) .put("time_zone", "America/Chicago") .put("accuracy_radius", 1500) - .put("metro_code", 765) .put("latitude", 44.98) .put("longitude", 93.2636) .end() @@ -133,11 +130,9 @@ public void testCitySerialization() throws IOException { .put("iso_code", "CA") .end() .startObjectField("traits") - .put("is_anonymous_proxy", true) .put("autonomous_system_number", 1234) .put("isp", "Comcast") .put("ip_address", "1.2.3.4") - .put("is_satellite_provider", true) .put("autonomous_system_organization", "AS Organization") .put("organization", "Blorg") .put("domain", "example.com") @@ -170,7 +165,6 @@ public void testCitySerialization() throws IOException { .end() .startObjectField("location") .put("time_zone", "America/Chicago") - .put("metro_code", 765) .put("latitude", 44.98) .put("longitude", 93.2636) .end() @@ -227,9 +221,7 @@ public void testCountrySerialization() throws IOException { .put("iso_code", "CA") .end() .startObjectField("traits") - .put("is_anonymous_proxy", true) .put("ip_address", "1.2.3.4") - .put("is_satellite_provider", true) // These are here just to simplify the testing. We expect the // difference .put("is_anonymous", false) diff --git a/src/test/resources/test-data/insights0.json b/src/test/resources/test-data/insights0.json index 57fd96238..9cbe65ed9 100644 --- a/src/test/resources/test-data/insights0.json +++ b/src/test/resources/test-data/insights0.json @@ -26,7 +26,6 @@ "average_income": 24626, "latitude": 44.98, "longitude": 93.2636, - "metro_code": 765, "population_density": 1341, "time_zone": "America/Chicago" }, @@ -74,13 +73,11 @@ "ip_address": "1.2.3.4", "isp": "Comcast", "is_anonymous": true, - "is_anonymous_proxy": true, "is_anonymous_vpn": true, "is_anycast": true, "is_hosting_provider": true, "is_public_proxy": true, "is_residential_proxy": true, - "is_satellite_provider": true, "is_tor_exit_node": true, "organization": "Blorg", "static_ip_score": 1.3, diff --git a/src/test/resources/test-data/insights1.json b/src/test/resources/test-data/insights1.json index 50634d898..e4b5bf4f8 100644 --- a/src/test/resources/test-data/insights1.json +++ b/src/test/resources/test-data/insights1.json @@ -90,12 +90,10 @@ "ip_address": "1.2.3.4", "isp": "Comcast", "is_anonymous": true, - "is_anonymous_proxy": true, "is_anonymous_vpn": true, "is_anycast": true, "is_hosting_provider": true, "is_public_proxy": true, - "is_satellite_provider": true, "is_tor_exit_node": true, "organization": "Blorg", "static_ip_score": 1.3,