Util { public static KeysetInfo getKeysetInfo(Keyset keyset) { KeysetInfo.Builder info = KeysetInfo.newBuilder().setPrimaryKeyId(keyset.getPrimaryKeyId()); for (Keyset.Key key : keyset.getKeyList()) { info.addKeyInfo(getKeyInfo(key)); } return info.build(); }  static KeysetInfo getKeysetInfo(Keyset keyset); static KeysetInfo.KeyInfo getKeyInfo(Keyset.Key key); static void validateKey(Keyset.Key key); static void validateKeyset(Keyset keyset); static byte[] readAll(InputStream inputStream); static final Charset UTF_8; }
@Test public void testGetKeysetInfo() throws Exception { String keyValue = "01234567890123456"; Keyset keyset = TestUtil.createKeyset( TestUtil.createKey( TestUtil.createHmacKeyData(keyValue.getBytes("UTF-8"), 16), 42, KeyStatusType.ENABLED, OutputPrefixType.TINK)); assertTrue(keyset.toString().contains(keyValue)); KeysetInfo keysetInfo = Util.getKeysetInfo(keyset); assertFalse(keysetInfo.toString().contains(keyValue)); }