Function dcaf::token::get_token_headers
source · pub fn get_token_headers(
token: &ByteString
) -> Option<(Header, ProtectedHeader)>
Expand description
Returns the headers of the given signed (CoseSign1
/ CoseSign
),
MAC tagged (CoseMac0
/ CoseMac
), or encrypted (CoseEncrypt0
/ CoseEncrypt
)
access token.
When the given token
is none of those structures mentioned above, None
is returned.
Example
For example, say you have an access token saved in token
and want to look at its headers:
if let Some((unprotected_header, protected_header)) = get_token_headers(&token) {
assert_eq!(protected_header.header.key_id, vec![0x84, 0x9b, 0x57, 0x86, 0x45, 0x7c])
} else {
unreachable!("Example token should be valid.")
}