예제 #1
0
void UsrPacket::answer(const char *cmd, vector<string> &args)
{
    if (strcmp(cmd, "USR")){
        QTimer::singleShot(0, m_client, SLOT(authFailed()));
        return;
    }
    if (args[0] == "OK"){
        QTimer::singleShot(0, m_client, SLOT(authOk()));
        return;
    }
    if (args[1] == "S"){
        MD5_CTX c;
        unsigned char md[MD5_DIGEST_LENGTH];
        MD5_Init(&c);
        string user;
        user = m_client->getLogin().utf8();
        MD5_Update(&c, args[2].c_str(),(unsigned long)args[2].length());
        string pswd;
        pswd = m_client->getPassword().utf8();
        MD5_Update(&c, pswd.c_str(), pswd.length());
        MD5_Final(md, &c);
        string digest = "";
        for (unsigned i = 0; i < MD5_DIGEST_LENGTH; i++){
            char b[3];
            sprintf(b, "%02x",md[i]);
            digest += b;
        }
        MSNPacket *packet = new UsrPacket(m_client, digest.c_str());
        packet->send();
    }
}
예제 #2
0
void SpotifyIO::loginReply()
{
    qDebug() << "resolver request";
    QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
    if (reply) {
        QByteArray data(reply->readAll());
        QVariantMap json = QJsonDocument::fromJson(data).toVariant().toMap();

        if (json["status"].toString() == "OK") {
            settings = json["config"].toMap();
            QVariantMap resolver = settings["aps"].toMap()["resolver"].toMap();

            QUrl url;
            url.setScheme("https");
            url.setHost(resolver["hostname"].toString());
            QUrlQuery query;
            query.addQueryItem("client", "24:0:0:" + settings["version"].toString());
            QString site = resolver["site"].toString();
            if (!site.isEmpty()) {
                query.addQueryItem("site", site);
            }
            url.setQuery(query);
            QNetworkRequest req(url);
            req.setHeader(QNetworkRequest::UserAgentHeader, userAgent);
            QObject::connect(nam->get(req), SIGNAL(finished()), this, SLOT(resolverReply()));
        }
        else {
            qDebug() << json["error"];
            Q_EMIT authFailed(json["error"].toString());

            _state = DisconnectedState;
            Q_EMIT stateChanged();
        }
    }
}
예제 #3
0
std::shared_ptr<YggdrasilTask> MojangAccount::login(QString password)
{
	if (m_currentTask)
		return m_currentTask;
	if (password.isEmpty())
	{
		m_currentTask.reset(new RefreshTask(this));
	}
	else
	{
		m_currentTask.reset(new AuthenticateTask(this, password));
	}
	connect(m_currentTask.get(), SIGNAL(succeeded()), SLOT(authSucceeded()));
	connect(m_currentTask.get(), SIGNAL(failed(QString)), SLOT(authFailed(QString)));
	return m_currentTask;
}
예제 #4
0
파일: capcan.cpp 프로젝트: hominlinx/cppbed
void capCan::initAuth()
{
	mAuth = new authLib("capCan");
	connect(mAuth, SIGNAL(authFailed()), this, SLOT(onAuthFailed()));
	mAuth->start();
}