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>,
    {
        (|| -> anyhow::Result<(JwtPayload, JwsHeader)> {
            let (payload, header) =
                self.jws_context
                    .deserialize_compact_with_selector(input, |header| {
                        (|| -> anyhow::Result<Option<&'a dyn JwsVerifier>> {
                            let verifier = match selector(&header)? {
                                Some(val) => val,
                                None => return Ok(None),
                            };

                            if self.is_acceptable_critical("b64") {
                                bail!("JWT is not supported b64 header claim.");
                            }

                            Ok(Some(verifier))
                        })()
                        .map_err(|err| {
                            match err.downcast::<JoseError>() {
                                Ok(err) => err,
                                Err(err) => JoseError::InvalidJwtFormat(err),
                            }
                        })
                    })?;

            let payload: Map<String, Value> = serde_json::from_slice(&payload)?;
            let payload = JwtPayload::from_map(payload)?;

            Ok((payload, header))
        })()
        .map_err(|err| match err.downcast::<JoseError>() {
            Ok(err) => err,
            Err(err) => JoseError::InvalidJwtFormat(err),
        })
    }
/// Return the JWT object decoded with a selected verifying algorithm.
///
/// # Arguments
///
/// * `input` - a JWT string representation.
/// * `selector` - a function for selecting the verifying algorithm.
Return the JWT object decoded with a selected verifying algorithm.
Return the JWT object decoded with a selected verifying algorithm .
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>,
    {
        (|| -> anyhow::Result<(JwtPayload, JwsHeader)> {
            let (payload, header) =
                self.jws_context
                    .deserialize_compact_with_selector(input, |header| {
                        (|| -> anyhow::Result<Option<&'a dyn JwsVerifier>> {
                            let verifier = match selector(&header)? {
                                Some(val) => val,
                                None => return Ok(None),
                            };
                            if self.is_acceptable_critical("b64") {
                                bail!("JWT is not supported b64 header claim.");
                            }
                            Ok(Some(verifier))
                        })()
                        .map_err(|err| {
                            match err.downcast::<JoseError>() {
                                Ok(err) => err,
                                Err(err) => JoseError::InvalidJwtFormat(err),
                            }
                        })
                    })?;
            let payload: Map<String, Value> = serde_json::from_slice(&payload)?;
            let payload = JwtPayload::from_map(payload)?;
            Ok((payload, header))
        })()
        .map_err(|err| match err.downcast::<JoseError>() {
            Ok(err) => err,
            Err(err) => JoseError::InvalidJwtFormat(err),
        })
    }
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 > , { ( | | -> anyhow :: Result < ( JwtPayload , JwsHeader ) > { let ( payload , header ) = self . jws_context . deserialize_compact_with_selector ( input , | header | { ( | | -> anyhow :: Result < Option < & ' a dyn JwsVerifier > > { let verifier = match selector ( & header ) ? { Some ( val ) => val , None => return Ok ( None ) , } ; if self . is_acceptable_critical ( " " ) { bail ! ( " " ) ; } Ok ( Some ( verifier ) ) } ) ( ) . map_err ( | err | { match err . downcast :: < JoseError > ( ) { Ok ( err ) => err , Err ( err ) => JoseError :: InvalidJwtFormat ( err ) , } } ) } ) ? ; let payload : Map < String , Value > = serde_json :: from_slice ( & payload ) ? ; let payload = JwtPayload :: from_map ( payload ) ? ; Ok ( ( payload , header ) ) } ) ( ) . map_err ( | err | match err . downcast :: < JoseError > ( ) { Ok ( err ) => err , Err ( err ) => JoseError :: InvalidJwtFormat ( err ) , } ) }
Return the JWT object decoded with a selected verifying algorithm.
Return the JWT object decoded with a selected verifying algorithm .
&self
input
impl AsRef<[u8]>
selector
F
&self
input
impl AsRef<[u8]>
selector
F