Skip to content

Commit d4c706b

Browse files
committed
Disambiguate JSON deserialization of AuthenticatorTransport
This broke in Jackson 2.12.0-rc1, seems like the deserializer somehow started choosing the `valueOf` function instead of the `of` function. At first this seemed like a regression in Jackson, but it was ambiguous on our side either way.
1 parent cf0dc37 commit d4c706b

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Changes:
66
** Unless `RelyingParty.allowUntrustedAttestation` is set to `false`, unknown
77
attestation statements will now pass as untrusted attestations, instead of
88
throwing an IllegalArgumentException.
9+
* Disambiguated Jackson deserialization of class `AuthenticatorTransport`
910

1011
New features:
1112

webauthn-server-core/src/main/java/com/yubico/webauthn/data/AuthenticatorTransport.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
package com.yubico.webauthn.data;
2626

2727

28+
import com.fasterxml.jackson.annotation.JsonCreator;
2829
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
2930
import com.yubico.internal.util.json.JsonStringSerializable;
3031
import com.yubico.internal.util.json.JsonStringSerializer;
@@ -92,6 +93,7 @@ public static AuthenticatorTransport[] values() {
9293
* #INTERNAL}, returns that constant instance. Otherwise returns a new instance containing <code>id</code>.
9394
* @see #valueOf(String)
9495
*/
96+
@JsonCreator
9597
public static AuthenticatorTransport of(@NonNull String id) {
9698
return Stream.of(values())
9799
.filter(v -> v.getId().equals(id))
@@ -114,7 +116,7 @@ public static AuthenticatorTransport valueOf(String name) {
114116
case "BLE": return BLE;
115117
case "INTERNAL": return INTERNAL;
116118
default:
117-
throw new IllegalArgumentException("No enum constant com.yubico.webauthn.data.AuthenticatorTransport." + name);
119+
throw new IllegalArgumentException("No constant com.yubico.webauthn.data.AuthenticatorTransport." + name);
118120
}
119121
}
120122

0 commit comments

Comments
 (0)