Struct josekit::jwt::JwtContext

source ·
pub struct JwtContext { /* private fields */ }

Implementations§

source§

impl JwtContext

source

pub fn new() -> Self

source

pub fn is_acceptable_critical(&self, name: &str) -> bool

Test a critical header claim name is acceptable.

§Arguments
  • name - a critical header claim name
source

pub fn add_acceptable_critical(&mut self, name: &str)

Add a acceptable critical header claim name

§Arguments
  • name - a acceptable critical header claim name
source

pub fn remove_acceptable_critical(&mut self, name: &str)

Remove a acceptable critical header claim name

§Arguments
  • name - a acceptable critical header claim name
source

pub fn encode_unsecured( &self, payload: &JwtPayload, header: &JwsHeader ) -> Result<String, JoseError>

Return the string repsentation of the JWT with a “none” algorithm.

§Arguments
  • payload - The payload data.
  • header - The JWT heaser claims.
source

pub fn encode_with_signer( &self, payload: &JwtPayload, header: &JwsHeader, signer: &dyn JwsSigner ) -> Result<String, JoseError>

Return the string repsentation of the JWT with the siginig algorithm.

§Arguments
  • payload - The payload data.
  • header - The JWS heaser claims.
  • signer - a signer object.
source

pub fn encode_with_encrypter( &self, payload: &JwtPayload, header: &JweHeader, encrypter: &dyn JweEncrypter ) -> Result<String, JoseError>

Return the string repsentation of the JWT with the encrypting algorithm.

§Arguments
  • payload - The payload data.
  • header - The JWE heaser claims.
  • encrypter - a encrypter object.
source

pub fn decode_header( &self, input: impl AsRef<[u8]> ) -> Result<Box<dyn JoseHeader>, JoseError>

Return the Jose header decoded from JWT.

§Arguments
  • input - a JWT string representation.
source

pub fn decode_unsecured( &self, input: impl AsRef<[u8]> ) -> Result<(JwtPayload, JwsHeader), JoseError>

Return the JWT object decoded with the “none” algorithm.

§Arguments
  • input - a JWT string representation.
source

pub fn decode_with_verifier( &self, input: impl AsRef<[u8]>, verifier: &dyn JwsVerifier ) -> Result<(JwtPayload, JwsHeader), JoseError>

Return the JWT object decoded by the selected verifier.

§Arguments
  • verifier - a verifier of the signing algorithm.
  • input - a JWT string representation.
source

pub fn decode_with_verifier_selector<'a, F>( &self, input: impl AsRef<[u8]>, selector: F ) -> Result<(JwtPayload, JwsHeader), JoseError>
where F: Fn(&JwsHeader) -> Result<Option<&'a dyn JwsVerifier>, JoseError>,

Return the JWT object decoded with a selected verifying algorithm.

§Arguments
  • input - a JWT string representation.
  • selector - a function for selecting the verifying algorithm.
source

pub fn decode_with_verifier_in_jwk_set<F>( &self, input: impl AsRef<[u8]>, jwk_set: &JwkSet, selector: F ) -> Result<(JwtPayload, JwsHeader), JoseError>
where F: Fn(&Jwk) -> Result<Option<&dyn JwsVerifier>, JoseError>,

Return the JWT object decoded by using a JWK set.

§Arguments
  • input - a JWT string representation.
  • jwk_set - a JWK set.
  • selector - a function for selecting the verifying algorithm.
source

pub fn decode_with_decrypter( &self, input: impl AsRef<[u8]>, decrypter: &dyn JweDecrypter ) -> Result<(JwtPayload, JweHeader), JoseError>

Return the JWT object decoded by the selected decrypter.

§Arguments
  • input - a JWT string representation.
  • decrypter - a decrypter of the decrypting algorithm.
source

pub fn decode_with_decrypter_selector<'a, F>( &self, input: impl AsRef<[u8]>, selector: F ) -> Result<(JwtPayload, JweHeader), JoseError>
where F: Fn(&JweHeader) -> Result<Option<&'a dyn JweDecrypter>, JoseError>,

Return the JWT object decoded with a selected decrypting algorithm.

§Arguments
  • input - a JWT string representation.
  • decrypter_selector - a function for selecting the decrypting algorithm.
source

pub fn decode_with_decrypter_in_jwk_set<F>( &self, input: impl AsRef<[u8]>, jwk_set: &JwkSet, selector: F ) -> Result<(JwtPayload, JweHeader), JoseError>
where F: Fn(&Jwk) -> Result<Option<&dyn JweDecrypter>, JoseError>,

Return the JWT object decoded by using a JWK set.

§Arguments
  • input - a JWT string representation.
  • jwk_set - a JWK set.
  • selector - a function for selecting the decrypting algorithm.

Trait Implementations§

source§

impl Clone for JwtContext

source§

fn clone(&self) -> JwtContext

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for JwtContext

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for JwtContext

source§

fn eq(&self, other: &JwtContext) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for JwtContext

source§

impl StructuralPartialEq for JwtContext

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.