Skip to content

Commit

Permalink
Merge branch 'master' into Add-ReversingLAB-scanner
Browse files Browse the repository at this point in the history
  • Loading branch information
developerkunal authored Oct 18, 2024
2 parents d2adac7 + 8ae4042 commit 289e1b3
Show file tree
Hide file tree
Showing 16 changed files with 466 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.13.0
2.14.0
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change Log

## [2.14.0](https://github.com/auth0/auth0-java/tree/2.14.0) (2024-10-16)
[Full Changelog](https://github.com/auth0/auth0-java/compare/2.13.0...2.14.0)

**Added**
- SDKs support for Control Your Own Key [\#671](https://github.com/auth0/auth0-java/pull/671) ([tanya732](https://github.com/tanya732))
- Added client credentials changes [\#670](https://github.com/auth0/auth0-java/pull/670) ([tanya732](https://github.com/tanya732))
- Added support for HRI phase 2 changes [\#668](https://github.com/auth0/auth0-java/pull/668) ([tanya732](https://github.com/tanya732))

## [2.13.0](https://github.com/auth0/auth0-java/tree/2.13.0) (2024-09-11)
[Full Changelog](https://github.com/auth0/auth0-java/compare/2.12.0...2.13.0)

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ Add the dependency via Maven:
<dependency>
<groupId>com.auth0</groupId>
<artifactId>auth0</artifactId>
<version>2.13.0</version>
<version>2.14.0</version>
</dependency>
```

or Gradle:

```gradle
implementation 'com.auth0:auth0:2.13.0'
implementation 'com.auth0:auth0:2.14.0'
```

### Configure the SDK
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/com/auth0/client/mgmt/KeysEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.auth0.json.mgmt.keys.Key;
import com.auth0.net.EmptyBodyRequest;
import com.auth0.net.BaseRequest;
import com.auth0.net.EmptyBodyVoidRequest;
import com.auth0.net.Request;
import com.auth0.net.client.Auth0HttpClient;
import com.auth0.net.client.HttpMethod;
Expand Down Expand Up @@ -100,4 +101,20 @@ public Request<Key> revoke(String kid) {
return new EmptyBodyRequest<>(this.client, tokenProvider, url, HttpMethod.PUT, new TypeReference<Key>() {
});
}

/**
* Perform rekeying operation on the key hierarchy.
* A token with scope create:encryption_keys and update:encryption_keys is needed
* See https://auth0.com/docs/api/management/v2#!/Keys/post-encryption-rekey
* @return a Request to execute.
*/
public Request<Void> postEncryptionRekey(){
String url = baseUrl
.newBuilder()
.addPathSegments("api/v2/keys/encryption/rekey")
.build()
.toString();

return new EmptyBodyVoidRequest<>(this.client, tokenProvider, url, HttpMethod.POST, new TypeReference<Void>() {});
}
}
11 changes: 11 additions & 0 deletions src/main/java/com/auth0/client/mgmt/filter/ClientFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,15 @@ public ClientFilter withFields(String fields, boolean includeFields) {
super.withFields(fields, includeFields);
return this;
}

/**
* Filter by custom query
*
* @param query the query string using Lucene query syntax
* @return this filter instance
*/
public ClientFilter withQuery(String query) {
parameters.put("q", query);
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,15 @@ public OrganizationClientGrantsFilter withTotals(boolean includeTotals) {
parameters.put("include_totals", includeTotals);
return this;
}

/**
* Filter by grant IDs
*
* @param grantIds comma-separated list of grant IDs to filter results on.
* @return this filter instance
*/
public OrganizationClientGrantsFilter withGrantIds(String grantIds) {
parameters.put("grant_ids", grantIds);
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,28 @@ public ResourceServersFilter withTotals(boolean includeTotals) {
return this;
}

/**
* Filter by specific identifier IDs (i.e. audience)
*
* @param identifiers the identifier IDs to filter by
* @return this filter instance
*/
public ResourceServersFilter withIdentifiers(String identifiers) {
parameters.put("identifiers", identifiers);
return this;
}

/**
* Filter by checkpoint pagination support
*
* @param from the starting index identifier
* @param take the number of items to retrieve
* @return this filter instance
*/
public ResourceServersFilter withCheckpointPagination(String from, int take) {
parameters.put("from", from);
parameters.put("take", take);
return this;
}

}
18 changes: 18 additions & 0 deletions src/main/java/com/auth0/json/mgmt/client/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ public class Client {
private String complianceLevel;
@JsonProperty("require_proof_of_possession")
private Boolean requireProofOfPossession;
@JsonProperty("default_organization")
private ClientDefaultOrganization defaultOrganization;

/**
* Getter for the name of the tenant this client belongs to.
Expand Down Expand Up @@ -889,5 +891,21 @@ public Boolean getRequireProofOfPossession() {
public void setRequireProofOfPossession(Boolean requireProofOfPossession) {
this.requireProofOfPossession = requireProofOfPossession;
}

/**
* Getter for the default organization configuration.
* @return the default organization configuration.
*/
public ClientDefaultOrganization getDefaultOrganization() {
return defaultOrganization;
}

/**
* Setter for the default organization configuration.
* @param defaultOrganization the default organization configuration to set.
*/
public void setDefaultOrganization(ClientDefaultOrganization defaultOrganization) {
this.defaultOrganization = defaultOrganization;
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.auth0.json.mgmt.client;

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 ClientDefaultOrganization {
@JsonProperty("flows")
private List<String> flows;
@JsonProperty("organization_id")
private String organizationId;

public ClientDefaultOrganization() {

}

public ClientDefaultOrganization(List<String> flows, String organizationId) {
this.flows = flows;
this.organizationId = organizationId;
}

/**
* Getter for the supported flows.
* @return the supported flows.
*/
public List<String> getFlows() {
return flows;
}

/**
* Setter for the supported flows.
* @param flows the supported flows to set.
*/
public void setFlows(List<String> flows) {
this.flows = flows;
}

/**
* Getter for the organization_id.
* @return the organization_id.
*/
public String getOrganizationId() {
return organizationId;
}

/**
* Setter for the organization_id.
* @param organizationId the organization_id to set.
*/
public void setOrganizationId(String organizationId) {
this.organizationId = organizationId;
}
}
42 changes: 42 additions & 0 deletions src/main/java/com/auth0/net/EmptyBodyVoidRequest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.auth0.net;

import com.auth0.client.mgmt.TokenProvider;
import com.auth0.exception.Auth0Exception;
import com.auth0.net.client.Auth0HttpClient;
import com.auth0.net.client.Auth0HttpResponse;
import com.auth0.net.client.HttpMethod;
import com.auth0.net.client.HttpRequestBody;
import com.fasterxml.jackson.core.type.TypeReference;

/**
* Request class that does not accept parameters to be sent as part of its body and request doesn't return any value on its success.
* The content type of this request is "application/json".
*
* @param <T> The type expected to be received as part of the response.
* @see BaseRequest
*/
public class EmptyBodyVoidRequest<T> extends BaseRequest<T> {
public EmptyBodyVoidRequest(Auth0HttpClient client, TokenProvider tokenProvider, String url, HttpMethod method, TypeReference<T> tType) {
super(client, tokenProvider, url, method, tType);
}

@Override
@SuppressWarnings("deprecation")
protected HttpRequestBody createRequestBody() {
return HttpRequestBody.create("application/json", new byte[0]);
}

@Override
public EmptyBodyVoidRequest<T> addParameter(String name, Object value) {
//do nothing
return this;
}
@Override
protected T parseResponseBody(Auth0HttpResponse response) throws Auth0Exception {
if (!response.isSuccessful()) {
throw super.createResponseException(response);
}
return null;
}

}
19 changes: 19 additions & 0 deletions src/test/java/com/auth0/client/mgmt/ClientsEntityTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,25 @@ public void shouldListClientsWithAdditionalProperties() throws Exception {
assertThat(response.getItems(), hasSize(2));
}

@Test
public void shouldListClientsWithQuery() throws Exception {
ClientFilter filter = new ClientFilter().withQuery("client_grant.organization_id:" + "org_123");
Request<ClientsPage> request = api.clients().list(filter);
assertThat(request, is(notNullValue()));

server.jsonResponse(MGMT_CLIENTS_PAGED_LIST, 200);
ClientsPage response = request.execute().getBody();
RecordedRequest recordedRequest = server.takeRequest();

assertThat(recordedRequest, hasMethodAndPath(HttpMethod.GET, "/api/v2/clients"));
assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
assertThat(recordedRequest, hasQueryParameter("q", "client_grant.organization_id:" + "org_123"));

assertThat(response, is(notNullValue()));
assertThat(response.getItems(), hasSize(2));
}

@Test
public void shouldThrowOnGetClientWithNullId() {
verifyThrows(IllegalArgumentException.class,
Expand Down
14 changes: 14 additions & 0 deletions src/test/java/com/auth0/client/mgmt/KeysEntityTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,18 @@ public void shouldRevokeKey() throws Exception {

assertThat(response, is(notNullValue()));
}

@Test
public void shouldRekey() throws Exception {
Request<Void> request = api.keys().postEncryptionRekey();
assertThat(request, is(notNullValue()));

server.emptyResponse(204);
request.execute().getBody();
RecordedRequest recordedRequest = server.takeRequest();

assertThat(recordedRequest, hasMethodAndPath(HttpMethod.POST, "/api/v2/keys/encryption/rekey"));
assertThat(recordedRequest, hasHeader("Content-Type", "application/json"));
assertThat(recordedRequest, hasHeader("Authorization", "Bearer apiToken"));
}
}
Loading

0 comments on commit 289e1b3

Please sign in to comment.