@Test public void testRegisterKeyType_NoCatalogue_shouldThrowException() throws Exception { KeyTypeEntry entry = KeyTypeEntry.newBuilder().setCatalogueName("DoesNotExist").build(); try { Config.registerKeyType(entry); fail("Expected GeneralSecurityException"); } catch (GeneralSecurityException e) { } }
public static void registerKeyType(KeyTypeEntry entry) throws GeneralSecurityException { validate(entry); if (entry.getCatalogueName().equals("TinkAead") || entry.getCatalogueName().equals("TinkMac") || entry.getCatalogueName().equals("TinkHybridDecrypt") || entry.getCatalogueName().equals("TinkHybridEncrypt") || entry.getCatalogueName().equals("TinkPublicKeySign") || entry.getCatalogueName().equals("TinkPublicKeyVerify") || entry.getCatalogueName().equals("TinkStreamingAead") || entry.getCatalogueName().equals("TinkDeterministicAead")) { return; } Catalogue<?> catalogue = Registry.getCatalogue(entry.getCatalogueName()); Registry.registerPrimitiveWrapper(catalogue.getPrimitiveWrapper()); KeyManager<?> keyManager = catalogue.getKeyManager( entry.getTypeUrl(), entry.getPrimitiveName(), entry.getKeyManagerVersion()); Registry.registerKeyManager(keyManager, entry.getNewKeyAllowed()); }
Config { public static void registerKeyType(KeyTypeEntry entry) throws GeneralSecurityException { validate(entry); if (entry.getCatalogueName().equals("TinkAead") || entry.getCatalogueName().equals("TinkMac") || entry.getCatalogueName().equals("TinkHybridDecrypt") || entry.getCatalogueName().equals("TinkHybridEncrypt") || entry.getCatalogueName().equals("TinkPublicKeySign") || entry.getCatalogueName().equals("TinkPublicKeyVerify") || entry.getCatalogueName().equals("TinkStreamingAead") || entry.getCatalogueName().equals("TinkDeterministicAead")) { return; } Catalogue<?> catalogue = Registry.getCatalogue(entry.getCatalogueName()); Registry.registerPrimitiveWrapper(catalogue.getPrimitiveWrapper()); KeyManager<?> keyManager = catalogue.getKeyManager( entry.getTypeUrl(), entry.getPrimitiveName(), entry.getKeyManagerVersion()); Registry.registerKeyManager(keyManager, entry.getNewKeyAllowed()); } }
Config { public static void registerKeyType(KeyTypeEntry entry) throws GeneralSecurityException { validate(entry); if (entry.getCatalogueName().equals("TinkAead") || entry.getCatalogueName().equals("TinkMac") || entry.getCatalogueName().equals("TinkHybridDecrypt") || entry.getCatalogueName().equals("TinkHybridEncrypt") || entry.getCatalogueName().equals("TinkPublicKeySign") || entry.getCatalogueName().equals("TinkPublicKeyVerify") || entry.getCatalogueName().equals("TinkStreamingAead") || entry.getCatalogueName().equals("TinkDeterministicAead")) { return; } Catalogue<?> catalogue = Registry.getCatalogue(entry.getCatalogueName()); Registry.registerPrimitiveWrapper(catalogue.getPrimitiveWrapper()); KeyManager<?> keyManager = catalogue.getKeyManager( entry.getTypeUrl(), entry.getPrimitiveName(), entry.getKeyManagerVersion()); Registry.registerKeyManager(keyManager, entry.getNewKeyAllowed()); }  }
Config { public static void registerKeyType(KeyTypeEntry entry) throws GeneralSecurityException { validate(entry); if (entry.getCatalogueName().equals("TinkAead") || entry.getCatalogueName().equals("TinkMac") || entry.getCatalogueName().equals("TinkHybridDecrypt") || entry.getCatalogueName().equals("TinkHybridEncrypt") || entry.getCatalogueName().equals("TinkPublicKeySign") || entry.getCatalogueName().equals("TinkPublicKeyVerify") || entry.getCatalogueName().equals("TinkStreamingAead") || entry.getCatalogueName().equals("TinkDeterministicAead")) { return; } Catalogue<?> catalogue = Registry.getCatalogue(entry.getCatalogueName()); Registry.registerPrimitiveWrapper(catalogue.getPrimitiveWrapper()); KeyManager<?> keyManager = catalogue.getKeyManager( entry.getTypeUrl(), entry.getPrimitiveName(), entry.getKeyManagerVersion()); Registry.registerKeyManager(keyManager, entry.getNewKeyAllowed()); }  static KeyTypeEntry getTinkKeyTypeEntry(
      String catalogueName,
      String primitiveName,
      String keyProtoName,
      int keyManagerVersion,
      boolean newKeyAllowed); static void register(RegistryConfig config); static void registerKeyType(KeyTypeEntry entry); }
Config { public static void registerKeyType(KeyTypeEntry entry) throws GeneralSecurityException { validate(entry); if (entry.getCatalogueName().equals("TinkAead") || entry.getCatalogueName().equals("TinkMac") || entry.getCatalogueName().equals("TinkHybridDecrypt") || entry.getCatalogueName().equals("TinkHybridEncrypt") || entry.getCatalogueName().equals("TinkPublicKeySign") || entry.getCatalogueName().equals("TinkPublicKeyVerify") || entry.getCatalogueName().equals("TinkStreamingAead") || entry.getCatalogueName().equals("TinkDeterministicAead")) { return; } Catalogue<?> catalogue = Registry.getCatalogue(entry.getCatalogueName()); Registry.registerPrimitiveWrapper(catalogue.getPrimitiveWrapper()); KeyManager<?> keyManager = catalogue.getKeyManager( entry.getTypeUrl(), entry.getPrimitiveName(), entry.getKeyManagerVersion()); Registry.registerKeyManager(keyManager, entry.getNewKeyAllowed()); }  static KeyTypeEntry getTinkKeyTypeEntry(
      String catalogueName,
      String primitiveName,
      String keyProtoName,
      int keyManagerVersion,
      boolean newKeyAllowed); static void register(RegistryConfig config); static void registerKeyType(KeyTypeEntry entry);  }