pub struct KeyRegistry<K: IsKey> { /* private fields */ }Implementations§
Source§impl KeyRegistry<PrivateKey>
impl KeyRegistry<PrivateKey>
Source§impl KeyRegistry<Key>
impl KeyRegistry<Key>
Source§impl<K: IsKey> KeyRegistry<K>
impl<K: IsKey> KeyRegistry<K>
pub fn into_keys(self) -> impl Iterator<Item = K>
Sourcepub fn add_key(&mut self, key: K)
pub fn add_key(&mut self, key: K)
Add a key to the registry. If the key already exists, it will be replaced. If the key specifies the same kid as another key already added, the new key will replace the old one.
Adding a key, even if it already exists, will make it the active key.
Sourcepub fn remove_key(&mut self, key: &K)
pub fn remove_key(&mut self, key: &K)
Remove a key from the registry by its key.
Sourcepub fn remove_kid(&mut self, kid: &str) -> bool
pub fn remove_kid(&mut self, kid: &str) -> bool
Remove a key from the registry by its kid. Note: O(N).
Sourcepub fn add_from_jwkset(&mut self, jwkset: &str) -> Result<usize, KeyError>
pub fn add_from_jwkset(&mut self, jwkset: &str) -> Result<usize, KeyError>
Add keys from a JWKSet.
Sourcepub fn add_from_any(&mut self, source: &str) -> Result<usize, KeyError>
pub fn add_from_any(&mut self, source: &str) -> Result<usize, KeyError>
Add keys from a source string which can be either a JWK set or a PEM file with 1 or more keys.
pub fn to_pem(&self) -> String
pub fn to_json(&self) -> Result<String, KeyError>
Sourcepub fn unsafely_decode_without_validation(
&self,
token: &str,
) -> Result<HashMap<String, Any>, ValidationError>
pub fn unsafely_decode_without_validation( &self, token: &str, ) -> Result<HashMap<String, Any>, ValidationError>
Decode a token without validating the signature.
pub fn validate( &self, token: &str, ctx: &ValidationContext, ) -> Result<HashMap<String, Any>, ValidationError>
pub fn sign( &self, claims: HashMap<String, Any>, ctx: &SigningContext, ) -> Result<String, SignatureError>
Source§impl KeyRegistry<PrivateKey>
impl KeyRegistry<PrivateKey>
pub fn can_sign(&self) -> bool
pub fn can_validate(&self) -> bool
pub fn has_private_keys(&self) -> bool
pub fn has_public_keys(&self) -> bool
pub fn has_symmetric_keys(&self) -> bool
Source§impl KeyRegistry<PublicKey>
impl KeyRegistry<PublicKey>
pub fn can_sign(&self) -> bool
pub fn can_validate(&self) -> bool
pub fn has_public_keys(&self) -> bool
pub fn has_private_keys(&self) -> bool
pub fn has_symmetric_keys(&self) -> bool
Source§impl KeyRegistry<Key>
impl KeyRegistry<Key>
pub fn can_sign(&self) -> bool
pub fn can_validate(&self) -> bool
pub fn has_private_keys(&self) -> bool
pub fn has_public_keys(&self) -> bool
pub fn has_symmetric_keys(&self) -> bool
Sourcepub fn to_pem_public(&self) -> Result<String, KeyError>
pub fn to_pem_public(&self) -> Result<String, KeyError>
Export the registry as a PEM file containing only the public keys. This will fail if the registry contains symmetric keys.
Sourcepub fn to_json_public(&self) -> Result<String, KeyError>
pub fn to_json_public(&self) -> Result<String, KeyError>
Export the registry as a JSON object containing only the public keys. This will fail if the registry contains symmetric keys.