blob: 106dc2850961971f5a83b4606149bab7c4584cea [file]
// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef THIRD_PARTY_CREDENTIO_CLAIM_MANIFEST_BOX_ASSEMBLER_H_
#define THIRD_PARTY_CREDENTIO_CLAIM_MANIFEST_BOX_ASSEMBLER_H_
#include "absl/log/die_if_null.h"
#include "absl/status/statusor.h"
#include "claim/manifest_box.h"
#include "constants/spec_version.h"
#include "crypto/hash.h"
#include "proto/generator.pb.h"
#include "uuid/uuid.h"
namespace credentio {
class ManifestBoxAssembler {
public:
virtual ~ManifestBoxAssembler() = default;
// Assembles a manifest box from the given request.
virtual absl::StatusOr<ManifestBox> Assemble(
const GenerateManifestStoreRequest& request) const = 0;
};
class StandardManifestBoxAssembler : public ManifestBoxAssembler {
public:
// `spec_version` is the C2PA specification version the generated manifests
// conform to. It gates spec-version-dependent features.
explicit StandardManifestBoxAssembler(
const UuidGenerator* uuid_generator, const HasherFactory* hash_factory,
SpecVersion spec_version = SpecVersion::kC2pa_2_2)
: uuid_generator_(*ABSL_DIE_IF_NULL(uuid_generator)),
hash_factory_(*ABSL_DIE_IF_NULL(hash_factory)),
spec_version_(spec_version) {}
~StandardManifestBoxAssembler() override = default;
absl::StatusOr<ManifestBox> Assemble(
const GenerateManifestStoreRequest& request) const override;
private:
class AssembleOp;
const UuidGenerator& uuid_generator_;
const HasherFactory& hash_factory_;
const SpecVersion spec_version_;
};
} // namespace credentio
#endif // THIRD_PARTY_CREDENTIO_CLAIM_MANIFEST_BOX_ASSEMBLER_H_