TPMTPublicDeserializer extends StdDeserializer<TPMTPublic> { @Override public TPMTPublic deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { byte[] value = p.getBinaryValue(); try { return deserialize(value); } catch (IllegalArgumentException e) { throw new InvalidFormatException(p, "input byte array contains surplus data", value, TPMTPublic.class); } } TPMTPublicDeserializer(); @Override TPMTPublic deserialize(JsonParser p, DeserializationContext ctxt);  }
@Test void deserialize_test() throws IOException { String input = "AAEACwAGBHIAIJ3/y/NsODrmmfuYaNxty4nXFTiEvigDkiwSQVi/rSKuABAAEAgAAAAAAAEAxdpvTZNXveIC9cVYzQoxVtJU8uCtmrV5MfmCa3R94axPKdYHCHTc5XkQ4ZhESZ2OQkcDObFw0CK1AauI6cL07TAuRxnHDevohCQD7ZvfwicwphobcPYWxfG3AMrPeEYTfcSy1Gmo4VqrT62GVwhAItKPRNkHUyMSa3AHyYGTn99yTK9PvkdQQEMaTqBkQwvLLPrX0Fvbn2S1sOCVLs+GeSc9bG36gWAfFFAzFqE9B4LDGj5r3e09e8Rrwfqb7w3/g7ferxRrWCxGRIIaPGLtuqa+QivwTkPtr1/TeDCGFT1zYaIDBhpimKsm4TN8ocntBnQaWQVHeYjnIDBOrhidfw"; byte[] inputBytes = Base64Util.decode(input); TPMTPublic value = deserializer.deserialize(inputBytes); assertThat(value.getBytes()).isEqualTo(inputBytes); }