-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resource server #77
Merged
Merged
Resource server #77
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
137 changes: 137 additions & 0 deletions
137
src/main/java/com/auth0/client/mgmt/ResourceServerEntity.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,137 @@ | ||
package com.auth0.client.mgmt; | ||
|
||
import java.util.List; | ||
|
||
import com.auth0.json.mgmt.ResourceServer; | ||
import com.auth0.net.CustomRequest; | ||
import com.auth0.net.Request; | ||
import com.auth0.net.VoidRequest; | ||
import com.auth0.utils.Asserts; | ||
import com.fasterxml.jackson.core.type.TypeReference; | ||
import okhttp3.HttpUrl; | ||
import okhttp3.OkHttpClient; | ||
|
||
public class ResourceServerEntity { | ||
private OkHttpClient client; | ||
private HttpUrl baseUrl; | ||
private String apiToken; | ||
|
||
ResourceServerEntity(OkHttpClient client, HttpUrl baseUrl, String apiToken) { | ||
this.client = client; | ||
this.baseUrl = baseUrl; | ||
this.apiToken = apiToken; | ||
} | ||
|
||
/** | ||
* Creates request to fetch all resource servers. | ||
* See <a href=https://auth0.com/docs/api/management/v2#!/Resource_Servers/get_resource_servers>API documentation</a> | ||
* | ||
* @return request to execute | ||
*/ | ||
public Request<List<ResourceServer>> list() { | ||
|
||
HttpUrl.Builder builder = baseUrl | ||
.newBuilder() | ||
.addPathSegments("api/v2/resource-servers"); | ||
|
||
String url = builder.build().toString(); | ||
CustomRequest<List<ResourceServer>> request = new CustomRequest<>(client, url, "GET", | ||
new TypeReference<List<ResourceServer>>() { | ||
}); | ||
request.addHeader("Authorization", "Bearer " + apiToken); | ||
return request; | ||
} | ||
|
||
/** | ||
* Cretes request for fetching single resource server by it's ID. | ||
* See <a href=https://auth0.com/docs/api/management/v2#!/Resource_Servers/get_resource_servers_by_id>API documentation</a> | ||
* | ||
* @param resourceServerIdOrIdentifier {@link ResourceServer#id} or {@link ResourceServer#identifier} (audience) field | ||
* @return request to execute | ||
*/ | ||
public Request<ResourceServer> get(String resourceServerIdOrIdentifier) { | ||
Asserts.assertNotNull(resourceServerIdOrIdentifier, "Resource server ID"); | ||
|
||
HttpUrl.Builder builder = baseUrl | ||
.newBuilder() | ||
.addPathSegments("api/v2/resource-servers") | ||
.addPathSegment(resourceServerIdOrIdentifier); | ||
|
||
String url = builder.build().toString(); | ||
CustomRequest<ResourceServer> request = new CustomRequest<>(client, url, "GET", | ||
new TypeReference<ResourceServer>() { | ||
}); | ||
request.addHeader("Authorization", "Bearer " + apiToken); | ||
return request; | ||
} | ||
|
||
/** | ||
* Cretes request for creation resource server | ||
* See <a href=https://auth0.com/docs/api/management/v2#!/Resource_Servers/post_resource_servers>API documentation</a> | ||
* | ||
* @param resourceServer resource server body | ||
* @return request to execute | ||
*/ | ||
public Request<ResourceServer> create(ResourceServer resourceServer) { | ||
Asserts.assertNotNull(resourceServer, "Resource server"); | ||
|
||
HttpUrl.Builder builder = baseUrl | ||
.newBuilder() | ||
.addPathSegments("api/v2/resource-servers"); | ||
|
||
String url = builder.build().toString(); | ||
CustomRequest<ResourceServer> request = new CustomRequest<>(client, url, "POST", | ||
new TypeReference<ResourceServer>() { | ||
}); | ||
request.addHeader("Authorization", "Bearer " + apiToken); | ||
request.setBody(resourceServer); | ||
return request; | ||
} | ||
|
||
/** | ||
* Creates request for delete resource server by it's ID | ||
* See <a href=https://auth0.com/docs/api/management/v2#!/Resource_Servers/delete_resource_servers_by_id>API documentation</a> | ||
* | ||
* @param resourceServerId {@link ResourceServer#id} field | ||
* @return request to execute | ||
*/ | ||
public Request<Void> delete(String resourceServerId) { | ||
Asserts.assertNotNull(resourceServerId, "Resource server ID"); | ||
|
||
HttpUrl.Builder builder = baseUrl | ||
.newBuilder() | ||
.addPathSegments("api/v2/resource-servers") | ||
.addPathSegment(resourceServerId); | ||
|
||
String url = builder.build().toString(); | ||
VoidRequest request = new VoidRequest(client, url, "DELETE"); | ||
request.addHeader("Authorization", "Bearer " + apiToken); | ||
return request; | ||
} | ||
|
||
/** | ||
* Creates request for partial update of resource server. All null fields stay not changed. | ||
* See <a href=https://auth0.com/docs/api/management/v2#!/Resource_Servers/patch_resource_servers_by_id>API documentation</a> | ||
* | ||
* @param resourceServerId {@link ResourceServer#id} field | ||
* @param resourceServer {@link ResourceServer} body | ||
* @return request to execute | ||
*/ | ||
public Request<ResourceServer> update(String resourceServerId, ResourceServer resourceServer) { | ||
Asserts.assertNotNull(resourceServerId, "resourceServerId"); | ||
Asserts.assertNotNull(resourceServer, "resourceServer"); | ||
|
||
HttpUrl.Builder builder = baseUrl | ||
.newBuilder() | ||
.addPathSegments("api/v2/resource-servers") | ||
.addPathSegment(resourceServerId); | ||
|
||
String url = builder.build().toString(); | ||
CustomRequest<ResourceServer> request = new CustomRequest<ResourceServer>(client, url, "PATCH", | ||
new TypeReference<ResourceServer>() { | ||
}); | ||
request.addHeader("Authorization", "Bearer " + apiToken); | ||
request.setBody(resourceServer); | ||
return request; | ||
} | ||
} |
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,157 @@ | ||
package com.auth0.json.mgmt; | ||
|
||
import java.util.List; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
@SuppressWarnings({"WeakerAccess", "unused"}) | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public class ResourceServer { | ||
@JsonProperty("id") | ||
private String id; | ||
@JsonProperty("name") | ||
private String name; | ||
@JsonProperty("identifier") | ||
private String identifier; | ||
@JsonProperty("scopes") | ||
private List<Scope> scopes; | ||
@JsonProperty("signing_alg") | ||
private String signingAlgorithm; | ||
@JsonProperty("signing_secret") | ||
private String signingSecret; | ||
@JsonProperty("allow_offline_access") | ||
private Boolean allowOfflineAccess; | ||
@JsonProperty("skip_consent_for_verifiable_first_party_clients") | ||
private Boolean skipConsentForVerifiableFirstPartyClients; | ||
@JsonProperty("token_lifetime") | ||
private Integer tokenLifetime; | ||
@JsonProperty("token_lifetime_for_web") | ||
private Integer tokenLifetimeForWeb; | ||
@JsonProperty("verification_location") | ||
private String verificationLocation; | ||
@JsonProperty("is_system") | ||
private Boolean isSystem; | ||
|
||
@JsonCreator | ||
public ResourceServer(@JsonProperty("identifier") String identifier) { | ||
this.identifier = identifier; | ||
} | ||
|
||
public ResourceServer() { | ||
} | ||
|
||
@JsonProperty("id") | ||
public String getId() { | ||
return id; | ||
} | ||
|
||
@JsonProperty("id") | ||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
|
||
@JsonProperty("name") | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
@JsonProperty("name") | ||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
@JsonProperty("is_system") | ||
public Boolean isSystem() { | ||
return isSystem; | ||
} | ||
|
||
@JsonProperty("identifier") | ||
public String getIdentifier() { | ||
return identifier; | ||
} | ||
|
||
@JsonProperty("scopes") | ||
public List<Scope> getScopes() { | ||
return scopes; | ||
} | ||
|
||
@JsonProperty("scopes") | ||
public void setScopes(List<Scope> scopes) { | ||
this.scopes = scopes; | ||
} | ||
|
||
@JsonProperty("signing_alg") | ||
public String getSigningAlgorithm() { | ||
return signingAlgorithm; | ||
} | ||
|
||
@JsonProperty("signing_alg") | ||
public void setSigningAlgorithm(String signingAlgorithm) { | ||
this.signingAlgorithm = signingAlgorithm; | ||
} | ||
|
||
@JsonProperty("signing_secret") | ||
public String getSigningSecret() { | ||
return signingSecret; | ||
} | ||
|
||
@JsonProperty("signing_secret") | ||
public void setSigningSecret(String signingSecret) { | ||
this.signingSecret = signingSecret; | ||
} | ||
|
||
@JsonProperty("allow_offline_access") | ||
public Boolean getAllowOfflineAccess() { | ||
return allowOfflineAccess; | ||
} | ||
|
||
@JsonProperty("allow_offline_access") | ||
public void setAllowOfflineAccess(Boolean allowOfflineAccess) { | ||
this.allowOfflineAccess = allowOfflineAccess; | ||
} | ||
|
||
@JsonProperty("skip_consent_for_verifiable_first_party_clients") | ||
public Boolean getSkipConsentForVerifiableFirstPartyClients() { | ||
return skipConsentForVerifiableFirstPartyClients; | ||
} | ||
|
||
@JsonProperty("skip_consent_for_verifiable_first_party_clients") | ||
public void setSkipConsentForVerifiableFirstPartyClients(Boolean skipConsentForVerifiableFirstPartyClients) { | ||
this.skipConsentForVerifiableFirstPartyClients = skipConsentForVerifiableFirstPartyClients; | ||
} | ||
|
||
@JsonProperty("token_lifetime") | ||
public Integer getTokenLifetime() { | ||
return tokenLifetime; | ||
} | ||
|
||
@JsonProperty("token_lifetime") | ||
public void setTokenLifetime(Integer tokenLifetime) { | ||
this.tokenLifetime = tokenLifetime; | ||
} | ||
|
||
@JsonProperty("verification_location") | ||
public String getVerificationLocation() { | ||
return verificationLocation; | ||
} | ||
|
||
@JsonProperty("verification_location") | ||
public void setVerificationLocation(String verificationLocation) { | ||
this.verificationLocation = verificationLocation; | ||
} | ||
|
||
@JsonProperty("token_lifetime_for_web") | ||
public Integer getTokenLifetimeForWeb() { | ||
return tokenLifetimeForWeb; | ||
} | ||
|
||
@JsonProperty("token_lifetime_for_web") | ||
public void setTokenLifetimeForWeb(Integer tokenLifetimeForWeb) { | ||
this.tokenLifetimeForWeb = tokenLifetimeForWeb; | ||
} | ||
|
||
} |
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,41 @@ | ||
package com.auth0.json.mgmt; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
@SuppressWarnings({"WeakerAccess", "unused"}) | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public class Scope { | ||
@JsonProperty("description") | ||
private String description; | ||
@JsonProperty("value") | ||
private String value; | ||
|
||
@JsonCreator | ||
public Scope(@JsonProperty("value") String value) { | ||
this.value = value; | ||
} | ||
|
||
@JsonProperty("description") | ||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
@JsonProperty("description") | ||
public void setDescription(String description) { | ||
this.description = description; | ||
} | ||
|
||
@JsonProperty("value") | ||
public String getValue() { | ||
return value; | ||
} | ||
|
||
@JsonProperty("value") | ||
public void setValue(String value) { | ||
this.value = value; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's missing the "token_lifetime_for_web" property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done