Skip to content

Commit a0b5c6b

Browse files
committed
Added few fields in RefreshToken and Session and modified minor changes
1 parent e03801f commit a0b5c6b

8 files changed

Lines changed: 104 additions & 10 deletions

File tree

src/main/java/com/auth0/client/mgmt/UsersEntity.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -798,8 +798,8 @@ public Request<AuthenticationMethod> updateAuthenticationMethodById(String userI
798798
* @param filter an optional pagination filter
799799
* @return a Request to execute
800800
*/
801-
public Request<RefreshTokensPage> listRefreshTokens(String userId, CheckpointPaginationFilter filter) {
802-
Asserts.assertNotNull(userId, "user id");
801+
public Request<RefreshTokensPage> listRefreshTokens(String userId, PageFilter filter) {
802+
Asserts.assertNotNull(userId, "user ID");
803803
HttpUrl.Builder builder = baseUrl
804804
.newBuilder()
805805
.addPathSegments("api/v2/users")
@@ -847,8 +847,8 @@ public Request<Void> deleteRefreshTokens(String userId) {
847847
* @param filter an optional pagination filter
848848
* @return a Request to execute
849849
*/
850-
public Request<SessionsPage> listSessions(String userId, CheckpointPaginationFilter filter) {
851-
Asserts.assertNotNull(userId, "user id");
850+
public Request<SessionsPage> listSessions(String userId, PageFilter filter) {
851+
Asserts.assertNotNull(userId, "user ID");
852852
HttpUrl.Builder builder = baseUrl
853853
.newBuilder()
854854
.addPathSegments("api/v2/users")
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package com.auth0.json.mgmt.users.refreshtokens;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import com.fasterxml.jackson.annotation.JsonInclude;
5+
import com.fasterxml.jackson.annotation.JsonProperty;
6+
7+
@JsonIgnoreProperties(ignoreUnknown = true)
8+
@JsonInclude(JsonInclude.Include.NON_NULL)
9+
public class Device {
10+
@JsonProperty("initial_ip")
11+
private String initialIp;
12+
@JsonProperty("initial_asn")
13+
private String initialAsn;
14+
@JsonProperty("initial_user_agent")
15+
private String initialUserAgent;
16+
@JsonProperty("last_ip")
17+
private String lastIp;
18+
@JsonProperty("last_asn")
19+
private String lastAsn;
20+
@JsonProperty("last_user_agent")
21+
private String lastUserAgent;
22+
23+
/**
24+
* @return First IP address associated with this session
25+
*/
26+
public String getInitialIp() {
27+
return initialIp;
28+
}
29+
30+
/**
31+
* @return First autonomous system number associated with this session
32+
*/
33+
public String getInitialAsn() {
34+
return initialAsn;
35+
}
36+
37+
/**
38+
* @return First user agent associated with this session
39+
*/
40+
public String getInitialUserAgent() {
41+
return initialUserAgent;
42+
}
43+
44+
/**
45+
* @return Last IP address from which this user logged in
46+
*/
47+
public String getLastIp() {
48+
return lastIp;
49+
}
50+
51+
/**
52+
* @return Last autonomous system number from which this user logged in
53+
*/
54+
public String getLastAsn() {
55+
return lastAsn;
56+
}
57+
58+
/**
59+
* @return Last user agent of the device from which this user logged in
60+
*/
61+
public String getLastUserAgent() {
62+
return lastUserAgent;
63+
}
64+
}

src/main/java/com/auth0/json/mgmt/users/refreshtokens/RefreshToken.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public class RefreshToken {
2020
private Date idleExpiresAt;
2121
@JsonProperty("expires_at")
2222
private Date expiresAt;
23+
@JsonProperty("device")
24+
private Device device;
2325
@JsonProperty("client_id")
2426
private String clientId;
2527
@JsonProperty("session_id")
@@ -28,6 +30,8 @@ public class RefreshToken {
2830
private Boolean rotating;
2931
@JsonProperty("resource_servers")
3032
private List<ResourceServer> resourceServers;
33+
@JsonProperty("last_exchanged_at")
34+
private Date lastExchangedAt;
3135

3236
/**
3337
* @return The ID of the refresh token
@@ -66,6 +70,13 @@ public Date getExpiresAt() {
6670
return expiresAt;
6771
}
6872

73+
/**
74+
* @return Device information
75+
*/
76+
public Device getDevice() {
77+
return device;
78+
}
79+
6980
/**
7081
* @return ID of the client application granted with this refresh token
7182
*/
@@ -94,4 +105,11 @@ public Boolean isRotating() {
94105
public List<ResourceServer> getResourceServers() {
95106
return resourceServers;
96107
}
108+
109+
/**
110+
* @return The date and time when the refresh token was last exchanged
111+
*/
112+
public Date getLastExchangedAt() {
113+
return lastExchangedAt;
114+
}
97115
}

src/main/java/com/auth0/json/mgmt/users/refreshtokens/RefreshTokensPage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import java.util.List;
88

99
/**
10-
* This does not extend com.auth0.json.mgmt.Page<RefreshToken> because the URL only supports "next" and "take" pagination.
10+
* Class that represents a page of Refresh Tokens.
1111
*/
1212
@JsonIgnoreProperties(ignoreUnknown = true)
1313
@JsonInclude(JsonInclude.Include.NON_NULL)

src/main/java/com/auth0/json/mgmt/users/sessions/Device.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
@JsonIgnoreProperties(ignoreUnknown = true)
88
@JsonInclude(JsonInclude.Include.NON_NULL)
99
public class Device {
10+
@JsonProperty("initial_user_agent")
11+
private String initialUserAgent;
1012
@JsonProperty("initial_ip")
1113
private String initialIP;
1214
@JsonProperty("initial_asn")
@@ -18,6 +20,13 @@ public class Device {
1820
@JsonProperty("last_asn")
1921
private String lastASN;
2022

23+
/**
24+
* @return First user agent associated with this session
25+
*/
26+
public String getInitialUserAgent() {
27+
return initialUserAgent;
28+
}
29+
2130
/**
2231
* @return First IP address associated with this session
2332
*/

src/main/java/com/auth0/json/mgmt/users/sessions/Session.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ public class Session {
2424
private Date idleExpiresAt;
2525
@JsonProperty("expires_at")
2626
private Date expiresAt;
27+
@JsonProperty("last_interacted_at")
28+
private Date lastInteractedAt;
2729
@JsonProperty("device")
2830
private Device device;
2931
@JsonProperty("clients")

src/main/java/com/auth0/json/mgmt/users/sessions/SessionsPage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import java.util.List;
88

99
/**
10-
* This does not extend com.auth0.json.mgmt.Page<RefreshToken> because the URL only supports "next" and "take" pagination.
10+
* Class that represents a given Page of Sessions. Related to the {@link com.auth0.client.mgmt.UsersEntity} entity.
1111
*/
1212
@JsonIgnoreProperties(ignoreUnknown = true)
1313
@JsonInclude(JsonInclude.Include.NON_NULL)

src/test/java/com/auth0/client/mgmt/UsersEntityTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.auth0.client.mgmt.filter.PageFilter;
66
import com.auth0.client.mgmt.filter.UserFilter;
77
import com.auth0.client.mgmt.filter.CheckpointPaginationFilter;
8+
import com.auth0.json.mgmt.Page;
89
import com.auth0.json.mgmt.guardian.Enrollment;
910
import com.auth0.json.mgmt.logevents.LogEvent;
1011
import com.auth0.json.mgmt.logevents.LogEventsPage;
@@ -1371,7 +1372,7 @@ public void shouldListRefreshTokensWithoutFilter() throws Exception {
13711372

13721373
@Test
13731374
public void shouldListRefreshTokensWithPage() throws Exception {
1374-
CheckpointPaginationFilter filter = new CheckpointPaginationFilter().withFrom("tokenId2").withTake(5);
1375+
PageFilter filter = new PageFilter().withFrom("tokenId2").withTake(5);
13751376
Request<RefreshTokensPage> request = api.users().listRefreshTokens("1", filter);
13761377
assertThat(request, is(notNullValue()));
13771378

@@ -1391,7 +1392,7 @@ public void shouldListRefreshTokensWithPage() throws Exception {
13911392

13921393
@Test
13931394
public void shouldListRefreshTokensWithTotal() throws Exception {
1394-
CheckpointPaginationFilter filter = new CheckpointPaginationFilter().withTotals(true);
1395+
PageFilter filter = new PageFilter().withTotals(true);
13951396
Request<RefreshTokensPage> request = api.users().listRefreshTokens("1", filter);
13961397
assertThat(request, is(notNullValue()));
13971398

@@ -1448,7 +1449,7 @@ public void shouldListSessionsWithoutFilter() throws Exception {
14481449

14491450
@Test
14501451
public void shouldListSessionsWithPage() throws Exception {
1451-
CheckpointPaginationFilter filter = new CheckpointPaginationFilter().withFrom("sessionId3").withTake(9);
1452+
PageFilter filter = new PageFilter().withFrom("sessionId3").withTake(9);
14521453
Request<SessionsPage> request = api.users().listSessions("1", filter);
14531454
assertThat(request, is(notNullValue()));
14541455

@@ -1468,7 +1469,7 @@ public void shouldListSessionsWithPage() throws Exception {
14681469

14691470
@Test
14701471
public void shouldListSessionsWithTotal() throws Exception {
1471-
CheckpointPaginationFilter filter = new CheckpointPaginationFilter().withTotals(true);
1472+
PageFilter filter = new PageFilter().withTotals(true);
14721473
Request<SessionsPage> request = api.users().listSessions("1", filter);
14731474
assertThat(request, is(notNullValue()));
14741475

0 commit comments

Comments
 (0)