summaryrefslogtreecommitdiffstats
path: root/kio/misc/kdesasl
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-31 19:46:43 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-31 19:46:43 +0000
commitffe8a83e053396df448e9413828527613ca3bd46 (patch)
treea73d4169e02df4a50f9a12cb165fcd0ab5bac7c6 /kio/misc/kdesasl
parent682bf3bfdcbcbb1fca85e8a36ed03e062e0555d5 (diff)
downloadtdelibs-ffe8a83e053396df448e9413828527613ca3bd46.tar.gz
tdelibs-ffe8a83e053396df448e9413828527613ca3bd46.zip
Trinity Qt initial conversion
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1157647 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kio/misc/kdesasl')
-rw-r--r--kio/misc/kdesasl/kdesasl.cpp80
-rw-r--r--kio/misc/kdesasl/kdesasl.h28
2 files changed, 54 insertions, 54 deletions
diff --git a/kio/misc/kdesasl/kdesasl.cpp b/kio/misc/kdesasl/kdesasl.cpp
index c59d157b8..b547f7e6b 100644
--- a/kio/misc/kdesasl/kdesasl.cpp
+++ b/kio/misc/kdesasl/kdesasl.cpp
@@ -22,7 +22,7 @@
#include <kmdcodec.h>
#include <kurl.h>
-#include <qstrlist.h>
+#include <tqstrlist.h>
#include <stdlib.h>
#include <string.h>
@@ -35,8 +35,8 @@ KDESasl::KDESasl(const KURL &aUrl)
mFirst = true;
}
-KDESasl::KDESasl(const QString &aUser, const QString &aPass,
- const QString &aProtocol)
+KDESasl::KDESasl(const TQString &aUser, const TQString &aPass,
+ const TQString &aProtocol)
{
mProtocol = aProtocol;
mUser = aUser;
@@ -47,29 +47,29 @@ KDESasl::KDESasl(const QString &aUser, const QString &aPass,
KDESasl::~KDESasl() {
}
-QCString KDESasl::chooseMethod(const QStrIList aMethods)
+TQCString KDESasl::chooseMethod(const TQStrIList aMethods)
{
if (aMethods.contains("DIGEST-MD5")) mMethod = "DIGEST-MD5";
else if (aMethods.contains("CRAM-MD5")) mMethod = "CRAM-MD5";
else if (aMethods.contains("PLAIN")) mMethod = "PLAIN";
else if (aMethods.contains("LOGIN")) mMethod = "LOGIN";
- else mMethod = QCString();
+ else mMethod = TQCString();
return mMethod;
}
-void KDESasl::setMethod(const QCString &aMethod)
+void KDESasl::setMethod(const TQCString &aMethod)
{
mMethod = aMethod.upper();
}
-QByteArray KDESasl::getPlainResponse()
+TQByteArray KDESasl::getPlainResponse()
{
- QCString user = mUser.utf8();
- QCString pass = mPass.utf8();
+ TQCString user = mUser.utf8();
+ TQCString pass = mPass.utf8();
int userlen = user.length();
int passlen = pass.length();
// result = $user\0$user\0$pass (no trailing \0)
- QByteArray result(2 * userlen + passlen + 2);
+ TQByteArray result(2 * userlen + passlen + 2);
if ( userlen ) {
memcpy( result.data(), user.data(), userlen );
memcpy( result.data() + userlen + 1, user.data(), userlen );
@@ -80,18 +80,18 @@ QByteArray KDESasl::getPlainResponse()
return result;
}
-QByteArray KDESasl::getLoginResponse()
+TQByteArray KDESasl::getLoginResponse()
{
- QByteArray result = (mFirst) ? mUser.utf8() : mPass.utf8();
+ TQByteArray result = (mFirst) ? mUser.utf8() : mPass.utf8();
mFirst = !mFirst;
if (result.size()) result.resize(result.size() - 1);
return result;
}
-QByteArray KDESasl::getCramMd5Response(const QByteArray &aChallenge)
+TQByteArray KDESasl::getCramMd5Response(const TQByteArray &aChallenge)
{
uint i;
- QByteArray secret = mPass.utf8();
+ TQByteArray secret = mPass.utf8();
int len = mPass.utf8().length();
secret.resize(len);
if (secret.size() > 64)
@@ -102,9 +102,9 @@ QByteArray KDESasl::getCramMd5Response(const QByteArray &aChallenge)
}
secret.resize(64);
for (i = len; i < 64; i++) secret[i] = 0;
- QByteArray XorOpad(64);
+ TQByteArray XorOpad(64);
for (i = 0; i < 64; i++) XorOpad[i] = secret[i] ^ 0x5C;
- QByteArray XorIpad(64);
+ TQByteArray XorIpad(64);
for (i = 0; i < 64; i++) XorIpad[i] = secret[i] ^ 0x36;
KMD5 md5;
md5.update(XorIpad);
@@ -112,21 +112,21 @@ QByteArray KDESasl::getCramMd5Response(const QByteArray &aChallenge)
KMD5 md5a;
md5a.update(XorOpad);
md5a.update(md5.rawDigest(), 16);
- QByteArray result = mUser.utf8();
+ TQByteArray result = mUser.utf8();
len = mUser.utf8().length();
result.resize(len + 33);
result[len] = ' ';
- QCString ch = md5a.hexDigest();
+ TQCString ch = md5a.hexDigest();
for (i = 0; i < 32; i++) result[i+len+1] = *(ch.data() + i);
return result;
}
-QByteArray KDESasl::getDigestMd5Response(const QByteArray &aChallenge)
+TQByteArray KDESasl::getDigestMd5Response(const TQByteArray &aChallenge)
{
mFirst = !mFirst;
- if (mFirst) return QByteArray();
- QCString str, realm, nonce, qop, algorithm, charset;
- QCString nc = "00000001";
+ if (mFirst) return TQByteArray();
+ TQCString str, realm, nonce, qop, algorithm, charset;
+ TQCString nc = "00000001";
unsigned int a, b, c, d;
a = 0;
while (a < aChallenge.size())
@@ -143,7 +143,7 @@ QByteArray KDESasl::getDigestMd5Response(const QByteArray &aChallenge)
d = c;
while (d < aChallenge.size() && aChallenge[d] != ',') d++;
}
- str = QCString(aChallenge.data() + c, d - c + 1);
+ str = TQCString(aChallenge.data() + c, d - c + 1);
if (qstrnicmp(aChallenge.data() + a, "realm=", 6) == 0) realm = str;
else if (qstrnicmp(aChallenge.data() + a, "nonce=", 6) == 0) nonce = str;
else if (qstrnicmp(aChallenge.data() + a, "qop=", 4) == 0) qop = str;
@@ -156,7 +156,7 @@ QByteArray KDESasl::getDigestMd5Response(const QByteArray &aChallenge)
if (qop.isEmpty()) qop = "auth";
qop = "auth";
bool utf8 = qstricmp(charset, "utf-8") == 0;
- QCString digestUri = QCString(mProtocol.latin1()) + "/" + realm;
+ TQCString digestUri = TQCString(mProtocol.latin1()) + "/" + realm;
/* Calculate the response */
/* Code based on code from the http io-slave
@@ -164,17 +164,17 @@ QByteArray KDESasl::getDigestMd5Response(const QByteArray &aChallenge)
Copyright (C) 2000,2001 Waldo Bastian <bastian@kde.org>
Copyright (C) 2000,2001 George Staikos <staikos@kde.org> */
KMD5 md, md2;
- QCString HA1, HA2;
- QCString cnonce;
+ TQCString HA1, HA2;
+ TQCString cnonce;
cnonce.setNum((1 + static_cast<int>(100000.0*rand()/(RAND_MAX+1.0))));
cnonce = KCodecs::base64Encode( cnonce );
// Calculate H(A1)
- QCString authStr = (utf8) ? mUser.utf8() : QCString(mUser.latin1());
+ TQCString authStr = (utf8) ? mUser.utf8() : TQCString(mUser.latin1());
authStr += ':';
authStr += realm;
authStr += ':';
- authStr += (utf8) ? mPass.utf8() : QCString(mPass.latin1());
+ authStr += (utf8) ? mPass.utf8() : TQCString(mPass.latin1());
md.update( authStr );
authStr = "";
@@ -220,30 +220,30 @@ QByteArray KDESasl::getDigestMd5Response(const QByteArray &aChallenge)
authStr += HA2;
md.reset();
md.update( authStr );
- QCString response = md.hexDigest();
+ TQCString response = md.hexDigest();
/* End of response calculation */
- QCString result;
+ TQCString result;
if (utf8)
{
result = "charset=utf-8,username=\"" + mUser.utf8();
} else {
- result = "charset=iso-8859-1,username=\"" + QCString(mUser.latin1());
+ result = "charset=iso-8859-1,username=\"" + TQCString(mUser.latin1());
}
result += "\",realm=\"" + realm + "\",nonce=\"" + nonce;
result += "\",nc=" + nc + ",cnonce=\"" + cnonce;
result += "\",digest-uri=\"" + digestUri;
result += "\",response=" + response + ",qop=" + qop;
- QByteArray ba;
+ TQByteArray ba;
ba.duplicate(result.data(), result.length());
return ba;
}
-QByteArray KDESasl::getBinaryResponse(const QByteArray &aChallenge, bool aBase64)
+TQByteArray KDESasl::getBinaryResponse(const TQByteArray &aChallenge, bool aBase64)
{
if (aBase64)
{
- QByteArray ba;
+ TQByteArray ba;
KCodecs::base64Decode(aChallenge, ba);
KCodecs::base64Encode(getBinaryResponse(ba, false), ba);
return ba;
@@ -254,17 +254,17 @@ QByteArray KDESasl::getBinaryResponse(const QByteArray &aChallenge, bool aBase64
return getCramMd5Response(aChallenge);
if (qstricmp(mMethod, "DIGEST-MD5") == 0)
return getDigestMd5Response(aChallenge);
-// return getDigestMd5Response(QCString("realm=\"elwood.innosoft.com\",nonce=\"OA6MG9tEQGm2hh\",qop=\"auth\",algorithm=md5-sess,charset=utf-8"));
- return QByteArray();
+// return getDigestMd5Response(TQCString("realm=\"elwood.innosoft.com\",nonce=\"OA6MG9tEQGm2hh\",qop=\"auth\",algorithm=md5-sess,charset=utf-8"));
+ return TQByteArray();
}
-QCString KDESasl::getResponse(const QByteArray &aChallenge, bool aBase64)
+TQCString KDESasl::getResponse(const TQByteArray &aChallenge, bool aBase64)
{
- QByteArray ba = getBinaryResponse(aChallenge, aBase64);
- return QCString(ba.data(), ba.size() + 1);
+ TQByteArray ba = getBinaryResponse(aChallenge, aBase64);
+ return TQCString(ba.data(), ba.size() + 1);
}
-QCString KDESasl::method() const {
+TQCString KDESasl::method() const {
return mMethod;
}
diff --git a/kio/misc/kdesasl/kdesasl.h b/kio/misc/kdesasl/kdesasl.h
index 834c83913..4049b96eb 100644
--- a/kio/misc/kdesasl/kdesasl.h
+++ b/kio/misc/kdesasl/kdesasl.h
@@ -20,7 +20,7 @@
#ifndef KDESASL_H
#define KDESASL_H
-#include <qstring.h>
+#include <tqstring.h>
#include <kdelibs_export.h>
@@ -59,7 +59,7 @@ class QStrIList;
* mySendAuthCommand( sasl.method() );
* }
* for ( ; !sasl.dialogComplete( numResponses ) ; ++numResponses ) {
- * QByteArray challenge = myRecvChallenge();
+ * TQByteArray challenge = myRecvChallenge();
* mySendResponse( sasl.getResponse( challenge ) );
* }
* return myCheckSuccess();
@@ -82,7 +82,7 @@ public:
* This is a conveniece function and differs from the above function only by
* what arguments it accepts.
*/
- KDESasl(const QString &aUser, const QString &aPass, const QString &aProtocol);
+ KDESasl(const TQString &aUser, const TQString &aPass, const TQString &aProtocol);
/*
* You need to have a virtual destructor!
*/
@@ -91,16 +91,16 @@ public:
* @returns the most secure method from the given methods and use it for
* further operations.
*/
- virtual QCString chooseMethod(const QStrIList aMethods);
+ virtual TQCString chooseMethod(const TQStrIList aMethods);
/**
* Explicitely set the SASL method used.
*/
- virtual void setMethod(const QCString &aMethod);
+ virtual void setMethod(const TQCString &aMethod);
/**
* @return the SASL method used.
* @since 3.2
*/
- QCString method() const;
+ TQCString method() const;
/**
* @param numCalls number of times getResponse() has been called.
* @return whether the challenge/response dialog has completed
@@ -126,11 +126,11 @@ public:
* encoding. The challenge is decoded from base64 and the response is
* encoded base64 if set to true.
*/
- QCString getResponse(const QByteArray &aChallenge=QByteArray(), bool aBase64 = true);
+ TQCString getResponse(const TQByteArray &aChallenge=TQByteArray(), bool aBase64 = true);
/**
* Create a response as above but place it in a QByteArray
*/
- QByteArray getBinaryResponse(const QByteArray &aChallenge=QByteArray(), bool aBase64=true);
+ TQByteArray getBinaryResponse(const TQByteArray &aChallenge=TQByteArray(), bool aBase64=true);
/**
* Returns true if the client is supposed to initiate the
* challenge-respinse dialog with an initial response (which most
@@ -146,23 +146,23 @@ protected:
/**
* PLAIN authentication as described in RFC 2595
*/
- virtual QByteArray getPlainResponse();
+ virtual TQByteArray getPlainResponse();
/**
* LOGIN authentication
*/
- virtual QByteArray getLoginResponse();
+ virtual TQByteArray getLoginResponse();
/**
* CRAM-MD5 authentication as described in RFC 2195
*/
- virtual QByteArray getCramMd5Response(const QByteArray &aChallenge);
+ virtual TQByteArray getCramMd5Response(const TQByteArray &aChallenge);
/**
* DIGEST-MD5 authentication as described in RFC 2831
*/
- virtual QByteArray getDigestMd5Response(const QByteArray &aChallenge);
+ virtual TQByteArray getDigestMd5Response(const TQByteArray &aChallenge);
private:
- QString mProtocol, mUser, mPass;
- QCString mMethod;
+ TQString mProtocol, mUser, mPass;
+ TQCString mMethod;
bool mFirst;
};