NoSecretKeysetHandle { @Deprecated public static final KeysetHandle parseFrom(final byte[] serialized) throws GeneralSecurityException { try { Keyset keyset = Keyset.parseFrom(serialized, ExtensionRegistryLite.getEmptyRegistry()); validate(keyset); return KeysetHandle.fromKeyset(keyset); } catch (InvalidProtocolBufferException e) { throw new GeneralSecurityException("invalid keyset"); } }  @Deprecated static final KeysetHandle parseFrom(final byte[] serialized); static final KeysetHandle read(KeysetReader reader);  }
@Test public void testBasic() throws Exception { KeyTemplate template = MacKeyTemplates.HMAC_SHA256_128BITTAG; KeysetManager manager = KeysetManager.withEmptyKeyset().rotate(template); Keyset keyset = manager.getKeysetHandle().getKeyset(); try { KeysetHandle unused = NoSecretKeysetHandle.parseFrom(keyset.toByteArray()); fail("Expected GeneralSecurityException"); } catch (GeneralSecurityException e) { assertExceptionContains(e, "keyset contains secret key material"); } }