All Downloads are FREE. Search and download functionalities are using the official Maven repository.

id.unum.facade.rest.serialization.PublicKeyInfoDeserializer Maven / Gradle / Ivy

The newest version!
package id.unum.facade.rest.serialization;

import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.util.JsonFormat;
import id.unum.protos.crypto.v1.PublicKeyInfo;
import id.unum.protos.didDocument.v1.DidDocument;
import lombok.extern.log4j.Log4j2;

import java.lang.reflect.Type;

@Log4j2
public class PublicKeyInfoDeserializer implements JsonDeserializer {
    @Override
    public PublicKeyInfo deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
        log.info("starting deserialization of PublicKeyInfo");
        PublicKeyInfo.Builder builder = PublicKeyInfo.newBuilder();
        try {
            log.info("starting deserialization of PublicKeyInfo. in Try");
            log.info("json " + jsonElement);
            JsonFormat.parser().ignoringUnknownFields().merge(jsonElement.toString(), builder);
            log.info("starting deserialization of PublicKeyInfo. after proto parser");
        } catch (InvalidProtocolBufferException e) {
            log.error("Issue deserializing PublicKeyInfo: " + e.getMessage());
            e.printStackTrace();
        }

        log.info("starting deserialization of PublicKeyInfo. before build");
        return builder.build();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy