///|
/// SASL PLAIN credentials: `authzid \0 authcid \0 password` (RFC 4616).
pub fn plain_sasl_credentials(
authzid : String,
authcid : String,
password : String,
) -> SaslCredentials {
let bytes = @utf8.encode(authzid) +
Bytes::from_array([0x00]) +
@utf8.encode(authcid) +
Bytes::from_array([0x00]) +
@utf8.encode(password)
SaslCredentials::new("PLAIN", bytes)
}
///|
/// Build a simple (cleartext password) bind request (RFC 4513 5.2.1).
pub fn simple_bind_request(
name : String,
password : String,
version? : Int,
) -> BindRequest {
let v = match version {
Some(v) => v
None => 3
}
BindRequest::simple(v, name, password)
}
///|
/// Build a SASL PLAIN bind request (RFC 4616).
pub fn sasl_plain_bind_request(
name : String,
authzid : String,
authcid : String,
password : String,
version? : Int,
) -> BindRequest {
let v = match version {
Some(v) => v
None => 3
}
BindRequest::sasl(v, name, plain_sasl_credentials(authzid, authcid, password))
}