Struct AgentKeyManager

Source
pub struct AgentKeyManager { /* private fields */ }
Expand description

Agent Key Manager implements the KeyManager trait using the agent key abstraction

Implementations§

Source§

impl AgentKeyManager

Source

pub fn new() -> Self

Create a new key manager

Source

pub async fn get_signing_key_type(&self, did: &str) -> Result<String>

Get the key type for a signing key (for debugging)

Source

pub fn agent_key_from_generated( &self, key: &GeneratedKey, ) -> Result<LocalAgentKey>

Create a LocalAgentKey from a GeneratedKey

Source

pub fn save_to_storage(&self) -> Result<()>

Save keys to storage if a storage path is configured

Source

pub fn load_from_default_storage(self) -> Result<Self>

Load from default storage location

Source

pub fn load_from_path(self, path: PathBuf) -> Result<Self>

Load from a specific storage path

Trait Implementations§

Source§

impl Clone for AgentKeyManager

Source§

fn clone(&self) -> AgentKeyManager

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 AgentKeyManager

Source§

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

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

impl Default for AgentKeyManager

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl KeyManager for AgentKeyManager

Source§

fn secrets(&self) -> Arc<RwLock<HashMap<String, Secret>>>

Get access to the secrets storage

Source§

fn generate_key(&self, options: DIDGenerationOptions) -> Result<GeneratedKey>

Generate a new key with the specified options

Source§

fn generate_web_did( &self, domain: &str, options: DIDGenerationOptions, ) -> Result<GeneratedKey>

Generate a new web DID with the specified domain and options

Source§

fn add_key(&self, key: &GeneratedKey) -> Result<()>

Add an existing key to the key manager

Source§

fn remove_key(&self, did: &str) -> Result<()>

Remove a key from the key manager

Source§

fn has_key(&self, did: &str) -> Result<bool>

Check if the key manager has a key for the given DID

Source§

fn list_keys(&self) -> Result<Vec<String>>

Get a list of all DIDs in the key manager

Source§

fn add_signing_key<'life0, 'async_trait>( &'life0 self, key: Arc<dyn SigningKey + Send + Sync>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Add a signing key to the key manager

Source§

fn add_encryption_key<'life0, 'async_trait>( &'life0 self, key: Arc<dyn EncryptionKey + Send + Sync>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Add an encryption key to the key manager

Source§

fn add_decryption_key<'life0, 'async_trait>( &'life0 self, key: Arc<dyn DecryptionKey + Send + Sync>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Add a decryption key to the key manager

Source§

fn get_signing_key<'life0, 'life1, 'async_trait>( &'life0 self, kid: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn SigningKey + Send + Sync>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get a signing key by ID

Source§

fn get_encryption_key<'life0, 'life1, 'async_trait>( &'life0 self, kid: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn EncryptionKey + Send + Sync>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get an encryption key by ID

Source§

fn get_decryption_key<'life0, 'life1, 'async_trait>( &'life0 self, kid: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn DecryptionKey + Send + Sync>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get a decryption key by ID

Source§

fn resolve_verification_key<'life0, 'life1, 'async_trait>( &'life0 self, kid: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn VerificationKey + Send + Sync>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Resolve a verification key by ID

Source§

fn sign_jws<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, kid: &'life1 str, payload: &'life2 [u8], protected_header: Option<JwsProtected>, ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Sign data with a key

Source§

fn verify_jws<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, jws: &'life1 str, expected_kid: Option<&'life2 str>, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Verify a JWS

Source§

fn encrypt_jwe<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, sender_kid: &'life1 str, recipient_kid: &'life2 str, plaintext: &'life3 [u8], protected_header: Option<JweProtected>, ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Encrypt data for a recipient

Source§

fn decrypt_jwe<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, jwe: &'life1 str, expected_kid: Option<&'life2 str>, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Decrypt a JWE

Source§

impl KeyManagerPacking for AgentKeyManager

Source§

fn get_signing_key<'life0, 'life1, 'async_trait>( &'life0 self, kid: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn SigningKey + Send + Sync>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get a signing key by ID
Source§

fn get_encryption_key<'life0, 'life1, 'async_trait>( &'life0 self, kid: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn EncryptionKey + Send + Sync>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get an encryption key by ID
Source§

fn get_decryption_key<'life0, 'life1, 'async_trait>( &'life0 self, kid: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn DecryptionKey + Send + Sync>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get a decryption key by ID
Source§

fn resolve_verification_key<'life0, 'life1, 'async_trait>( &'life0 self, kid: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn VerificationKey + Send + Sync>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Resolve a verification key

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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>,

Source§

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,