Skip to content

Commit 868c90f

Browse files
committed
Make MetadataObject not extend JsonSerializable
1 parent 5b506b3 commit 868c90f

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

webauthn-server-core/src/main/java/com/yubico/u2f/attestation/MetadataObject.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,21 @@
88
import com.fasterxml.jackson.core.type.TypeReference;
99
import com.fasterxml.jackson.databind.JsonMappingException;
1010
import com.fasterxml.jackson.databind.JsonNode;
11+
import com.fasterxml.jackson.databind.ObjectMapper;
1112
import com.google.common.base.MoreObjects;
1213
import com.google.common.collect.ImmutableList;
13-
import com.yubico.u2f.data.messages.json.JsonSerializable;
1414
import com.yubico.u2f.exceptions.U2fBadConfigurationException;
15-
import com.yubico.u2f.exceptions.U2fBadInputException;
15+
import com.yubico.webauthn.util.WebAuthnCodecs;
1616
import java.io.IOException;
1717
import java.util.List;
1818
import java.util.Map;
1919
import lombok.EqualsAndHashCode;
2020

2121
@JsonIgnoreProperties(ignoreUnknown = true)
2222
@EqualsAndHashCode(of = { "data" }, callSuper = false)
23-
public class MetadataObject extends JsonSerializable {
23+
public class MetadataObject {
24+
private static final ObjectMapper OBJECT_MAPPER = WebAuthnCodecs.json();
25+
2426
private static final TypeReference<Map<String, String>> MAP_STRING_STRING_TYPE = new TypeReference<Map<String, String>>() {
2527
};
2628
private static final TypeReference LIST_STRING_TYPE = new TypeReference<List<String>>() {
@@ -55,7 +57,6 @@ public MetadataObject(JsonNode data) throws U2fBadConfigurationException {
5557
version = data.get("version").asLong();
5658
}
5759

58-
@Override
5960
public String toJson() {
6061
return data.toString();
6162
}
@@ -100,8 +101,8 @@ public static List<MetadataObject> parseFromJson(String jsonData) throws U2fBadC
100101

101102
public static MetadataObject fromJson(String json) throws U2fBadConfigurationException {
102103
try {
103-
return fromJson(json, MetadataObject.class);
104-
} catch (U2fBadInputException e) {
104+
return OBJECT_MAPPER.readValue(json, MetadataObject.class);
105+
} catch (IOException e) {
105106
throw new U2fBadConfigurationException("Malformed data", e);
106107
}
107108
}

0 commit comments

Comments
 (0)