pub struct ContractValidator { /* private fields */ }Expand description
The object that will collect the contracts and provide the functionality to validate incoming requests.
Implementations§
Source§impl ContractValidator
impl ContractValidator
Sourcepub const INITIALIZATION_PERIOD: Duration
pub const INITIALIZATION_PERIOD: Duration
Initial updating interval for calling ContractValidator::update_contracts().
Sourcepub const UPDATE_PERIOD: Duration = CONTRACTS_FETCHING_INTERVAL
pub const UPDATE_PERIOD: Duration = CONTRACTS_FETCHING_INTERVAL
Remaining updating interval for calling ContractValidator::update_contracts().
Validates if client_id credential can be authorized in the current API contract.
If the validation is succesful, this method returns the ClientData of client_id.
Otherwise an AuthorizationError is returned.
Sourcepub fn authenticate(
&self,
client_id: &ClientId,
client_secret: &ClientSecret,
) -> Result<ClientData, AuthenticationError>
pub fn authenticate( &self, client_id: &ClientId, client_secret: &ClientSecret, ) -> Result<ClientData, AuthenticationError>
Validates if client_id and client_secret credentials can be authenticated
in the current API contract.
If the validation is succesful, this method returns the ClientData of client_id.
Otherwise an AuthenticationError is returned.
Sourcepub fn is_ready(&self) -> bool
pub fn is_ready(&self) -> bool
Returns true if contracts have been pulled and are available locally.
This method can be used to determine if the ContractValidator is ready
for authorization and authentication operations.
Sourcepub async fn update_contracts(&self) -> Result<(), UpdateError>
pub async fn update_contracts(&self) -> Result<(), UpdateError>
Updates local contracts database. This method is intended to be called periodically in order to keep the local contracts database up to date. During initialization time, this method should be invoked in a period of ContractValidator::INITIALIZATION_PERIOD. After initialization, this method should be invoked in a period of ContractValidator::UPDATE_PERIOD.