summaryrefslogtreecommitdiffstats
path: root/vespa-athenz
diff options
context:
space:
mode:
authorjonmv <venstad@gmail.com>2023-07-05 10:43:34 +0200
committerjonmv <venstad@gmail.com>2023-07-05 10:43:34 +0200
commit55e23eab171ca5ff62c9167c659a40091fa1dd2f (patch)
tree8aef6c7ce6f2e7144d597aba9d8873d56c95d17e /vespa-athenz
parent4b5d9a1e79da69a0296cdfde3d20e2afd26e931f (diff)
Proper JSON
Diffstat (limited to 'vespa-athenz')
-rw-r--r--vespa-athenz/src/main/java/com/yahoo/vespa/athenz/client/zms/DefaultZmsClient.java13
1 files changed, 4 insertions, 9 deletions
diff --git a/vespa-athenz/src/main/java/com/yahoo/vespa/athenz/client/zms/DefaultZmsClient.java b/vespa-athenz/src/main/java/com/yahoo/vespa/athenz/client/zms/DefaultZmsClient.java
index 6d19b102745..4500df6ff1b 100644
--- a/vespa-athenz/src/main/java/com/yahoo/vespa/athenz/client/zms/DefaultZmsClient.java
+++ b/vespa-athenz/src/main/java/com/yahoo/vespa/athenz/client/zms/DefaultZmsClient.java
@@ -1,6 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.athenz.client.zms;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.yahoo.athenz.auth.util.Crypto;
import com.yahoo.security.KeyUtils;
import com.yahoo.vespa.athenz.api.AthenzAssertion;
@@ -52,6 +53,8 @@ import java.util.Set;
import java.util.function.Supplier;
import java.util.stream.Collectors;
+import static com.yahoo.yolean.Exceptions.uncheck;
+
/**
* @author bjorncs
@@ -228,15 +231,7 @@ public class DefaultZmsClient extends ClientBase implements ZmsClient {
@Override
public void updateDomain(AthenzDomain domain, Map<String, Object> attributes) {
for (String attribute : attributes.keySet()) {
- Object attrVal = attributes.get(attribute);
-
- String val = attrVal instanceof String ? "\"" + attrVal.toString() + "\"" : attrVal.toString();
- String domainMeta = """
- {
- "%s": %s
- }
- """
- .formatted(attribute, val);
+ String domainMeta = uncheck(() -> new ObjectMapper().writeValueAsString(Map.of(attribute, attributes.get(attribute))));
HttpUriRequest request = RequestBuilder.put()
.setUri(zmsUrl.resolve("domain/%s/meta/system/%s".formatted(domain.getName(), attribute)))
.setEntity(new StringEntity(domainMeta, ContentType.APPLICATION_JSON))