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
71
72
73
74
75
76
77
78
79
80
use super::Vault;
use crate::{
	core::{CredFormat, KrbUser, TicketCred, TicketCreds},
	error::Result,
};

/// Reference for implementing the `Vault` trait
pub struct EmptyVault
{
	ticket_creds: TicketCreds,
}

impl Default for EmptyVault
{
	fn default() -> Self
	{
		Self::new()
	}
}

impl EmptyVault
{
	pub fn new() -> Self
	{
		Self { ticket_creds: TicketCreds::empty() }
	}
}

impl Vault for EmptyVault
{
	fn id(&self) -> &str
	{
		"Nowhere"
	}

	fn support_cred_format(&self) -> Result<Option<CredFormat>>
	{
		Ok(None)
	}

	fn add(&mut self, ticket_info: TicketCred) -> Result<()>
	{
		self.ticket_creds.push(ticket_info);
		Ok(())
	}

	fn dump(&self) -> Result<TicketCreds>
	{
		Ok(self.ticket_creds.clone())
	}

	fn save(&self, _: TicketCreds) -> Result<()>
	{
		Ok(())
	}

	fn save_as(&self, _: TicketCreds, _: CredFormat) -> Result<()>
	{
		Ok(())
	}

	fn change_format(&self, _: CredFormat) -> Result<()>
	{
		Ok(())
	}

	fn get_user_tgts(&self, user: &KrbUser) -> Result<TicketCreds>
	{
		Ok(self.ticket_creds.user_tgt_realm(user, &user.realm))
	}

	fn s4u2self_tgss(&self,
	                 user: &KrbUser,
	                 impersonate_user: &KrbUser,
	                 user_service: Option<&String>)
	                 -> Result<TicketCreds>
	{
		Ok(self.ticket_creds.s4u2self_tgss(user, impersonate_user, user_service))
	}
}