|
| 1 | +package com.maxmind.geoip2.model; |
| 2 | + |
| 3 | +import com.fasterxml.jackson.annotation.JacksonInject; |
| 4 | +import com.fasterxml.jackson.annotation.JsonProperty; |
| 5 | +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; |
| 6 | +import com.maxmind.db.MaxMindDbConstructor; |
| 7 | +import com.maxmind.db.MaxMindDbParameter; |
| 8 | +import com.maxmind.db.Network; |
| 9 | +import com.maxmind.geoip2.NetworkDeserializer; |
| 10 | +import java.time.LocalDate; |
| 11 | + |
| 12 | +/** |
| 13 | + * This class provides the GeoIP Anonymous Plus model. |
| 14 | + */ |
| 15 | +public class AnonymousPlusResponse extends AnonymousIpResponse { |
| 16 | + private final Integer anonymizerConfidence; |
| 17 | + private final LocalDate networkLastSeen; |
| 18 | + private final String providerName; |
| 19 | + |
| 20 | + /** |
| 21 | + * Constructs an instance of {@code AnonymousPlusResponse} with the specified values. |
| 22 | + * |
| 23 | + * @param anonymizerConfidence confidence that the network is a VPN. |
| 24 | + * @param ipAddress the IP address being checked |
| 25 | + * @param isAnonymous whether the IP address belongs to any sort of anonymous network |
| 26 | + * @param isAnonymousVpn whether the IP address belongs to an anonymous VPN system |
| 27 | + * @param isHostingProvider whether the IP address belongs to a hosting provider |
| 28 | + * @param isPublicProxy whether the IP address belongs to a public proxy system |
| 29 | + * @param isResidentialProxy whether the IP address belongs to a residential proxy system |
| 30 | + * @param isTorExitNode whether the IP address is a Tor exit node |
| 31 | + * @param network the network associated with the record |
| 32 | + * @param networkLastSeen the last sighting of the network. |
| 33 | + * @param providerName the name of the VPN provider. |
| 34 | + */ |
| 35 | + public AnonymousPlusResponse( |
| 36 | + @JsonProperty("anonymizer_confidence") Integer anonymizerConfidence, |
| 37 | + @JacksonInject("ip_address") @JsonProperty("ip_address") String ipAddress, |
| 38 | + @JsonProperty("is_anonymous") Boolean isAnonymous, |
| 39 | + @JsonProperty("is_anonymous_vpn") Boolean isAnonymousVpn, |
| 40 | + @JsonProperty("is_hosting_provider") Boolean isHostingProvider, |
| 41 | + @JsonProperty("is_public_proxy") Boolean isPublicProxy, |
| 42 | + @JsonProperty("is_residential_proxy") Boolean isResidentialProxy, |
| 43 | + @JsonProperty("is_tor_exit_node") Boolean isTorExitNode, |
| 44 | + @JacksonInject("network") @JsonDeserialize(using = NetworkDeserializer.class) |
| 45 | + @JsonProperty("network") Network network, |
| 46 | + @JsonProperty("network_last_seen") LocalDate networkLastSeen, |
| 47 | + @JsonProperty("provider_name") String providerName |
| 48 | + ) { |
| 49 | + super(ipAddress, isAnonymous, isAnonymousVpn, isHostingProvider, isPublicProxy, |
| 50 | + isResidentialProxy, isTorExitNode, network); |
| 51 | + |
| 52 | + this.anonymizerConfidence = anonymizerConfidence; |
| 53 | + this.networkLastSeen = networkLastSeen; |
| 54 | + this.providerName = providerName; |
| 55 | + } |
| 56 | + |
| 57 | + /** |
| 58 | + * Constructs an instance of {@code AnonymousPlusResponse} with the specified values. |
| 59 | + * |
| 60 | + * @param anonymizerConfidence confidence that the network is a VPN. |
| 61 | + * @param ipAddress the IP address being checked |
| 62 | + * @param isAnonymous whether the IP address belongs to any sort of anonymous network |
| 63 | + * @param isAnonymousVpn whether the IP address belongs to an anonymous VPN system |
| 64 | + * @param isHostingProvider whether the IP address belongs to a hosting provider |
| 65 | + * @param isPublicProxy whether the IP address belongs to a public proxy system |
| 66 | + * @param isResidentialProxy whether the IP address belongs to a residential proxy system |
| 67 | + * @param isTorExitNode whether the IP address is a Tor exit node |
| 68 | + * @param network the network associated with the record |
| 69 | + * @param networkLastSeen the last sighting of the network. |
| 70 | + * @param providerName the name of the VPN provider. |
| 71 | + */ |
| 72 | + @MaxMindDbConstructor |
| 73 | + public AnonymousPlusResponse( |
| 74 | + @MaxMindDbParameter(name = "anonymizer_confidence") Integer anonymizerConfidence, |
| 75 | + @MaxMindDbParameter(name = "ip_address") String ipAddress, |
| 76 | + @MaxMindDbParameter(name = "is_anonymous") Boolean isAnonymous, |
| 77 | + @MaxMindDbParameter(name = "is_anonymous_vpn") Boolean isAnonymousVpn, |
| 78 | + @MaxMindDbParameter(name = "is_hosting_provider") Boolean isHostingProvider, |
| 79 | + @MaxMindDbParameter(name = "is_public_proxy") Boolean isPublicProxy, |
| 80 | + @MaxMindDbParameter(name = "is_residential_proxy") Boolean isResidentialProxy, |
| 81 | + @MaxMindDbParameter(name = "is_tor_exit_node") Boolean isTorExitNode, |
| 82 | + @MaxMindDbParameter(name = "network") Network network, |
| 83 | + @MaxMindDbParameter(name = "network_last_seen") String networkLastSeen, |
| 84 | + @MaxMindDbParameter(name = "provider_name") String providerName |
| 85 | + ) { |
| 86 | + this(anonymizerConfidence, ipAddress, isAnonymous, isAnonymousVpn, |
| 87 | + isHostingProvider, isPublicProxy, isResidentialProxy, isTorExitNode, network, |
| 88 | + networkLastSeen != null ? LocalDate.parse(networkLastSeen) : null, |
| 89 | + providerName); |
| 90 | + } |
| 91 | + |
| 92 | + /** |
| 93 | + * Constructs an instance of {@code AnonymousPlusResponse} from the values in the |
| 94 | + * response and the specified IP address and network. |
| 95 | + * |
| 96 | + * @param response the response to copy |
| 97 | + * @param ipAddress the IP address being checked |
| 98 | + * @param network the network associated with the record |
| 99 | + */ |
| 100 | + public AnonymousPlusResponse( |
| 101 | + AnonymousPlusResponse response, |
| 102 | + String ipAddress, |
| 103 | + Network network |
| 104 | + ) { |
| 105 | + this( |
| 106 | + response.getAnonymizerConfidence(), |
| 107 | + ipAddress, |
| 108 | + response.isAnonymous(), |
| 109 | + response.isAnonymousVpn(), |
| 110 | + response.isHostingProvider(), |
| 111 | + response.isPublicProxy(), |
| 112 | + response.isResidentialProxy(), |
| 113 | + response.isTorExitNode(), |
| 114 | + network, |
| 115 | + response.getNetworkLastSeen(), |
| 116 | + response.getProviderName() |
| 117 | + ); |
| 118 | + } |
| 119 | + |
| 120 | + /** |
| 121 | + * @return A score ranging from 1 to 99 that is our percent confidence that the network is |
| 122 | + * currently part of an actively used VPN service. |
| 123 | + */ |
| 124 | + @JsonProperty |
| 125 | + public Integer getAnonymizerConfidence() { |
| 126 | + return anonymizerConfidence; |
| 127 | + } |
| 128 | + |
| 129 | + /** |
| 130 | + * @return The last day that the network was sighted in our analysis of anonymized networks. |
| 131 | + */ |
| 132 | + @JsonProperty |
| 133 | + public LocalDate getNetworkLastSeen() { |
| 134 | + return networkLastSeen; |
| 135 | + } |
| 136 | + |
| 137 | + /** |
| 138 | + * @return The name of the VPN provider (e.g., NordVPN, SurfShark, etc.) associated with the |
| 139 | + * network. |
| 140 | + */ |
| 141 | + @JsonProperty |
| 142 | + public String getProviderName() { |
| 143 | + return providerName; |
| 144 | + } |
| 145 | +} |
0 commit comments