Skip to content

Commit

Permalink
Design sketch: ValidationError as trait
Browse files Browse the repository at this point in the history
  • Loading branch information
scouten-adobe committed Nov 22, 2024
1 parent 2df2f1d commit f550f50
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
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>>;
}

0 comments on commit f550f50

Please sign in to comment.