Struct identity_iota::client::CredentialValidator
source · [−]#[non_exhaustive]pub struct CredentialValidator;
Expand description
A struct for validating Credential
s.
Implementations
sourceimpl CredentialValidator
impl CredentialValidator
sourcepub fn validate<T, D>(
credential: &Credential<T>,
issuer: &D,
options: &CredentialValidationOptions,
fail_fast: FailFast
) -> Result<(), CompoundCredentialValidationError> where
T: Serialize,
D: AsRef<IotaDocument>,
pub fn validate<T, D>(
credential: &Credential<T>,
issuer: &D,
options: &CredentialValidationOptions,
fail_fast: FailFast
) -> Result<(), CompoundCredentialValidationError> where
T: Serialize,
D: AsRef<IotaDocument>,
Validates a Credential
.
The following properties are validated according to options
:
- the issuer’s signature,
- the expiration date,
- the issuance date,
- the semantic structure.
Warning
The lack of an error returned from this method is in of itself not enough to conclude that the credential can be trusted. This section contains more information on additional checks that should be carried out before and after calling this method.
The state of the issuer’s DID Document
The caller must ensure that issuer
represents an up-to-date DID Document. The convenience method
Resolver::resolve_credential_issuer
can help extract
the latest available state of the issuer’s DID Document.
Properties that are not validated
There are many properties defined in The Verifiable Credentials Data Model that are not validated, such as:
credentialStatus
, type
, credentialSchema
, refreshService
, and more.
These should be manually checked after validation, according to your requirements.
Errors
An error is returned whenever a validated condition is not satisfied.
sourcepub fn check_structure<T>(
credential: &Credential<T>
) -> Result<(), ValidationError>
pub fn check_structure<T>(
credential: &Credential<T>
) -> Result<(), ValidationError>
Validates the semantic structure of the Credential
.
Warning
This does not validate against the credential’s schema nor the structure of the subject claims.
sourcepub fn check_expires_on_or_after<T>(
credential: &Credential<T>,
timestamp: Timestamp
) -> Result<(), ValidationError>
pub fn check_expires_on_or_after<T>(
credential: &Credential<T>,
timestamp: Timestamp
) -> Result<(), ValidationError>
Validate that the Credential
expires on or after the specified Timestamp
.
sourcepub fn check_issued_on_or_before<T>(
credential: &Credential<T>,
timestamp: Timestamp
) -> Result<(), ValidationError>
pub fn check_issued_on_or_before<T>(
credential: &Credential<T>,
timestamp: Timestamp
) -> Result<(), ValidationError>
Validate that the Credential
is issued on or before the specified Timestamp
.
sourcepub fn verify_signature<T, D>(
credential: &Credential<T>,
trusted_issuers: &[D],
options: &VerifierOptions
) -> Result<(), ValidationError> where
T: Serialize,
D: AsRef<IotaDocument>,
pub fn verify_signature<T, D>(
credential: &Credential<T>,
trusted_issuers: &[D],
options: &VerifierOptions
) -> Result<(), ValidationError> where
T: Serialize,
D: AsRef<IotaDocument>,
Verify the signature using the DID Document of a trusted issuer.
Warning
The caller must ensure that the DID Documents of the trusted issuers are up-to-date.
Errors
This method immediately returns an error if the credential issuer’ url cannot be parsed to a DID belonging to one of the trusted issuers. Otherwise an attempt to verify the credential’s signature will be made and an error is returned upon failure.
sourcepub fn check_subject_holder_relationship<T>(
credential: &Credential<T>,
holder: &Url,
relationship: SubjectHolderRelationship
) -> Result<(), ValidationError>
pub fn check_subject_holder_relationship<T>(
credential: &Credential<T>,
holder: &Url,
relationship: SubjectHolderRelationship
) -> Result<(), ValidationError>
Validate that the relationship between the holder
and the credential subjects is in accordance with
relationship
.
sourcepub fn check_status<T, D>(
credential: &Credential<T>,
trusted_issuers: &[D],
status_check: StatusCheck
) -> Result<(), ValidationError> where
D: AsRef<IotaDocument>,
pub fn check_status<T, D>(
credential: &Credential<T>,
trusted_issuers: &[D],
status_check: StatusCheck
) -> Result<(), ValidationError> where
D: AsRef<IotaDocument>,
Checks whether the credential status has been revoked.
Only supports BitmapRevocation2022
.
Trait Implementations
sourceimpl Clone for CredentialValidator
impl Clone for CredentialValidator
sourcefn clone(&self) -> CredentialValidator
fn clone(&self) -> CredentialValidator
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl RefUnwindSafe for CredentialValidator
impl Send for CredentialValidator
impl Sync for CredentialValidator
impl Unpin for CredentialValidator
impl UnwindSafe for CredentialValidator
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more