void ConnectionValidator::slotStatusFound(const QUrl&url, const QVariantMap &info) { // status.php was found. qDebug() << "** Application: ownCloud found: " << url << " with version " << CheckServerJob::versionString(info) << "(" << CheckServerJob::version(info) << ")"; QString version = CheckServerJob::version(info); _account->setServerVersion(version); if (version.contains('.') && version.split('.')[0].toInt() < 5) { _errors.append( tr("The configured server for this client is too old") ); _errors.append( tr("Please update to the latest server and restart the client.") ); reportResult( ServerVersionMismatch ); return; } // now check the authentication AbstractCredentials *creds = _account->credentials(); if (creds->ready()) { QTimer::singleShot( 0, this, SLOT( checkAuthentication() )); } else { // We can't proceed with the auth check because we don't have credentials. // Fetch them now! Once fetched, a new connectivity check will be // initiated anyway. creds->fetch(); // no result is reported deleteLater(); } }
void AbstractCredentialsWizardPage::cleanupPage() { Account *account = static_cast<OwncloudWizard*>(wizard())->account(); AbstractCredentials *creds = account->credentials(); if (creds) { if (!creds->inherits("DummyCredentials")) { account->setCredentials(CredentialsFactory::create("dummy")); } } }
void AbstractNetworkJob::slotFinished() { _timer.stop(); if( _reply->error() == QNetworkReply::SslHandshakeFailedError ) { qDebug() << "SslHandshakeFailedError: " << reply()->errorString() << " : can be caused by a webserver wanting SSL client certificates"; } if( _reply->error() != QNetworkReply::NoError ) { qDebug() << Q_FUNC_INFO << _reply->error() << _reply->errorString() << _reply->attribute(QNetworkRequest::HttpStatusCodeAttribute); if (_reply->error() == QNetworkReply::ProxyAuthenticationRequiredError) { qDebug() << Q_FUNC_INFO << _reply->rawHeader("Proxy-Authenticate"); } emit networkError(_reply); } // get the Date timestamp from reply _responseTimestamp = _reply->rawHeader("Date"); _duration = _durationTimer.elapsed(); if (_followRedirects) { // ### the qWarnings here should be exported via displayErrors() so they // ### can be presented to the user if the job executor has a GUI QUrl requestedUrl = reply()->request().url(); QUrl redirectUrl = reply()->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl(); if (!redirectUrl.isEmpty()) { _redirectCount++; if (requestedUrl.scheme() == QLatin1String("https") && redirectUrl.scheme() == QLatin1String("http")) { qWarning() << this << "HTTPS->HTTP downgrade detected!"; } else if (requestedUrl == redirectUrl || _redirectCount >= maxRedirects()) { qWarning() << this << "Redirect loop detected!"; } else { resetTimeout(); setReply(getRequest(redirectUrl)); setupConnections(reply()); return; } } } AbstractCredentials *creds = _account->credentials(); if (!creds->stillValid(_reply) && ! _ignoreCredentialFailure) { _account->handleInvalidCredentials(); } bool discard = finished(); if (discard) { deleteLater(); } }
void ConnectionValidator::checkAuthentication() { AbstractCredentials *creds = _account->credentials(); if (!creds->ready()) { // The user canceled reportResult(UserCanceledCredentials); } // simply GET the webdav root, will fail if credentials are wrong. // continue in slotAuthCheck here :-) qDebug() << "# Check whether authenticated propfind works."; PropfindJob *job = new PropfindJob(_account, "/", this); job->setProperties(QList<QByteArray>() << "getlastmodified"); connect(job, SIGNAL(result(QVariantMap)), SLOT(slotAuthSuccess())); connect(job, SIGNAL(networkError(QNetworkReply*)), SLOT(slotAuthFailed(QNetworkReply*))); job->start(); }
void AbstractCredentialsWizardPage::cleanupPage() { // Reset the credentials when the 'Back' button is used. // Unfortunately this code is also run when the Wizard finishes // prematurely with 'Skip Folder Configuration'. Therefore we need to // avoid resetting credentials on active accounts. AccountPtr account = static_cast<OwncloudWizard*>(wizard())->account(); if (account == AccountManager::instance()->account()) return; AbstractCredentials *creds = account->credentials(); if (creds) { if (!creds->inherits("DummyCredentials")) { account->setCredentials(CredentialsFactory::create("dummy")); } } }
void AbstractNetworkJob::slotFinished() { _timer.stop(); if( _reply->error() != QNetworkReply::NoError ) { qDebug() << Q_FUNC_INFO << _reply->error() << _reply->errorString(); if (_reply->error() == QNetworkReply::ProxyAuthenticationRequiredError) { qDebug() << Q_FUNC_INFO << _reply->rawHeader("Proxy-Authenticate"); } emit networkError(_reply); } // get the Date timestamp from reply _responseTimestamp = QString::fromAscii(_reply->rawHeader("Date")); _duration = _durationTimer.elapsed(); bool discard = finished(); AbstractCredentials *creds = _account->credentials(); if (!creds->stillValid(_reply) &&! _ignoreCredentialFailure && _account->state() != Account::InvalidCredidential) { _account->setState(Account::InvalidCredidential); // invalidate & forget token/password // but try to re-sign in. connect( creds, SIGNAL(fetched()), qApp, SLOT(slotCredentialsFetched()), Qt::UniqueConnection); if (creds->ready()) { creds->invalidateAndFetch(_account); } else { creds->fetch(_account); } } if (discard) { deleteLater(); } }
void AbstractNetworkJob::slotFinished() { _timer.stop(); if (_reply->error() == QNetworkReply::SslHandshakeFailedError) { qCWarning(lcNetworkJob) << "SslHandshakeFailedError: " << errorString() << " : can be caused by a webserver wanting SSL client certificates"; } if (_reply->error() != QNetworkReply::NoError) { if (!_ignoreCredentialFailure || _reply->error() != QNetworkReply::AuthenticationRequiredError) { qCWarning(lcNetworkJob) << _reply->error() << errorString() << _reply->attribute(QNetworkRequest::HttpStatusCodeAttribute); if (_reply->error() == QNetworkReply::ProxyAuthenticationRequiredError) { qCWarning(lcNetworkJob) << _reply->rawHeader("Proxy-Authenticate"); } } emit networkError(_reply); } // get the Date timestamp from reply _responseTimestamp = _reply->rawHeader("Date"); QUrl requestedUrl = reply()->request().url(); QUrl redirectUrl = reply()->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl(); if (_followRedirects && !redirectUrl.isEmpty()) { // Redirects may be relative if (redirectUrl.isRelative()) redirectUrl = requestedUrl.resolved(redirectUrl); // For POST requests where the target url has query arguments, Qt automatically // moves these arguments to the body if no explicit body is specified. // This can cause problems with redirected requests, because the redirect url // will no longer contain these query arguments. if (reply()->operation() == QNetworkAccessManager::PostOperation && requestedUrl.hasQuery() && !redirectUrl.hasQuery() && !_requestBody) { qCWarning(lcNetworkJob) << "Redirecting a POST request with an implicit body loses that body"; } // ### some of the qWarnings here should be exported via displayErrors() so they // ### can be presented to the user if the job executor has a GUI QByteArray verb = requestVerb(*reply()); if (requestedUrl.scheme() == QLatin1String("https") && redirectUrl.scheme() == QLatin1String("http")) { qCWarning(lcNetworkJob) << this << "HTTPS->HTTP downgrade detected!"; } else if (requestedUrl == redirectUrl || _redirectCount + 1 >= maxRedirects()) { qCWarning(lcNetworkJob) << this << "Redirect loop detected!"; } else if (_requestBody && _requestBody->isSequential()) { qCWarning(lcNetworkJob) << this << "cannot redirect request with sequential body"; } else if (verb.isEmpty()) { qCWarning(lcNetworkJob) << this << "cannot redirect request: could not detect original verb"; } else { emit redirected(_reply, redirectUrl, _redirectCount); // The signal emission may have changed this value if (_followRedirects) { _redirectCount++; // Create the redirected request and send it qCInfo(lcNetworkJob) << "Redirecting" << verb << requestedUrl << redirectUrl; resetTimeout(); if (_requestBody) { _requestBody->seek(0); } sendRequest( verb, redirectUrl, reply()->request(), _requestBody); return; } } } AbstractCredentials *creds = _account->credentials(); if (!creds->stillValid(_reply) && !_ignoreCredentialFailure) { _account->handleInvalidCredentials(); } bool discard = finished(); if (discard) { qCDebug(lcNetworkJob) << "Network job" << metaObject()->className() << "finished for" << path(); deleteLater(); } }