Skip to content

Commit

Permalink
Remove the Java type from the serialized JSON requests
Browse files Browse the repository at this point in the history
  • Loading branch information
ebourg committed May 2, 2024
1 parent 50c7f8e commit ef04ae1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,12 @@ public byte[] sign(SigningServicePrivateKey privateKey, String algorithm, byte[]
request.put("MessageType", "DIGEST");
request.put("Message", Base64.getEncoder().encodeToString(data));
request.put("SigningAlgorithm", alg);
request.put(JsonWriter.TYPE, "false");

Map<String, Object> args = new HashMap<>();
args.put(JsonWriter.TYPE, "false");

try {
Map<String, ?> response = query("TrentService.Sign", JsonWriter.objectToJson(request));
Map<String, ?> response = query("TrentService.Sign", JsonWriter.objectToJson(request, args));
String signature = (String) response.get("Signature");
return Base64.getDecoder().decode(signature);
} catch (IOException e) {
Expand Down
15 changes: 12 additions & 3 deletions jsign-core/src/main/java/net/jsign/jca/ESignerSigningService.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,11 @@ private static String getAccessToken(String endpoint, String clientId, String us
request.put("username", username);
request.put("password", password);

Map<String, Object> args = new HashMap<>();
args.put(JsonWriter.TYPE, "false");

RESTClient client = new RESTClient(endpoint);
Map<String, ?> response = client.post("/oauth2/token", JsonWriter.objectToJson(request));
Map<String, ?> response = client.post("/oauth2/token", JsonWriter.objectToJson(request, args));
return (String) response.get("access_token");
}

Expand All @@ -89,7 +92,9 @@ public List<String> aliases() throws KeyStoreException {
try {
Map<String, String> request = new HashMap<>();
request.put("clientData", "EVCS");
Map<String, ?> response = client.post("/csc/v0/credentials/list", JsonWriter.objectToJson(request));
Map<String, Object> args = new HashMap<>();
args.put(JsonWriter.TYPE, "false");
Map<String, ?> response = client.post("/csc/v0/credentials/list", JsonWriter.objectToJson(request, args));
Object[] credentials = (Object[]) response.get("credentialIDs");
return Stream.of(credentials).map(Object::toString).collect(Collectors.toList());
} catch (IOException e) {
Expand All @@ -107,7 +112,11 @@ public List<String> aliases() throws KeyStoreException {
Map<String, String> request = new HashMap<>();
request.put("credentialID", alias);
request.put("certificates", "chain");
Map<String, ?> response = client.post("/csc/v0/credentials/info", JsonWriter.objectToJson(request));

Map<String, Object> args = new HashMap<>();
args.put(JsonWriter.TYPE, "false");

Map<String, ?> response = client.post("/csc/v0/credentials/info", JsonWriter.objectToJson(request, args));
certificates.put(alias, (Map) response.get("cert"));
}

Expand Down

0 comments on commit ef04ae1

Please sign in to comment.