Esempio n. 1
0
KIO::AuthInfo KPasswdServer::queryAuthInfo(KIO::AuthInfo info, QString errorMsg, long windowId, long seqNr, unsigned long usertime)
{
    kdDebug(130) << "KPasswdServer::queryAuthInfo: User= "******", Message= " << info.prompt << ", WindowId = " << windowId << endl;
    if(!info.password.isEmpty()) // should we really allow the caller to pre-fill the password?
        kdDebug(130) << "password was set by caller" << endl;
    if(usertime != 0)
        kapp->updateUserTimestamp(usertime);

    QString key = createCacheKey(info);
    Request *request = new Request;
    request->client = callingDcopClient();
    request->transaction = request->client->beginTransaction();
    request->key = key;
    request->info = info;
    request->windowId = windowId;
    request->seqNr = seqNr;
    if(errorMsg == "<NoAuthPrompt>")
    {
        request->errorMsg = QString::null;
        request->prompt = false;
    }
    else
    {
        request->errorMsg = errorMsg;
        request->prompt = true;
    }
    m_authPending.append(request);

    if(m_authPending.count() == 1)
        QTimer::singleShot(0, this, SLOT(processRequest()));

    return info;
}
Esempio n. 2
0
void KDEPrintd::processRequest()
{
    if(m_requestsPending.count() == 0)
        return;

    Request *req = m_requestsPending.first();
    KIO::AuthInfo info;
    QByteArray params, reply;
    QCString replyType;
    QString authString("::");

    info.username = req->user;
    info.keepPassword = true;
    info.url = req->uri;
    info.comment = i18n("Printing system");

    QDataStream input(params, IO_WriteOnly);
    input << info << i18n("Authentication failed (user name=%1)").arg(info.username) << 0L << (long int)req->seqNbr;
    if(callingDcopClient()->call("kded", "kpasswdserver", "queryAuthInfo(KIO::AuthInfo,QString,long int,long int)", params, replyType, reply))
    {
        if(replyType == "KIO::AuthInfo")
        {
            QDataStream output(reply, IO_ReadOnly);
            KIO::AuthInfo result;
            int seqNbr;
            output >> result >> seqNbr;

            if(result.isModified())
                authString = result.username + ":" + result.password + ":" + QString::number(seqNbr);
        }
        else
Esempio n. 3
0
KIO::AuthInfo
KPasswdServer::checkAuthInfo(KIO::AuthInfo info, long windowId, unsigned long usertime)
{
    kdDebug(130) << "KPasswdServer::checkAuthInfo: User= "******", WindowId = " << windowId << endl;
    if( usertime != 0 )
        kapp->updateUserTimestamp( usertime );

    QString key = createCacheKey(info);

    Request *request = m_authPending.first();
    QString path2 = info.url.directory(false, false);
    for(; request; request = m_authPending.next())
    {
       if (request->key != key)
           continue;

       if (info.verifyPath)
       {
          QString path1 = request->info.url.directory(false, false);
          if (!path2.startsWith(path1))
             continue;
       }

       request = new Request;
       request->client = callingDcopClient();
       request->transaction = request->client->beginTransaction();
       request->key = key;
       request->info = info;
       m_authWait.append(request);
       return info;
    }

    const AuthInfo *result = findAuthInfoItem(key, info);
    if (!result || result->isCanceled)
    {
       if (!result &&
           (info.username.isEmpty() || info.password.isEmpty()) &&
           !KWallet::Wallet::keyDoesNotExist(KWallet::Wallet::NetworkWallet(),
                                             KWallet::Wallet::PasswordFolder(), makeWalletKey(key, info.realmValue)))
       {
          QMap<QString, QString> knownLogins;
          if (openWallet(windowId)) {
              if (readFromWallet(m_wallet, key, info.realmValue, info.username, info.password,
                             info.readOnly, knownLogins))
	      {
		      info.setModified(true);
		      return info;
	      }
	  }
       }

       info.setModified(false);
       return info;
    }

    updateAuthExpire(key, result, windowId, false);

    return copyAuthInfo(result);
}
Esempio n. 4
0
QString KDEPrintd::requestPassword(const QString &user, const QString &host, int port, int seqNbr)
{
    Request *req = new Request;
    req->user = user;
    req->uri = "print://" + user + "@" + host + ":" + QString::number(port);
    req->seqNbr = seqNbr;
    req->transaction = callingDcopClient()->beginTransaction();
    m_requestsPending.append(req);
    if(m_requestsPending.count() == 1)
        QTimer::singleShot(0, this, SLOT(processRequest()));
    return "::";
}
Esempio n. 5
0
// DCOP function
QString KCookieServer::findCookies(QString url, long windowId)
{
    if(cookiesPending(url))
    {
        CookieRequest *request = new CookieRequest;
        request->client = callingDcopClient();
        request->transaction = request->client->beginTransaction();
        request->url = url;
        request->DOM = false;
        request->windowId = windowId;
        mRequestList->append(request);
        return QString::null; // Talk to you later :-)
    }

    QString cookies = mCookieJar->findCookies(url, false, windowId);

    if(mCookieJar->changed())
        saveCookieJar();

    return cookies;
}