From 31db959a46dc6873b4e9e4e13971d49668224d37 Mon Sep 17 00:00:00 2001 From: Graham Date: Sat, 13 Feb 2021 10:36:03 +0000 Subject: [PATCH] Add XteaKeyDeserializer Signed-off-by: Graham --- .../kotlin/org/openrs2/crypto/CryptoJacksonModule.kt | 1 + .../kotlin/org/openrs2/crypto/XteaKeyDeserializer.kt | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 crypto/src/main/kotlin/org/openrs2/crypto/XteaKeyDeserializer.kt diff --git a/crypto/src/main/kotlin/org/openrs2/crypto/CryptoJacksonModule.kt b/crypto/src/main/kotlin/org/openrs2/crypto/CryptoJacksonModule.kt index 35c866d5d2..1d0c4f0cca 100644 --- a/crypto/src/main/kotlin/org/openrs2/crypto/CryptoJacksonModule.kt +++ b/crypto/src/main/kotlin/org/openrs2/crypto/CryptoJacksonModule.kt @@ -6,6 +6,7 @@ import javax.inject.Singleton @Singleton public class CryptoJacksonModule : SimpleModule() { init { + addDeserializer(XteaKey::class.java, XteaKeyDeserializer) addSerializer(XteaKey::class.java, XteaKeySerializer) } } diff --git a/crypto/src/main/kotlin/org/openrs2/crypto/XteaKeyDeserializer.kt b/crypto/src/main/kotlin/org/openrs2/crypto/XteaKeyDeserializer.kt new file mode 100644 index 0000000000..4e396f8c9a --- /dev/null +++ b/crypto/src/main/kotlin/org/openrs2/crypto/XteaKeyDeserializer.kt @@ -0,0 +1,11 @@ +package org.openrs2.crypto + +import com.fasterxml.jackson.core.JsonParser +import com.fasterxml.jackson.databind.DeserializationContext +import com.fasterxml.jackson.databind.deser.std.StdDeserializer + +public object XteaKeyDeserializer : StdDeserializer(XteaKey::class.java) { + override fun deserialize(parser: JsonParser, ctx: DeserializationContext): XteaKey { + return XteaKey.fromIntArray(ctx.readValue(parser, IntArray::class.java)) + } +}