Struct ncryptf::Authorization
source · [−]pub struct Authorization {
pub token: Token,
pub salt: Vec<u8>,
pub date: DateTime<Utc>,
pub signature: String,
pub hmac: Vec<u8>,
pub version: Option<i8>,
}Fields
token: Tokensalt: Vec<u8>date: DateTime<Utc>signature: Stringhmac: Vec<u8>version: Option<i8>Implementations
sourceimpl Authorization
impl Authorization
sourcepub fn from(
method: String,
uri: String,
token: Token,
date: DateTime<Utc>,
payload: String,
salt: Option<Vec<u8>>,
version: Option<i8>
) -> Result<Self, Error>
pub fn from(
method: String,
uri: String,
token: Token,
date: DateTime<Utc>,
payload: String,
salt: Option<Vec<u8>>,
version: Option<i8>
) -> Result<Self, Error>
Generates an Authorization struct from the given parameters
sourcepub fn get_date_string(&self) -> String
pub fn get_date_string(&self) -> String
Returns the date as a string
sourcepub fn get_encoded_hmac(&self) -> String
pub fn get_encoded_hmac(&self) -> String
Returns the base64 encoded HMAC
sourcepub fn get_encoded_salt(&self) -> String
pub fn get_encoded_salt(&self) -> String
Returns the base64 encoded salt
sourcepub fn get_signature_string(&self) -> String
pub fn get_signature_string(&self) -> String
Returns the signature string
sourcepub fn get_time_drift(date: DateTime<Utc>) -> i32
pub fn get_time_drift(date: DateTime<Utc>) -> i32
Returns the time drift between the current time and the provided time
sourcepub fn verify(&self, hmac: Vec<u8>, drift_allowance: i32) -> bool
pub fn verify(&self, hmac: Vec<u8>, drift_allowance: i32) -> bool
Verifies whether or not a given HMAC is equal to the one on record This comparison occurs in constant time to avoid timing attack
sourcepub fn get_header(&self) -> String
pub fn get_header(&self) -> String
Returns the authorization header as a string
sourcepub fn extract_params_from_header_string(
header: String
) -> Result<AuthParams, Error>
pub fn extract_params_from_header_string(
header: String
) -> Result<AuthParams, Error>
Extracts the parameters from the header string
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Authorization
impl Send for Authorization
impl Sync for Authorization
impl Unpin for Authorization
impl UnwindSafe for Authorization
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
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