use super::{
GarnetAclWithPasswordAuthenticator, GarnetNoAuthAuthenticator, GarnetPasswordAuthenticator,
i_garnet_authenticator::IGarnetAuthenticator,
};
pub enum GarnetAuthenticator {
NoAuth(GarnetNoAuthAuthenticator),
Password(GarnetPasswordAuthenticator),
AclWithPassword(GarnetAclWithPasswordAuthenticator),
}
impl IGarnetAuthenticator for GarnetAuthenticator {
#[inline]
fn is_authenticated(&self) -> bool {
match self {
Self::NoAuth(a) => a.is_authenticated(),
Self::Password(a) => a.is_authenticated(),
Self::AclWithPassword(a) => a.is_authenticated(),
}
}
#[inline]
fn can_authenticate(&self) -> bool {
match self {
Self::NoAuth(a) => a.can_authenticate(),
Self::Password(a) => a.can_authenticate(),
Self::AclWithPassword(a) => a.can_authenticate(),
}
}
#[inline]
fn has_acl_support(&self) -> bool {
match self {
Self::NoAuth(a) => a.has_acl_support(),
Self::Password(a) => a.has_acl_support(),
Self::AclWithPassword(a) => a.has_acl_support(),
}
}
#[inline]
fn authenticate(&mut self, password: &[u8], username: &[u8]) -> bool {
match self {
Self::NoAuth(a) => a.authenticate(password, username),
Self::Password(a) => a.authenticate(password, username),
Self::AclWithPassword(a) => a.authenticate(password, username),
}
}
}