diff --git a/build.gradle b/build.gradle index 68948f64..c9ac2d33 100644 --- a/build.gradle +++ b/build.gradle @@ -60,15 +60,15 @@ test { } dependencies { - implementation 'com.squareup.okhttp3:okhttp:3.9.1' - implementation 'com.squareup.okhttp3:logging-interceptor:3.9.1' + implementation 'com.squareup.okhttp3:okhttp:3.14.9' + implementation 'com.squareup.okhttp3:logging-interceptor:3.14.9' implementation 'com.fasterxml.jackson.core:jackson-databind:2.10.0.pr3' implementation 'commons-codec:commons-codec:1.13' implementation 'com.auth0:java-jwt:3.10.3' testImplementation 'org.bouncycastle:bcprov-jdk15on:1.65' testImplementation 'org.mockito:mockito-core:2.28.2' - testImplementation 'com.squareup.okhttp3:mockwebserver:3.9.1' + testImplementation 'com.squareup.okhttp3:mockwebserver:3.14.9' testImplementation 'org.hamcrest:hamcrest-core:1.3' testImplementation 'org.hamcrest:hamcrest-library:1.3' testImplementation 'junit:junit:4.12' diff --git a/src/main/java/com/auth0/client/auth/AuthorizeUrlBuilder.java b/src/main/java/com/auth0/client/auth/AuthorizeUrlBuilder.java index ef009ec4..9ac1a229 100644 --- a/src/main/java/com/auth0/client/auth/AuthorizeUrlBuilder.java +++ b/src/main/java/com/auth0/client/auth/AuthorizeUrlBuilder.java @@ -37,7 +37,7 @@ private AuthorizeUrlBuilder(HttpUrl url, String clientId, String redirectUri) { builder = url.newBuilder() .addPathSegment("authorize") .addEncodedQueryParameter("redirect_uri", redirectUri) - .addQueryParameter("client_id", clientId); + .addEncodedQueryParameter("client_id", clientId); withParameter("response_type", "code"); } @@ -122,7 +122,7 @@ public AuthorizeUrlBuilder withParameter(String name, String value) { */ public String build() { for (Map.Entry p : parameters.entrySet()) { - builder.addQueryParameter(p.getKey(), p.getValue()); + builder.addEncodedQueryParameter(p.getKey(), p.getValue()); } return builder.build().toString(); } diff --git a/src/main/java/com/auth0/client/auth/LogoutUrlBuilder.java b/src/main/java/com/auth0/client/auth/LogoutUrlBuilder.java index cbfe29c9..f54da99e 100644 --- a/src/main/java/com/auth0/client/auth/LogoutUrlBuilder.java +++ b/src/main/java/com/auth0/client/auth/LogoutUrlBuilder.java @@ -40,7 +40,7 @@ private LogoutUrlBuilder(HttpUrl url, String clientId, String returnToUrl) { .addPathSegment("logout") .addEncodedQueryParameter("returnTo", returnToUrl); if (clientId != null) { - builder.addQueryParameter("client_id", clientId); + builder.addEncodedQueryParameter("client_id", clientId); } } @@ -66,7 +66,7 @@ public LogoutUrlBuilder useFederated(boolean federated) { */ public String build() { for (Map.Entry p : parameters.entrySet()) { - builder.addQueryParameter(p.getKey(), p.getValue()); + builder.addEncodedQueryParameter(p.getKey(), p.getValue()); } return builder.build().toString(); } diff --git a/src/main/java/com/auth0/client/mgmt/BlacklistsEntity.java b/src/main/java/com/auth0/client/mgmt/BlacklistsEntity.java index 93814f01..71b93078 100644 --- a/src/main/java/com/auth0/client/mgmt/BlacklistsEntity.java +++ b/src/main/java/com/auth0/client/mgmt/BlacklistsEntity.java @@ -34,7 +34,7 @@ public Request> getBlacklist(String audience) { String url = baseUrl .newBuilder() .addPathSegments("api/v2/blacklists/tokens") - .addQueryParameter("aud", audience) + .addEncodedQueryParameter("aud", audience) .build() .toString(); CustomRequest> request = new CustomRequest<>(client, url, "GET", new TypeReference>() { diff --git a/src/main/java/com/auth0/client/mgmt/ClientGrantsEntity.java b/src/main/java/com/auth0/client/mgmt/ClientGrantsEntity.java index 30896e46..6fbd1c1d 100644 --- a/src/main/java/com/auth0/client/mgmt/ClientGrantsEntity.java +++ b/src/main/java/com/auth0/client/mgmt/ClientGrantsEntity.java @@ -37,7 +37,7 @@ public Request list(ClientGrantsFilter filter) { .addPathSegments("api/v2/client-grants"); if (filter != null) { for (Map.Entry e : filter.getAsMap().entrySet()) { - builder.addQueryParameter(e.getKey(), String.valueOf(e.getValue())); + builder.addEncodedQueryParameter(e.getKey(), String.valueOf(e.getValue())); } } diff --git a/src/main/java/com/auth0/client/mgmt/ClientsEntity.java b/src/main/java/com/auth0/client/mgmt/ClientsEntity.java index 28d4c1fb..9c177184 100644 --- a/src/main/java/com/auth0/client/mgmt/ClientsEntity.java +++ b/src/main/java/com/auth0/client/mgmt/ClientsEntity.java @@ -59,7 +59,7 @@ public Request list(ClientFilter filter) { .addPathSegments("api/v2/clients"); if (filter != null) { for (Map.Entry e : filter.getAsMap().entrySet()) { - builder.addQueryParameter(e.getKey(), String.valueOf(e.getValue())); + builder.addEncodedQueryParameter(e.getKey(), String.valueOf(e.getValue())); } } String url = builder.build().toString(); diff --git a/src/main/java/com/auth0/client/mgmt/ConnectionsEntity.java b/src/main/java/com/auth0/client/mgmt/ConnectionsEntity.java index 4de7c1f1..df4f275c 100644 --- a/src/main/java/com/auth0/client/mgmt/ConnectionsEntity.java +++ b/src/main/java/com/auth0/client/mgmt/ConnectionsEntity.java @@ -38,7 +38,7 @@ public Request listAll(ConnectionFilter filter) { .addPathSegments("api/v2/connections"); if (filter != null) { for (Map.Entry e : filter.getAsMap().entrySet()) { - builder.addQueryParameter(e.getKey(), String.valueOf(e.getValue())); + builder.addEncodedQueryParameter(e.getKey(), String.valueOf(e.getValue())); } } String url = builder.build().toString(); @@ -67,7 +67,7 @@ public Request> list(ConnectionFilter filter) { for (Map.Entry e : filter.getAsMap().entrySet()) { //This check below is to prevent JSON parsing errors if (!e.getKey().equalsIgnoreCase("include_totals")) { - builder.addQueryParameter(e.getKey(), String.valueOf(e.getValue())); + builder.addEncodedQueryParameter(e.getKey(), String.valueOf(e.getValue())); } } } @@ -95,7 +95,7 @@ public Request get(String connectionId, ConnectionFilter filter) { .addPathSegment(connectionId); if (filter != null) { for (Map.Entry e : filter.getAsMap().entrySet()) { - builder.addQueryParameter(e.getKey(), String.valueOf(e.getValue())); + builder.addEncodedQueryParameter(e.getKey(), String.valueOf(e.getValue())); } } String url = builder.build().toString(); @@ -190,7 +190,7 @@ public Request deleteUser(String connectionId, String email) { .addPathSegments("api/v2/connections") .addPathSegment(connectionId) .addPathSegment("users") - .addQueryParameter("email", email) + .addEncodedQueryParameter("email", email) .build() .toString(); VoidRequest request = new VoidRequest(this.client, url, "DELETE"); diff --git a/src/main/java/com/auth0/client/mgmt/DeviceCredentialsEntity.java b/src/main/java/com/auth0/client/mgmt/DeviceCredentialsEntity.java index 4ca82265..d804e152 100644 --- a/src/main/java/com/auth0/client/mgmt/DeviceCredentialsEntity.java +++ b/src/main/java/com/auth0/client/mgmt/DeviceCredentialsEntity.java @@ -36,7 +36,7 @@ public Request> list(DeviceCredentialsFilter filter) { .addPathSegments("api/v2/device-credentials"); if (filter != null) { for (Map.Entry e : filter.getAsMap().entrySet()) { - builder.addQueryParameter(e.getKey(), String.valueOf(e.getValue())); + builder.addEncodedQueryParameter(e.getKey(), String.valueOf(e.getValue())); } } String url = builder.build().toString(); diff --git a/src/main/java/com/auth0/client/mgmt/EmailProviderEntity.java b/src/main/java/com/auth0/client/mgmt/EmailProviderEntity.java index 439c222b..a30383f0 100644 --- a/src/main/java/com/auth0/client/mgmt/EmailProviderEntity.java +++ b/src/main/java/com/auth0/client/mgmt/EmailProviderEntity.java @@ -34,7 +34,7 @@ public Request get(FieldsFilter filter) { .addPathSegments("api/v2/emails/provider"); if (filter != null) { for (Map.Entry e : filter.getAsMap().entrySet()) { - builder.addQueryParameter(e.getKey(), String.valueOf(e.getValue())); + builder.addEncodedQueryParameter(e.getKey(), String.valueOf(e.getValue())); } } String url = builder.build().toString(); diff --git a/src/main/java/com/auth0/client/mgmt/GrantsEntity.java b/src/main/java/com/auth0/client/mgmt/GrantsEntity.java index 816e0847..d3520fa3 100644 --- a/src/main/java/com/auth0/client/mgmt/GrantsEntity.java +++ b/src/main/java/com/auth0/client/mgmt/GrantsEntity.java @@ -38,10 +38,10 @@ public Request list(String userId, GrantsFilter filter) { HttpUrl.Builder builder = baseUrl .newBuilder() .addPathSegments("api/v2/grants") - .addQueryParameter("user_id", userId); + .addEncodedQueryParameter("user_id", userId); if (filter != null) { for (Map.Entry e : filter.getAsMap().entrySet()) { - builder.addQueryParameter(e.getKey(), String.valueOf(e.getValue())); + builder.addEncodedQueryParameter(e.getKey(), String.valueOf(e.getValue())); } } @@ -68,7 +68,7 @@ public Request> list(String userId) { String url = baseUrl .newBuilder() .addPathSegments("api/v2/grants") - .addQueryParameter("user_id", userId) + .addEncodedQueryParameter("user_id", userId) .build() .toString(); CustomRequest> request = new CustomRequest<>(client, url, "GET", new TypeReference>() { @@ -111,7 +111,7 @@ public Request deleteAll(String userId) { final String url = baseUrl .newBuilder() .addPathSegments("api/v2/grants") - .addQueryParameter("user_id", userId) + .addEncodedQueryParameter("user_id", userId) .build() .toString(); VoidRequest request = new VoidRequest(client, url, "DELETE"); diff --git a/src/main/java/com/auth0/client/mgmt/LogEventsEntity.java b/src/main/java/com/auth0/client/mgmt/LogEventsEntity.java index 3834fff1..fe8bba6a 100644 --- a/src/main/java/com/auth0/client/mgmt/LogEventsEntity.java +++ b/src/main/java/com/auth0/client/mgmt/LogEventsEntity.java @@ -40,7 +40,7 @@ public Request list(LogEventFilter filter) { if (KEY_QUERY.equals(e.getKey())) { builder.addEncodedQueryParameter(e.getKey(), String.valueOf(e.getValue())); } else { - builder.addQueryParameter(e.getKey(), String.valueOf(e.getValue())); + builder.addEncodedQueryParameter(e.getKey(), String.valueOf(e.getValue())); } } } diff --git a/src/main/java/com/auth0/client/mgmt/ResourceServerEntity.java b/src/main/java/com/auth0/client/mgmt/ResourceServerEntity.java index 9396b9ce..17d8be41 100644 --- a/src/main/java/com/auth0/client/mgmt/ResourceServerEntity.java +++ b/src/main/java/com/auth0/client/mgmt/ResourceServerEntity.java @@ -36,7 +36,7 @@ public Request list(ResourceServersFilter filter) { .addPathSegments("api/v2/resource-servers"); if (filter != null) { for (Map.Entry e : filter.getAsMap().entrySet()) { - builder.addQueryParameter(e.getKey(), String.valueOf(e.getValue())); + builder.addEncodedQueryParameter(e.getKey(), String.valueOf(e.getValue())); } } diff --git a/src/main/java/com/auth0/client/mgmt/RolesEntity.java b/src/main/java/com/auth0/client/mgmt/RolesEntity.java index 17da9ef8..1445cb01 100644 --- a/src/main/java/com/auth0/client/mgmt/RolesEntity.java +++ b/src/main/java/com/auth0/client/mgmt/RolesEntity.java @@ -40,7 +40,7 @@ public Request list(RolesFilter filter) { .addEncodedPathSegments("api/v2/roles"); if (filter != null) { for (Map.Entry e : filter.getAsMap().entrySet()) { - builder.addQueryParameter(e.getKey(), String.valueOf(e.getValue())); + builder.addEncodedQueryParameter(e.getKey(), String.valueOf(e.getValue())); } } String url = builder.build().toString(); @@ -160,7 +160,7 @@ public Request listUsers(String roleId, PageFilter filter) { .addEncodedPathSegments("users"); if (filter != null) { for (Map.Entry e : filter.getAsMap().entrySet()) { - builder.addQueryParameter(e.getKey(), String.valueOf(e.getValue())); + builder.addEncodedQueryParameter(e.getKey(), String.valueOf(e.getValue())); } } String url = builder.build().toString(); @@ -217,7 +217,7 @@ public Request listPermissions(String roleId, PageFilter filter .addEncodedPathSegments("permissions"); if (filter != null) { for (Map.Entry e : filter.getAsMap().entrySet()) { - builder.addQueryParameter(e.getKey(), String.valueOf(e.getValue())); + builder.addEncodedQueryParameter(e.getKey(), String.valueOf(e.getValue())); } } String url = builder.build().toString(); diff --git a/src/main/java/com/auth0/client/mgmt/RulesEntity.java b/src/main/java/com/auth0/client/mgmt/RulesEntity.java index 3f8676d0..0074a9c9 100644 --- a/src/main/java/com/auth0/client/mgmt/RulesEntity.java +++ b/src/main/java/com/auth0/client/mgmt/RulesEntity.java @@ -37,7 +37,7 @@ public Request listAll(RulesFilter filter) { .addPathSegments("api/v2/rules"); if (filter != null) { for (Map.Entry e : filter.getAsMap().entrySet()) { - builder.addQueryParameter(e.getKey(), String.valueOf(e.getValue())); + builder.addEncodedQueryParameter(e.getKey(), String.valueOf(e.getValue())); } } String url = builder.build().toString(); @@ -65,7 +65,7 @@ public Request> list(RulesFilter filter) { for (Map.Entry e : filter.getAsMap().entrySet()) { //This check below is to prevent JSON parsing errors if (!e.getKey().equalsIgnoreCase("include_totals")) { - builder.addQueryParameter(e.getKey(), String.valueOf(e.getValue())); + builder.addEncodedQueryParameter(e.getKey(), String.valueOf(e.getValue())); } } } @@ -93,7 +93,7 @@ public Request get(String ruleId, RulesFilter filter) { .addPathSegment(ruleId); if (filter != null) { for (Map.Entry e : filter.getAsMap().entrySet()) { - builder.addQueryParameter(e.getKey(), String.valueOf(e.getValue())); + builder.addEncodedQueryParameter(e.getKey(), String.valueOf(e.getValue())); } } String url = builder.build().toString(); diff --git a/src/main/java/com/auth0/client/mgmt/StatsEntity.java b/src/main/java/com/auth0/client/mgmt/StatsEntity.java index fb029ef3..5a013275 100644 --- a/src/main/java/com/auth0/client/mgmt/StatsEntity.java +++ b/src/main/java/com/auth0/client/mgmt/StatsEntity.java @@ -58,8 +58,8 @@ public Request> getDailyStats(Date from, Date to) { String url = baseUrl .newBuilder() .addPathSegments("api/v2/stats/daily") - .addQueryParameter("from", dateFrom) - .addQueryParameter("to", dateTo) + .addEncodedQueryParameter("from", dateFrom) + .addEncodedQueryParameter("to", dateTo) .build() .toString(); diff --git a/src/main/java/com/auth0/client/mgmt/TenantsEntity.java b/src/main/java/com/auth0/client/mgmt/TenantsEntity.java index 03b72f87..b1054cfb 100644 --- a/src/main/java/com/auth0/client/mgmt/TenantsEntity.java +++ b/src/main/java/com/auth0/client/mgmt/TenantsEntity.java @@ -34,7 +34,7 @@ public Request get(FieldsFilter filter) { .addPathSegments("api/v2/tenants/settings"); if (filter != null) { for (Map.Entry e : filter.getAsMap().entrySet()) { - builder.addQueryParameter(e.getKey(), String.valueOf(e.getValue())); + builder.addEncodedQueryParameter(e.getKey(), String.valueOf(e.getValue())); } } String url = builder.build().toString(); diff --git a/src/main/java/com/auth0/client/mgmt/UserBlocksEntity.java b/src/main/java/com/auth0/client/mgmt/UserBlocksEntity.java index 70377416..9288e3cc 100644 --- a/src/main/java/com/auth0/client/mgmt/UserBlocksEntity.java +++ b/src/main/java/com/auth0/client/mgmt/UserBlocksEntity.java @@ -32,7 +32,7 @@ public Request getByIdentifier(String identifier) { String url = baseUrl .newBuilder() .addPathSegments("api/v2/user-blocks") - .addQueryParameter("identifier", identifier) + .addEncodedQueryParameter("identifier", identifier) .build() .toString(); CustomRequest request = new CustomRequest<>(client, url, "GET", new TypeReference() { @@ -54,7 +54,7 @@ public Request deleteByIdentifier(String identifier) { String url = baseUrl .newBuilder() .addPathSegments("api/v2/user-blocks") - .addQueryParameter("identifier", identifier) + .addEncodedQueryParameter("identifier", identifier) .build() .toString(); VoidRequest request = new VoidRequest(client, url, "DELETE"); diff --git a/src/main/java/com/auth0/client/mgmt/UsersEntity.java b/src/main/java/com/auth0/client/mgmt/UsersEntity.java index aa696428..d2ea9f21 100644 --- a/src/main/java/com/auth0/client/mgmt/UsersEntity.java +++ b/src/main/java/com/auth0/client/mgmt/UsersEntity.java @@ -53,10 +53,10 @@ public Request> listByEmail(String email, FieldsFilter filter) { HttpUrl.Builder builder = baseUrl .newBuilder() .addPathSegments("api/v2/users-by-email"); - builder.addQueryParameter("email", email); + builder.addEncodedQueryParameter("email", email); if (filter != null) { for (Map.Entry e : filter.getAsMap().entrySet()) { - builder.addQueryParameter(e.getKey(), String.valueOf(e.getValue())); + builder.addEncodedQueryParameter(e.getKey(), String.valueOf(e.getValue())); } } @@ -85,7 +85,7 @@ public Request list(UserFilter filter) { if (KEY_QUERY.equals(e.getKey())) { builder.addEncodedQueryParameter(e.getKey(), String.valueOf(e.getValue())); } else { - builder.addQueryParameter(e.getKey(), String.valueOf(e.getValue())); + builder.addEncodedQueryParameter(e.getKey(), String.valueOf(e.getValue())); } } } @@ -115,7 +115,7 @@ public Request get(String userId, UserFilter filter) { .addPathSegment(userId); if (filter != null) { for (Map.Entry e : filter.getAsMap().entrySet()) { - builder.addQueryParameter(e.getKey(), String.valueOf(e.getValue())); + builder.addEncodedQueryParameter(e.getKey(), String.valueOf(e.getValue())); } } String url = builder.build().toString(); @@ -241,7 +241,7 @@ public Request getLogEvents(String userId, LogEventFilter filter) .addPathSegment("logs"); if (filter != null) { for (Map.Entry e : filter.getAsMap().entrySet()) { - builder.addQueryParameter(e.getKey(), String.valueOf(e.getValue())); + builder.addEncodedQueryParameter(e.getKey(), String.valueOf(e.getValue())); } } String url = builder.build().toString(); @@ -386,7 +386,7 @@ public Request listPermissions(String userId, PageFilter filter .addPathSegments("permissions"); if (filter != null) { for (Map.Entry e : filter.getAsMap().entrySet()) { - builder.addQueryParameter(e.getKey(), String.valueOf(e.getValue())); + builder.addEncodedQueryParameter(e.getKey(), String.valueOf(e.getValue())); } } String url = builder.build().toString(); @@ -473,7 +473,7 @@ public Request listRoles(String userId, PageFilter filter) { .addPathSegments("roles"); if (filter != null) { for (Map.Entry e : filter.getAsMap().entrySet()) { - builder.addQueryParameter(e.getKey(), String.valueOf(e.getValue())); + builder.addEncodedQueryParameter(e.getKey(), String.valueOf(e.getValue())); } } String url = builder.build().toString();