Java tutorial
/* * echocat Marquardt Java SDK, Copyright (c) 2015 echocat * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ package org.echocat.marquardt.common.serialization; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.ObjectCodec; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonDeserializer; import com.fasterxml.jackson.databind.JsonNode; import org.echocat.marquardt.common.domain.PublicKeyWithMechanism; import java.io.IOException; import java.security.PublicKey; public class PublicKeyDeserializer extends JsonDeserializer<PublicKey> { @Override public PublicKey deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException { final ObjectCodec oc = jsonParser.getCodec(); final JsonNode node = oc.readTree(jsonParser); return new PublicKeyWithMechanism(node.get(PublicKeySerializer.KEY).binaryValue()).toJavaKey(); } }