|
|
|
@ -155,6 +155,7 @@ public:
|
|
|
|
|
TQString out_mech;
|
|
|
|
|
TQByteArray out_buf;
|
|
|
|
|
bool capable;
|
|
|
|
|
bool allow_plain;
|
|
|
|
|
int err;
|
|
|
|
|
|
|
|
|
|
TQCA_SASLNeedParams need;
|
|
|
|
@ -207,12 +208,13 @@ public:
|
|
|
|
|
host = _host;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setSecurityProps(bool, bool, bool, bool, bool reqForward, bool reqCreds, bool reqMutual, int ssfMin, int, const TQString &, int)
|
|
|
|
|
void setSecurityProps(bool noPlain, bool, bool, bool, bool reqForward, bool reqCreds, bool reqMutual, int ssfMin, int, const TQString &, int)
|
|
|
|
|
{
|
|
|
|
|
if(reqForward || reqCreds || reqMutual || ssfMin > 0)
|
|
|
|
|
capable = false;
|
|
|
|
|
else
|
|
|
|
|
capable = true;
|
|
|
|
|
allow_plain = !noPlain;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int security() const
|
|
|
|
@ -228,8 +230,17 @@ public:
|
|
|
|
|
bool clientStart(const TQStringList &mechlist)
|
|
|
|
|
{
|
|
|
|
|
bool haveMech = false;
|
|
|
|
|
resetState();
|
|
|
|
|
step = 0;
|
|
|
|
|
|
|
|
|
|
for(TQStringList::ConstIterator it = mechlist.begin(); it != mechlist.end(); ++it) {
|
|
|
|
|
if((*it) == "PLAIN" && allow_plain) {
|
|
|
|
|
out_mech = "PLAIN";
|
|
|
|
|
haveMech = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if((*it) == "DIGEST-MD5") {
|
|
|
|
|
out_mech = "DIGEST-MD5";
|
|
|
|
|
haveMech = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
@ -238,9 +249,6 @@ public:
|
|
|
|
|
err = TQCA::SASL::NoMech;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resetState();
|
|
|
|
|
step = 0;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -316,7 +324,7 @@ public:
|
|
|
|
|
|
|
|
|
|
const TQByteArray *clientInit() const
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
return out_mech == "PLAIN" ? &out_buf : 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TQByteArray result() const
|
|
|
|
@ -326,8 +334,49 @@ public:
|
|
|
|
|
|
|
|
|
|
int clientTryAgain()
|
|
|
|
|
{
|
|
|
|
|
if( out_mech == "PLAIN" ) {
|
|
|
|
|
if(step == 0) {
|
|
|
|
|
// First, check if we have everything
|
|
|
|
|
if(need.user || need.pass) {
|
|
|
|
|
err = -1;
|
|
|
|
|
return Error;
|
|
|
|
|
}
|
|
|
|
|
if(!have.user) {
|
|
|
|
|
need.user = true;
|
|
|
|
|
}
|
|
|
|
|
if(!have.pass) {
|
|
|
|
|
need.pass = true;
|
|
|
|
|
}
|
|
|
|
|
if(need.user || need.pass) {
|
|
|
|
|
return NeedParams;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TQCString authz_ = authz.utf8();
|
|
|
|
|
TQCString user_ = user.utf8();
|
|
|
|
|
TQCString pass_ = pass.utf8();
|
|
|
|
|
int l = 0;
|
|
|
|
|
|
|
|
|
|
out_buf.resize(authz_.length() + 1 + user_.length() + 1 + pass_.length());
|
|
|
|
|
memcpy(&out_buf[l], authz_.data(), authz_.length());
|
|
|
|
|
l += authz_.length();
|
|
|
|
|
out_buf[l] = '\0';
|
|
|
|
|
l += 1;
|
|
|
|
|
memcpy(&out_buf[l], user_.data(), user_.length());
|
|
|
|
|
l += user_.length();
|
|
|
|
|
out_buf[l] = '\0';
|
|
|
|
|
l += 1;
|
|
|
|
|
|
|
|
|
|
memcpy(&out_buf[l], pass_.data(), pass_.length());
|
|
|
|
|
++step;
|
|
|
|
|
return Continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
out_buf.resize(0);
|
|
|
|
|
return Success;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( out_mech == "DIGEST-MD5" ) {
|
|
|
|
|
if(step == 0) {
|
|
|
|
|
out_mech = "DIGEST-MD5";
|
|
|
|
|
++step;
|
|
|
|
|
return Continue;
|
|
|
|
|
}
|
|
|
|
@ -404,7 +453,7 @@ public:
|
|
|
|
|
++step;
|
|
|
|
|
return Continue;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
|
|
out_buf.resize(0);
|
|
|
|
|
return Success;
|
|
|
|
|
}
|
|
|
|
|