oracle_nosql_rust_sdk/auth_common/
authentication_provider.rs1use openssl::pkey::Private;
8use openssl::rsa::Rsa;
9use std::error::Error;
10use std::fmt::Debug;
11
12pub trait AuthenticationProvider: Send + Sync + Debug + AuthenticationProviderClone {
14 fn tenancy_id(&self) -> &str;
16 fn user_id(&self) -> &str;
18 fn fingerprint(&self) -> &str;
20 fn private_key(&self) -> Result<Rsa<Private>, Box<dyn Error>>;
22 fn key_id(&self) -> String {
24 let key_id = format!(
25 "{}/{}/{}",
26 self.tenancy_id(),
27 self.user_id(),
28 self.fingerprint()
29 );
30 key_id
31 }
32 fn region_id(&self) -> &str;
34}
35
36pub trait AuthenticationProviderClone {
38 fn clone_box(&self) -> Box<dyn AuthenticationProvider>;
39}
40
41impl<T> AuthenticationProviderClone for T
42where
43 T: 'static + AuthenticationProvider + Clone,
44{
45 fn clone_box(&self) -> Box<dyn AuthenticationProvider> {
46 Box::new(self.clone())
47 }
48}
49
50impl Clone for Box<dyn AuthenticationProvider> {
51 fn clone(&self) -> Box<dyn AuthenticationProvider> {
52 self.clone_box()
53 }
54}