Skip to content

Commit

Permalink
fixed IllegalStateException when search query contains curly braces
Browse files Browse the repository at this point in the history
  • Loading branch information
albogdano committed Aug 19, 2021
1 parent 9a50e7d commit 90ae7c6
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions para-core/src/main/java/com/erudika/para/rest/Signer.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import javax.ws.rs.HttpMethod;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.Entity;
Expand Down Expand Up @@ -232,6 +233,18 @@ public Response invokeSignedRequest(Client apiClient, String accessKey, String s

boolean isJWT = StringUtils.startsWithIgnoreCase(secretKey, "Bearer");

// strip URI template param brackets - https://stackoverflow.com/questions/57011188
reqPath = reqPath.replaceAll("[{}]", "");
if (params != null) {
for (Map.Entry<String, List<String>> param : params.entrySet()) {
String key = param.getKey();
List<String> value = param.getValue();
if (value != null && !value.isEmpty()) {
params.put(key, value.stream().filter(v -> !StringUtils.isBlank(v)).
map(v -> v.replaceAll("[{}]", "")).collect(Collectors.toList()));
}
}
}
WebTarget target = apiClient.target(endpointURL).path(reqPath);
Map<String, String> signedHeaders = new HashMap<>();
if (!isJWT) {
Expand Down

0 comments on commit 90ae7c6

Please sign in to comment.