1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//! Error types.
use serde::{Deserialize, Serialize};
use std::fmt;
#[derive(Debug, Serialize, Clone, Deserialize, PartialEq)]
/// An error in the JWT library
pub enum JwtError {
/// Invalid Token - May not be in correct compact form
InvalidCompactFormat,
/// Invalid Base64 encodidng of the token content
InvalidBase64,
/// Invalid token header
InvalidHeaderFormat,
/// Invalid signature over the header and payload
InvalidSignature,
/// Invalid JWT content
InvalidJwt,
/// Invalid PRT content
InvalidPRT,
/// Invalid Critical Extension present
CriticalExtension,
/// OpenSSL failure
OpenSSLError,
/// Cryptographic Failure
CryptoError,
/// Tpm Failure
TpmError,
/// Incorrect Algorithm for verification
ValidatorAlgMismatch,
/// Invalid JWT Key ID
InvalidJwtKid,
/// The listed JweEnc type is not valid for the type of inner
/// decryption key we recieved
JweEncMismatch,
/// The Token has expired
OidcTokenExpired,
/// No embeded JWK is available
EmbededJwkNotAvailable,
/// Jwk public key export denied
JwkPublicKeyDenied,
/// X5c public key's cert chain didn't validate
X5cPublicKeyDenied,
/// Private key export denied
PrivateKeyDenied,
/// No leaf certificate is available in the chain
X5cChainMissingLeaf,
/// The provided x5c chain is not trusted
X5cChainNotTrusted,
/// The provided key was not valid
InvalidKey,
/// A required header value is not set
CriticalMissingHeaderValue,
/// The requested JWE cipher is not available.
CipherUnavailable,
/// The JWE algorithm does not match this decipher.
AlgorithmUnavailable,
/// The request to release the key is unable to be satisfied.
UnableToReleaseKey,
/// Serialisation / Deserialisation error
Serde,
}
impl fmt::Display for JwtError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{self:?}")
}
}
impl std::error::Error for JwtError {}