109 lines
3.7 KiB
Rust
109 lines
3.7 KiB
Rust
use serde::{Deserialize, Serialize};
|
|
use std::hash::Hash;
|
|
|
|
use super::{key_encryption::KeyEncryption, request::Request};
|
|
#[derive(Debug, Serialize, Deserialize, Default, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
|
pub struct KeyRoleConfidential {
|
|
pub attribute_name: String,
|
|
pub key: KeyEncryption,
|
|
pub algorithm_name: String,
|
|
}
|
|
|
|
impl KeyRoleConfidential {
|
|
pub fn new(attribute_name: String, key: KeyEncryption, algorithm_name: String) -> Self {
|
|
KeyRoleConfidential {
|
|
attribute_name,
|
|
key,
|
|
algorithm_name,
|
|
}
|
|
}
|
|
|
|
// Fonction pour afficher ou retourner les informations
|
|
pub fn display_info(&self) -> String {
|
|
format!(
|
|
"Attribute Name: {}, Key: {:?}, Algorithm: {}",
|
|
self.attribute_name,
|
|
self.key, // Utilise {:?} si KeyEncryption implémente Debug
|
|
self.algorithm_name
|
|
)
|
|
}
|
|
|
|
// Additional methods for KeyRoleConfidential can be added here
|
|
}
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Default, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
|
pub struct RequestPrd {
|
|
pub request: Request, // Assuming Request is a predefined struct
|
|
pub pcd_keys_role_confidential_list_enc_by_shared_secret: String,
|
|
pub message_public: Option<String>,
|
|
pub message_confidential: Option<String>,
|
|
pub message_private: Option<String>,
|
|
pub sp_address_to: String,
|
|
pub sp_address_from: String,
|
|
pub sp_address_reply: String,
|
|
pub timestamp_declared: u64, // Assuming a Unix timestamp
|
|
pub role_name_from: String,
|
|
pub role_name_to: String,
|
|
}
|
|
|
|
impl RequestPrd {
|
|
pub const TYPE: &'static str = "prd";
|
|
pub fn new(
|
|
request_item_name: Option<String>,
|
|
request_type: String,
|
|
request_version: i64,
|
|
request_process_hash: String,
|
|
request_pcd_reference_hash: Option<String>,
|
|
request_item_reference_hash: Option<String>,
|
|
pcd_keys_role_confidential_list_enc_by_shared_secret: String,
|
|
message_public: Option<String>,
|
|
message_confidential: Option<String>,
|
|
message_private: Option<String>,
|
|
sp_address_to: String,
|
|
sp_address_from: String,
|
|
sp_address_reply: String,
|
|
timestamp_declared: u64,
|
|
role_name_from: String,
|
|
role_name_to: String,
|
|
) -> Self {
|
|
let request = Request::new(
|
|
request_item_name,
|
|
request_type,
|
|
request_version,
|
|
request_process_hash,
|
|
request_pcd_reference_hash,
|
|
request_item_reference_hash,
|
|
);
|
|
RequestPrd {
|
|
request,
|
|
pcd_keys_role_confidential_list_enc_by_shared_secret,
|
|
message_public,
|
|
message_confidential,
|
|
message_private,
|
|
sp_address_to,
|
|
sp_address_from,
|
|
sp_address_reply,
|
|
timestamp_declared,
|
|
role_name_from,
|
|
role_name_to,
|
|
}
|
|
}
|
|
|
|
// Fonction pour afficher ou retourner les informations
|
|
pub fn display_info(&self) -> String {
|
|
format!(
|
|
"Request: {:?}, PCD Keys Role Confidential: {:?}, Message Public: {}, Message Confidential: {}, Message Private: {}, SP Address From: {}, SP Address Reply: {}, Timestamp Declared: {}, Role Name From: {}, Role Name To: {}",
|
|
self.request,
|
|
self.pcd_keys_role_confidential_list_enc_by_shared_secret,
|
|
self.message_public.as_ref().unwrap(),
|
|
self.message_confidential.as_ref().unwrap(),
|
|
self.message_private.as_ref().unwrap(),
|
|
self.sp_address_from,
|
|
self.sp_address_reply,
|
|
self.timestamp_declared,
|
|
self.role_name_from,
|
|
self.role_name_to,
|
|
)
|
|
}
|
|
}
|