public static String validateKmsKeyUriAndRemovePrefix(String expectedPrefix, String kmsKeyUri) {
    if (!kmsKeyUri.toLowerCase(Locale.US).startsWith(expectedPrefix)) {
      throw new IllegalArgumentException(
          String.format("key URI must start with %s", expectedPrefix));
    }
    return kmsKeyUri.substring(expectedPrefix.length());
  }
Validates that {@code kmsKeyUri} starts with {@code expectedPrefix}, and removes the prefix.

@throws IllegalArgumentException if {@code kmsKeyUri} is invalid.
java_src/src/main/java/com/google/crypto/tink/subtle/Validators.java