public static LegacyKmsEnvelopeAeadKey create(
      LegacyKmsEnvelopeAeadParameters parameters, @Nullable Integer idRequirement)
      throws GeneralSecurityException {
    Bytes outputPrefix;
    if (parameters.getVariant() == LegacyKmsEnvelopeAeadParameters.Variant.NO_PREFIX) {
      if (idRequirement != null) {
        throw new GeneralSecurityException(
            "For given Variant NO_PREFIX the value of idRequirement must be null");
      }
      outputPrefix = OutputPrefixUtil.EMPTY_PREFIX;
    } else if (parameters.getVariant() == LegacyKmsEnvelopeAeadParameters.Variant.TINK) {
      if (idRequirement == null) {
        throw new GeneralSecurityException(
            "For given Variant TINK the value of idRequirement must be non-null");
      }
      outputPrefix = OutputPrefixUtil.getTinkOutputPrefix(idRequirement);
    } else {
      throw new GeneralSecurityException("Unknown Variant: " + parameters.getVariant());
    }
    return new LegacyKmsEnvelopeAeadKey(parameters, outputPrefix, idRequirement);
  }
Describes an EnvelopeAead backed by a KMS.

<p>Usage of this key type is not recommended. Instead, we recommend to implement the idea of this
class manually:

<ol>
  <li>Create an remote {@link com.google.crypto.tink.Aead} object for your KMS with an
      appropriate Tink extension (typically using a subclass of {@link
      com.google.crypto.tink.KmsClient}).
  <li>Create an envelope AEAD with {@link com.google.crypto.tink.aead.KmsEnvelopeAead#create}.
</ol>

See {@link LegacyKmsEnvelopeParameters} for known issues.
java_src/src/main/java/com/google/crypto/tink/aead/LegacyKmsEnvelopeAeadKey.java