public static synchronized <P> void registerKeyManager(
      final KeyManager<P> manager, boolean newKeyAllowed) throws GeneralSecurityException {
    if (manager == null) {
      throw new IllegalArgumentException("key manager must be non-null.");
    }
    if (!ALLOWED_PRIMITIVES.contains(manager.getPrimitiveClass())) {
      throw new GeneralSecurityException(
          "Registration of key managers for class "
              + manager.getPrimitiveClass()
              + " has been disabled. Please file an issue on"
              + " https://github.com/tink-crypto/tink-java");
    }
    if (!TinkFipsUtil.AlgorithmFipsCompatibility.ALGORITHM_NOT_FIPS.isCompatible()) {
      throw new GeneralSecurityException("Registering key managers is not supported in FIPS mode");
    }
    KeyManagerRegistry.globalInstance().registerKeyManager(manager, newKeyAllowed);
  }
Tries to register {@code manager} for {@code manager.getKeyType()}. If {@code newKeyAllowed} is
true, users can generate new keys with this manager using the {@link Registry#newKey} methods.

<p>If there is an existing key manager, throws an exception if {@code manager} and the existing
key manager aren't instances of the same class, or if {@code newKeyAllowed} is true while the
existing key manager could not create new keys. Otherwise registration succeeds.

@throws GeneralSecurityException if there's an existing key manager is not an instance of the
    class of {@code manager}, or the registration tries to re-enable the generation of new
    keys.
java_src/src/main/java/com/google/crypto/tink/Registry.java