@SuppressWarnings("UnusedException")
  private static AesCmacKey parseKey(
      ProtoKeySerialization serialization, @Nullable SecretKeyAccess access)
      throws GeneralSecurityException {
    if (!serialization.getTypeUrl().equals(TYPE_URL)) {
      throw new IllegalArgumentException(
          "Wrong type URL in call to AesCmacProtoSerialization.parseKey");
    }
    try {
      com.google.crypto.tink.proto.AesCmacKey protoKey =
          com.google.crypto.tink.proto.AesCmacKey.parseFrom(
              serialization.getValue(), ExtensionRegistryLite.getEmptyRegistry());
      if (protoKey.getVersion() != 0) {
        throw new GeneralSecurityException("Only version 0 keys are accepted");
      }
      AesCmacParameters parameters =
          AesCmacParameters.builder().setKeySizeBytes(protoKey.getKeyValue().size())
              .setTagSizeBytes(protoKey.getParams().getTagSize())
              .setVariant(toVariant(serialization.getOutputPrefixType())).build();
      return AesCmacKey.builder()
          .setParameters(parameters)
          .setAesKeyBytes(SecretBytes.copyFrom(
                protoKey.getKeyValue().toByteArray(), SecretKeyAccess.requireAccess(access)))
          .setIdRequirement(serialization.getIdRequirementOrNull())
          .build();
    } catch (InvalidProtocolBufferException | IllegalArgumentException e) {
      throw new GeneralSecurityException("Parsing AesCmacKey failed");
    }
  }
Methods to serialize and parse {@link AesCmacKey} objects and {@link AesCmacParameters} objects.
java_src/src/main/java/com/google/crypto/tink/mac/internal/AesCmacProtoSerialization.java