public JwtHmacKey build() throws GeneralSecurityException {
      if (!parameters.isPresent()) {
        throw new GeneralSecurityException("Parameters are required");
      }
      if (!keyBytes.isPresent()) {
        throw new GeneralSecurityException("KeyBytes are required");
      }

      if (parameters.get().getKeySizeBytes() != keyBytes.get().size()) {
        throw new GeneralSecurityException("Key size mismatch");
      }

      if (parameters.get().hasIdRequirement() && !idRequirement.isPresent()) {
        throw new GeneralSecurityException(
            "Cannot create key without ID requirement with parameters with ID requirement");
      }

      if (!parameters.get().hasIdRequirement() && idRequirement.isPresent()) {
        throw new GeneralSecurityException(
            "Cannot create key with ID requirement with parameters without ID requirement");
      }

      return new JwtHmacKey(parameters.get(), keyBytes.get(), idRequirement, computeKid());
    }
Helps creating new {@code JwtHmacKey} objects.
java_src/src/main/java/com/google/crypto/tink/jwt/JwtHmacKey.java