Skip to content

Commit 6a78398

Browse files
committed
update version 1.0.11
1 parent e7739d6 commit 6a78398

File tree

6 files changed

+125
-7
lines changed

6 files changed

+125
-7
lines changed

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Add the following dependency in 'pom.xml' file to use the IP Geolocation API Jav
3535
<dependency>
3636
<groupId>io.ipgeolocation</groupId>
3737
<artifactId>ipgeolocation</artifactId>
38-
<version>1.0.9</version>
38+
<version>1.0.11</version>
3939
</dependency>
4040
```
4141

@@ -50,7 +50,7 @@ repositories {
5050
}
5151
5252
dependencies {
53-
compile 'io.ipgeolocation:ipgeolocation:1.0.9'
53+
compile 'io.ipgeolocation:ipgeolocation:1.0.11'
5454
...
5555
}
5656
```
@@ -60,7 +60,7 @@ dependencies {
6060
Add the following dependency code in 'ivy.xml' file to use the IP Geolocation API Java SDK.
6161

6262
```ivy
63-
<dependency org='io.ipgeolocation' name='ipgeolocation' rev='1.0.9'>
63+
<dependency org='io.ipgeolocation' name='ipgeolocation' rev='1.0.11'>
6464
<artifact name='ipgeolocation' />
6565
</dependency>
6666
```
@@ -69,7 +69,7 @@ Add the following dependency code in 'ivy.xml' file to use the IP Geolocation AP
6969

7070
Use the following URL to download the latest JAR file for IP Geolocation API Java SDK.
7171

72-
* [https://ipgeolocation.io/downloads/ip-geolocation-api-java-1.0.9.jar](https://ipgeolocation.io/downloads/ip-geolocation-api-java-1.0.9.jar)
72+
* [https://ipgeolocation.io/downloads/ip-geolocation-api-java-1.0.11.jar](https://ipgeolocation.io/downloads/ip-geolocation-api-java-1.0.11.jar)
7373

7474
Basic Usage
7575
-----------
@@ -88,14 +88,20 @@ IPGeolocationAPI api = new IPGeolocationAPI("YOUR_API_KEY");
8888
GeolocationParams geoParams = new GeolocationParams();
8989
geoParams.setIPAddress("1.1.1.1");
9090
geoParams.setFields("geo,time_zone,currency");
91-
91+
geoParams.setIncludeSecurity(true);
9292
Geolocation geolocation = api.getGeolocation(geoParams);
9393

9494
// Check if geolocation lookup was successful
9595
if(geolocation.getStatus() == 200) {
9696
System.out.println(geolocation.getCountryName());
9797
System.out.println(geolocation.getCurrency().getName());
9898
System.out.println(geolocation.getTimezone().getCurrentTime());
99+
System.out.println(geolocation.getGeolocationSecurity().getAnonymous());
100+
System.out.println(geolocation.getGeolocationSecurity().getKnownAttacker());
101+
System.out.println(geolocation.getGeolocationSecurity().getProxy());
102+
System.out.println(geolocation.getGeolocationSecurity().getProxyType());
103+
System.out.println(geolocation.getGeolocationSecurity().getAnonymous());
104+
System.out.println(geolocation.getGeolocationSecurity().getCloudProvider());
99105
} else {
100106
System.out.printf("Status Code: %d, Message: %s\n", geolocation.getStatus(), geolocation.getMessage());
101107
}

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>io.ipgeolocation</groupId>
88
<artifactId>ipgeolocation</artifactId>
9-
<version>1.0.9</version>
9+
<version>1.0.11</version>
1010

1111
<dependencies>
1212
<dependency>

src/main/java/io/ipgeolocation/api/Geolocation.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class Geolocation {
3434
private String geonameID;
3535
private GeolocationCurrency currency;
3636
private GeolocationTimezone timezone;
37+
private GeolocationSecurity geolocationSecurity;
3738

3839
Geolocation(Map<String, Object> json) {
3940
this.status = Integer.parseInt((String) json.get("status"));
@@ -76,6 +77,11 @@ public class Geolocation {
7677
Map timezoneJson = (LinkedTreeMap) json.get("time_zone");
7778
this.timezone = new GeolocationTimezone(timezoneJson);
7879
}
80+
81+
if(json.get("security") instanceof LinkedTreeMap) {
82+
Map securityJson = (LinkedTreeMap) json.get("security");
83+
this.geolocationSecurity = new GeolocationSecurity(securityJson);
84+
}
7985
}
8086
}
8187

@@ -195,10 +201,15 @@ public GeolocationTimezone getTimezone() {
195201
return timezone;
196202
}
197203

204+
public GeolocationSecurity getGeolocationSecurity() {
205+
return geolocationSecurity;
206+
}
207+
198208
@Override
199209
public String toString() {
200210
String currencyString = "";
201211
String timezoneString = "";
212+
String geolocationSecurityString = "";
202213

203214
if(currency != null) {
204215
currencyString = currency.toString();
@@ -208,6 +219,10 @@ public String toString() {
208219
timezoneString = timezone.toString();
209220
}
210221

211-
return String.format("domain: '%s' \nip: '%s' \nhostname: '%s' \ncontinent_code: '%s' \ncontinent_name: '%s' \ncountry_code2: '%s' \ncountry_code3: '%s' \ncountry_name: '%s' \ncountry_capital: '%s \nstate_prov: '%s' \ndistrict: '%s' \ncity: '%s' \nzipcode: '%s' \nlatitude: '%s' \nlongitude: '%s' \nis_eu: '%s' \ncalling_code: '%s' \ncountry_tld: '%s' \nlanguages: '%s' \ncountry_flag: '%s' \nisp: '%s' \nconnection_type: '%s' \norganization: '%s' \ngeoname_id: '%s'\nasn: '%s' \ncurrency: {\n%s\n} \ntime_zone: {\n%s\n}\n", domain, ip, hostname, continentCode, continentName, countryCode2, countryCode3, countryName, countryCapital, stateProvince, district, city, zipCode, latitude, longitude, isEU, callingCode, countryTLD, languages, countryFlag, isp, connectionType, organization, geonameID, asn, currencyString, timezoneString);
222+
if(geolocationSecurity != null){
223+
geolocationSecurityString = geolocationSecurity.toString();
224+
}
225+
226+
return String.format("domain: '%s' \nip: '%s' \nhostname: '%s' \ncontinent_code: '%s' \ncontinent_name: '%s' \ncountry_code2: '%s' \ncountry_code3: '%s' \ncountry_name: '%s' \ncountry_capital: '%s \nstate_prov: '%s' \ndistrict: '%s' \ncity: '%s' \nzipcode: '%s' \nlatitude: '%s' \nlongitude: '%s' \nis_eu: '%s' \ncalling_code: '%s' \ncountry_tld: '%s' \nlanguages: '%s' \ncountry_flag: '%s' \nisp: '%s' \nconnection_type: '%s' \norganization: '%s' \ngeoname_id: '%s'\nasn: '%s' \ncurrency: {\n%s\n} \ntime_zone: {\n%s\n} \nsecurity: {\n%s\n}\n", domain, ip, hostname, continentCode, continentName, countryCode2, countryCode3, countryName, countryCapital, stateProvince, district, city, zipCode, latitude, longitude, isEU, callingCode, countryTLD, languages, countryFlag, isp, connectionType, organization, geonameID, asn, currencyString, timezoneString, geolocationSecurityString);
212227
}
213228
}

src/main/java/io/ipgeolocation/api/GeolocationParams.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ public class GeolocationParams {
77
private String fields;
88
private String lang;
99
private boolean includeHostname;
10+
private boolean includeSecurity;
1011
private String[] ips;
1112

1213
public GeolocationParams() {
1314
this.ip = "";
1415
this.fields = "";
1516
this.lang = "en";
1617
this.includeHostname = false;
18+
this.includeSecurity = false;
1719
this.ips = new String[0];
1820
}
1921

@@ -49,6 +51,14 @@ public boolean isIncludeHostname() {
4951
return includeHostname;
5052
}
5153

54+
public boolean isIncludeSecurity() {
55+
return includeSecurity;
56+
}
57+
58+
public void setIncludeSecurity(boolean includeSecurity) {
59+
this.includeSecurity = includeSecurity;
60+
}
61+
5262
public void setIPAddresses(String[] ips) throws IllegalArgumentException {
5363
if(ips.length > 50) {
5464
throw new IllegalArgumentException("Max. number of IP addresses cannot be more than 50.");
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
package io.ipgeolocation.api;
2+
3+
import java.util.Map;
4+
5+
public class GeolocationSecurity {
6+
private Double threatScore;
7+
private Boolean isTor;
8+
private Boolean isProxy;
9+
private String proxyType;
10+
private Boolean isAnonymous;
11+
private Boolean isKnownAttacker;
12+
private Boolean isCloudProvider;
13+
14+
GeolocationSecurity(Map json){
15+
this.threatScore = (Double) json.get("threat_score");
16+
this.isTor = (Boolean) json.get("is_tor");
17+
this.isProxy = (Boolean) json.get("is_proxy");
18+
this.proxyType = (String) json.get("proxy_type");
19+
this.isAnonymous = (Boolean) json.get("is_anonymous");
20+
this.isKnownAttacker = (Boolean) json.get("is_known_attacker");
21+
this.isCloudProvider = (Boolean) json.get("is_cloud_provider");
22+
}
23+
24+
public Double getThreatScore() {
25+
return threatScore;
26+
}
27+
28+
public void setThreatScore(Double threatScore) {
29+
this.threatScore = threatScore;
30+
}
31+
32+
public Boolean getTor() {
33+
return isTor;
34+
}
35+
36+
public void setTor(Boolean tor) {
37+
isTor = tor;
38+
}
39+
40+
public Boolean getProxy() {
41+
return isProxy;
42+
}
43+
44+
public void setProxy(Boolean proxy) {
45+
isProxy = proxy;
46+
}
47+
48+
public String getProxyType() {
49+
return proxyType;
50+
}
51+
52+
public void setProxyType(String proxyType) {
53+
this.proxyType = proxyType;
54+
}
55+
56+
public Boolean getAnonymous() {
57+
return isAnonymous;
58+
}
59+
60+
public void setAnonymous(Boolean anonymous) {
61+
isAnonymous = anonymous;
62+
}
63+
64+
public Boolean getKnownAttacker() {
65+
return isKnownAttacker;
66+
}
67+
68+
public void setKnownAttacker(Boolean knownAttacker) {
69+
isKnownAttacker = knownAttacker;
70+
}
71+
72+
public Boolean getCloudProvider() {
73+
return isCloudProvider;
74+
}
75+
76+
public void setCloudProvider(Boolean cloudProvider) {
77+
isCloudProvider = cloudProvider;
78+
}
79+
}

src/main/java/io/ipgeolocation/api/IPGeolocationAPI.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ private String buildGeolocationUrlParams(GeolocationParams params) {
5959
urlParams.append("&include=hostname");
6060
}
6161

62+
if(params.isIncludeSecurity()) {
63+
if(params.isIncludeHostname()){
64+
urlParams.append(",security");
65+
}else{
66+
urlParams.append("&include=security");
67+
}
68+
}
69+
6270
if(!isNullOrEmpty(params.getLang())) {
6371
urlParams.append("&lang=");
6472
urlParams.append(params.getLang());

0 commit comments

Comments
 (0)