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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
use crate::error::SamlError;
/// SAML protocol message `ID`.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct MessageId(String);
impl MessageId {
/// Validate and wrap a SAML protocol message ID.
///
/// # Errors
///
/// Returns [`SamlError::Invalid`] when the message ID is empty.
pub fn try_new(value: impl Into<String>) -> Result<Self, SamlError> {
let value = value.into();
if value.trim().is_empty() {
return Err(SamlError::Invalid(
"SAML message ID must not be empty".into(),
));
}
Ok(Self(value))
}
/// Borrow the message ID string.
pub fn as_str(&self) -> &str {
&self.0
}
}
/// Assertion ID extracted from a SAML assertion.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct AssertionId(String);
impl AssertionId {
/// Validate and wrap an assertion ID.
///
/// # Errors
///
/// Returns [`SamlError::Invalid`] when the assertion ID is empty.
pub fn try_new(value: impl Into<String>) -> Result<Self, SamlError> {
let value = value.into();
if value.trim().is_empty() {
return Err(SamlError::Invalid("assertion ID must not be empty".into()));
}
Ok(Self(value))
}
/// Borrow the assertion ID string.
pub fn as_str(&self) -> &str {
&self.0
}
}
/// SAML instant text carried in pending snapshots and parsed results.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct SamlInstant(String);
impl SamlInstant {
/// Validate and wrap a SAML instant string.
///
/// # Errors
///
/// Returns [`SamlError::Invalid`] when the instant is empty. Full temporal
/// enforcement is left to the validation policy that consumes the value.
pub fn try_new(value: impl Into<String>) -> Result<Self, SamlError> {
let value = value.into();
if value.trim().is_empty() {
return Err(SamlError::Invalid("SAML instant must not be empty".into()));
}
Ok(Self(value))
}
/// Borrow the instant string.
pub fn as_str(&self) -> &str {
&self.0
}
}
/// SessionIndex from an AuthnStatement or LogoutRequest.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct SessionIndex(String);
impl SessionIndex {
/// Validate and wrap a SessionIndex.
///
/// # Errors
///
/// Returns [`SamlError::Invalid`] when the SessionIndex is empty.
pub fn try_new(value: impl Into<String>) -> Result<Self, SamlError> {
let value = value.into();
if value.trim().is_empty() {
return Err(SamlError::Invalid("SessionIndex must not be empty".into()));
}
Ok(Self(value))
}
/// Borrow the SessionIndex string.
pub fn as_str(&self) -> &str {
&self.0
}
}