-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add sessions and refresh tokens
- Loading branch information
Showing
18 changed files
with
959 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/com/auth0/client/mgmt/filter/CheckpointPaginationFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.auth0.client.mgmt.filter; | ||
|
||
public class CheckpointPaginationFilter extends BaseFilter { | ||
|
||
/** | ||
* Return results inside an object that contains the total result count (true) or as a direct array of results (false, default). | ||
* | ||
* @param includeTotals whether to include or not total result count. | ||
* @return this filter instance | ||
*/ | ||
public CheckpointPaginationFilter withTotals(boolean includeTotals) { | ||
parameters.put("include_totals", includeTotals); | ||
return this; | ||
} | ||
|
||
/** | ||
* Optional ID from which to start selection (exclusive). | ||
* | ||
* @param from the ID from which to start selection. This can be obtained from the {@code next} field returned from | ||
* a checkpoint-paginated result. | ||
* @return this filter instance. | ||
*/ | ||
public CheckpointPaginationFilter withFrom(String from) { | ||
parameters.put("from", from); | ||
return this; | ||
} | ||
|
||
/** | ||
* Number of results per page. Defaults to 50. | ||
* | ||
* @param take the amount of entries to retrieve per page. | ||
* @return this filter instance. | ||
*/ | ||
public CheckpointPaginationFilter withTake(int take) { | ||
parameters.put("take", take); | ||
return this; | ||
} | ||
} |
97 changes: 97 additions & 0 deletions
97
src/main/java/com/auth0/json/mgmt/users/refreshtokens/RefreshToken.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package com.auth0.json.mgmt.users.refreshtokens; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import java.util.Date; | ||
import java.util.List; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public class RefreshToken { | ||
@JsonProperty("id") | ||
private String id; | ||
@JsonProperty("user_id") | ||
private String userId; | ||
@JsonProperty("created_at") | ||
private Date createdAt; | ||
@JsonProperty("idle_expires_at") | ||
private Date idleExpiresAt; | ||
@JsonProperty("expires_at") | ||
private Date expiresAt; | ||
@JsonProperty("client_id") | ||
private String clientId; | ||
@JsonProperty("session_id") | ||
private String sessionId; | ||
@JsonProperty("rotating") | ||
private Boolean rotating; | ||
@JsonProperty("resource_servers") | ||
private List<ResourceServer> resourceServers; | ||
|
||
/** | ||
* @return The ID of the refresh token | ||
*/ | ||
public String getId() { | ||
return id; | ||
} | ||
|
||
/** | ||
* @return ID of the user which can be used when interacting with other APIs. | ||
*/ | ||
public String getUserId() { | ||
return userId; | ||
} | ||
|
||
/** | ||
* @return The date and time when the refresh token was created | ||
*/ | ||
public Date getCreatedAt() { | ||
return createdAt; | ||
} | ||
|
||
/** | ||
* | ||
* @return The date and time when the refresh token will expire if idle | ||
*/ | ||
public Date getIdleExpiresAt() { | ||
return idleExpiresAt; | ||
} | ||
|
||
/** | ||
* | ||
* @return The date and time when the refresh token will expire | ||
*/ | ||
public Date getExpiresAt() { | ||
return expiresAt; | ||
} | ||
|
||
/** | ||
* @return ID of the client application granted with this refresh token | ||
*/ | ||
public String getClientId() { | ||
return clientId; | ||
} | ||
|
||
/** | ||
* | ||
* @return ID of the authenticated session used to obtain this refresh-token | ||
*/ | ||
public String getSessionId() { | ||
return sessionId; | ||
} | ||
|
||
/** | ||
* @return True if the token is a rotating refresh token | ||
*/ | ||
public Boolean isRotating() { | ||
return rotating; | ||
} | ||
|
||
/** | ||
* @return A list of the resource server IDs associated to this refresh-token and their granted scopes | ||
*/ | ||
public List<ResourceServer> getResourceServers() { | ||
return resourceServers; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/main/java/com/auth0/json/mgmt/users/refreshtokens/RefreshTokensPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.auth0.json.mgmt.users.refreshtokens; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* This does not extend com.auth0.json.mgmt.Page<RefreshToken> because the URL only supports "next" and "take" pagination. | ||
*/ | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public class RefreshTokensPage { | ||
@JsonProperty("total") | ||
private Integer total; | ||
|
||
@JsonProperty("next") | ||
private String next; | ||
|
||
@JsonProperty("tokens") | ||
private List<RefreshToken> tokens; | ||
|
||
/** | ||
* @return the total number of refresh tokens. This is only present when `include_totals` is passed as a query parameter. | ||
*/ | ||
public Integer getTotal() { | ||
return total; | ||
} | ||
|
||
/** | ||
* @return the token ID from which to start selection for a new page | ||
*/ | ||
public String getNext() { | ||
return next; | ||
} | ||
|
||
/** | ||
* @return the list of Tokens | ||
*/ | ||
public List<RefreshToken> getTokens() { | ||
return tokens; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/com/auth0/json/mgmt/users/refreshtokens/ResourceServer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.auth0.json.mgmt.users.refreshtokens; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import java.util.List; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public class ResourceServer { | ||
@JsonProperty("audience") | ||
private String audience; | ||
@JsonProperty("scopes") | ||
private List<String> scopes; | ||
|
||
/** | ||
* @return Resource server ID | ||
*/ | ||
public String getAudience() { | ||
return audience; | ||
} | ||
|
||
/** | ||
* @return List of scopes for the refresh token | ||
*/ | ||
public List<String> getScopes() { | ||
return scopes; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/auth0/json/mgmt/users/sessions/Authentication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.auth0.json.mgmt.users.sessions; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import java.util.List; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public class Authentication { | ||
@JsonProperty("methods") | ||
private List<AuthenticationMethod> methods; | ||
|
||
/** | ||
* @return Contains the authentication methods a user has completed during their session | ||
*/ | ||
public List<AuthenticationMethod> getMethods() { | ||
return methods; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/com/auth0/json/mgmt/users/sessions/AuthenticationMethod.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.auth0.json.mgmt.users.sessions; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import java.util.Date; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public class AuthenticationMethod { | ||
@JsonProperty("name") | ||
private String name; | ||
@JsonProperty("timestamp") | ||
private Date timestamp; | ||
@JsonProperty("type") | ||
private String type; | ||
|
||
/** | ||
* @return One of: "federated", "passkey", "pwd", "sms", "email", "mfa", "mock" or a custom method denoted by a URL | ||
*/ | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
/** | ||
* @return Timestamp of when the signal was received | ||
*/ | ||
public Date getTimestamp() { | ||
return timestamp; | ||
} | ||
|
||
/** | ||
* @return A specific MFA factor. Only present when "name" is set to "mfa" | ||
*/ | ||
public String getType() { | ||
return type; | ||
} | ||
} |
Oops, something went wrong.