Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Design sketch: ValidationError as trait #697

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions internal/crypto/src/ocsp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,11 @@ pub enum OcspError {
CertificateStatusUnknown,
}


impl ValidationError for OcspError {
// ...
}

const DATE_FMT: &str = "%Y-%m-%d %H:%M:%S %Z";

#[cfg(not(target_arch = "wasm32"))]
Expand Down
5 changes: 5 additions & 0 deletions internal/crypto/src/raw_signature/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// each license.

use bcder::Oid;
use c2pa_status_tracker::ValidationError;
use thiserror::Error;

use super::oids::*;
Expand Down Expand Up @@ -164,3 +165,7 @@ impl From<crate::webcrypto::WasmCryptoError> for RawSignatureValidationError {
}
}
}

impl ValidationError for RawSignatureValidationError {
// ...
}
25 changes: 25 additions & 0 deletions internal/status-tracker/src/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2024 Adobe. All rights reserved.
// This file is licensed to you under the Apache License,
// Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
// or the MIT license (http://opensource.org/licenses/MIT),
// at your option.

// Unless required by applicable law or agreed to in writing,
// this software is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or
// implied. See the LICENSE-MIT and LICENSE-APACHE files for the
// specific language governing permissions and limitations under
// each license.

/// A `ValidationError` describes an error that was found when validating a C2PA manifest.
pub trait ValidationError {
/// Returns the C2PA validation code for the error condition.
///
/// May return `None` if the error condition is not described in the C2PA Technical Specification.
fn validation_code(&self) -> Option<Cow<'static, str>>;

/// Returns the JUMBF path to the location where the error condition was identified.
///
/// May return `None` if the error condition does not pertain to a specific box in the manifest store.
fn jumbf_path(&self) -> Option<Cow<'static, str>>;
}
Loading