@@ -5,7 +5,7 @@ use util::FromElement;
#[derive(Clone, Debug)]
pub enum Condition {
Aborted,
- AccountDisabled(Option<String>),
+ AccountDisabled,
CredentialsExpired,
EncryptionRequired,
IncorrectEncoding,
@@ -42,9 +42,8 @@ impl FromElement for SaslError {
if element.has_child("aborted", ns::SASL) {
err.condition = Condition::Aborted;
}
- else if let Some(account_disabled) = element.get_child("account-disabled", ns::SASL) {
- let text = account_disabled.text();
- err.condition = Condition::AccountDisabled(if text == "" { None } else { Some(text) });
+ else if element.has_child("account-disabled", ns::SASL) {
+ err.condition = Condition::AccountDisabled;
}
else if element.has_child("credentials-expired", ns::SASL) {
err.condition = Condition::CredentialsExpired;
@@ -70,6 +69,16 @@ impl FromElement for SaslError {
else if element.has_child("temporary-auth-failure", ns::SASL) {
err.condition = Condition::TemporaryAuthFailure;
}
+ else {
+ /* RFC 6120 section 6.5:
+ *
+ * However, because additional error conditions might be defined in
+ * the future, if an entity receives a SASL error condition that it
+ * does not understand then it MUST treat the unknown condition as
+ * a generic authentication failure, i.e., as equivalent to
+ * <not-authorized/> (Section 6.5.10). */
+ err.condition = Condition::NotAuthorized;
+ }
Ok(err)
}
}