use crate::error::SamlError;
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct MessageId(String);
impl MessageId {
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))
}
pub fn as_str(&self) -> &str {
&self.0
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct AssertionId(String);
impl AssertionId {
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))
}
pub fn as_str(&self) -> &str {
&self.0
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct SamlInstant(String);
impl SamlInstant {
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))
}
pub fn as_str(&self) -> &str {
&self.0
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct SessionIndex(String);
impl SessionIndex {
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))
}
pub fn as_str(&self) -> &str {
&self.0
}
}