CleartextKeysetHandle { public static void write(KeysetHandle handle, KeysetWriter keysetWriter) throws IOException { keysetWriter.write(handle.getKeyset()); }  @Deprecated static final KeysetHandle parseFrom(final byte[] serialized); static KeysetHandle read(KeysetReader reader); static Keyset getKeyset(KeysetHandle keysetHandle); static KeysetHandle fromKeyset(Keyset keyset); static void write(KeysetHandle handle, KeysetWriter keysetWriter);  }
@Test public void testWrite() throws Exception { KeyTemplate template = MacKeyTemplates.HMAC_SHA256_128BITTAG; KeysetHandle handle = KeysetManager.withEmptyKeyset().rotate(template).getKeysetHandle(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); KeysetWriter writer = BinaryKeysetWriter.withOutputStream(outputStream); CleartextKeysetHandle.write(handle, writer); ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray()); KeysetReader reader = BinaryKeysetReader.withInputStream(inputStream); KeysetHandle handle2 = CleartextKeysetHandle.read(reader); assertEquals(handle.getKeyset(), handle2.getKeyset()); }