void AMGithubManager::createNewIssue(const QString &title, const QString &body, const QString &assignee){ if(!isAuthenticated() || repository_.isEmpty() || createNewIssueReply_) return; QNetworkRequest request; QString issuesURL = "https://api.github.com/repos/"+repository_+"/issues"; request.setUrl(QUrl(issuesURL)); QString userInfo = userName_+":"+password_; QByteArray userData = userInfo.toLocal8Bit().toBase64(); QString headerData = "Basic " + userData; request.setRawHeader("Authorization", headerData.toLocal8Bit()); QVariantMap jdata; jdata["title"] = title; jdata["body"] = body; if(!assignee.isEmpty()) jdata["assignee"] = assignee; QJson::Serializer jserializer; QByteArray jsonData = jserializer.serialize(jdata); //qdebug() << jsonData; createNewIssueReply_ = manager_->post(request, jsonData); createNewIssueReply_->ignoreSslErrors(); connect(createNewIssueReply_, SIGNAL(readyRead()), this, SLOT(onCreateNewIssueReturned())); }
void LastFmService::init() { m_currentTrack = 0; bool enable = SETTINGS()->_useLastFmScrobbler; Debug::debug() << " [LastFmService] init enable " << enable; disconnect(Engine::instance(), 0,this, 0); /* load settings */ QSettings settings(UTIL::CONFIGFILE,QSettings::IniFormat,this); settings.beginGroup("Scrobbler"); LastFm::GLOBAL::username = settings.value("username", QString()).toString(); LastFm::GLOBAL::session_key = settings.value("key", QString()).toString(); LastFm::GLOBAL::api_key = "b3717637c18071e1619e92ee2c3eb0f8"; LastFm::GLOBAL::secret_key = "8192599d44d34b27c520d597d34f3714"; settings.endGroup(); if( enable && isAuthenticated() ) { connect(Engine::instance(), SIGNAL(engineStateChanged()), this, SLOT(slot_state_changed())); connect(Engine::instance(), SIGNAL(mediaChanged()), this, SLOT(slot_track_changed())); } /* change status for send love action */ ACTIONS()->value(LASTFM_LOVE)->setEnabled(enable); ACTIONS()->value(LASTFM_LOVE_NOW_PLAYING)->setEnabled(enable); }
const char * Authentication::getOwner() const { #if defined(SKIP_AUTHENTICATION) return NULL; #else // Since we never use getOwner() like it allocates memory // anywhere in the code, it shouldn't actually allocate // memory. We can always just return claimToBe, since it'll // either be NULL or the string we want, which is the old // semantics. -Derek Wright 3/12/99 const char *owner; if (authenticator_) { owner = authenticator_->getRemoteUser(); } else { owner = NULL; } // If we're authenticated, we should always have a valid owner if ( isAuthenticated() ) { if ( NULL == owner ) { EXCEPT( "Socket is authenticated, but has no owner!!" ); } } return owner; #endif }
void LYGithubManager::updateFileContents(const QString &path, const QString &commitMessage, const QString &contents, const QString &sha){ if(!isAuthenticated() || repository_.isEmpty() || updateFileContentsReply_) return; LYGithubProductBacklogStatusLog::statusLog()->appendStatusMessage("Starting updateFileContents request"); QNetworkRequest request; QString updateFileContentsURL = QString("https://api.github.com/repos/%1/contents/%2").arg(repository_).arg(path); request.setUrl(QUrl(updateFileContentsURL)); QString userInfo = userName_+":"+password_; QByteArray userData = userInfo.toLocal8Bit().toBase64(); QString headerData = "Basic " + userData; request.setRawHeader("Authorization", headerData.toLocal8Bit()); QVariantMap jdata; jdata["message"] = commitMessage; QByteArray encodedContent = contents.toLocal8Bit().toBase64(); jdata["content"] = encodedContent; jdata["sha"] = sha; QJson::Serializer jserializer; QByteArray jsonData = jserializer.serialize(jdata); QBuffer *buffer = new QBuffer; buffer->setData(jsonData); buffer->open(QIODevice::ReadOnly); updateFileContentsReply_ = manager_->sendCustomRequest(request, "PUT", buffer); buffer->setParent(updateFileContentsReply_); connect(updateFileContentsReply_, SIGNAL(readyRead()), this, SLOT(onUpdateFileContentsReturned())); }
void LYGithubManager::closeIssue(int issueNumber){ if(!isAuthenticated() || repository_.isEmpty() || closeIssueReply_) return; LYGithubProductBacklogStatusLog::statusLog()->appendStatusMessage("Starting closeIssue request"); QNetworkRequest request; QString commentURL = QString("https://api.github.com/repos/%1/issues/%2").arg(repository_).arg(issueNumber); request.setUrl(QUrl(commentURL)); QString userInfo = userName_+":"+password_; QByteArray userData = userInfo.toLocal8Bit().toBase64(); QString headerData = "Basic " + userData; request.setRawHeader("Authorization", headerData.toLocal8Bit()); QVariantMap jdata; jdata["state"] = "closed"; QJson::Serializer jserializer; QByteArray jsonData = jserializer.serialize(jdata); QBuffer *buffer = new QBuffer; buffer->setData(jsonData); buffer->open(QIODevice::ReadOnly); closeIssueReply_ = manager_->sendCustomRequest(request, "PATCH", buffer); buffer->setParent(closeIssueReply_); connect(closeIssueReply_, SIGNAL(readyRead()), this, SLOT(onCloseIssueReturned())); }
// Players void BF3Widget::updatePlayerList() { if (isAuthenticated()) { // con->sendAdminListPlayersCommand(All); } else { con->sendListPlayersCommand(PlayerSubset::All); } }
void FrostbiteClient::onConnected() { commandHandler->sendVersionCommand(); commandHandler->sendServerInfoCommand(); if (!isAuthenticated() && !serverEntry->getPassword().isEmpty()) { commandHandler->sendLoginHashedCommand(); } }
LastFmService::~LastFmService() { Debug::debug() << " [LastFmService] delete"; if(SETTINGS()->_useLastFmScrobbler && isAuthenticated()) scrobble(); //! save settings QSettings settings(UTIL::CONFIGFILE,QSettings::IniFormat,this); settings.beginGroup("Scrobbler"); settings.setValue("username", LastFm::GLOBAL::username); settings.setValue("key", LastFm::GLOBAL::session_key); settings.endGroup(); settings.sync(); }
bool Authentication::authenticate(){ bool authenticationSuccess = false; if (isAuthenticated()){ authenticationSuccess = true; markAuthenticated(); return authenticationSuccess; } QString password; do { const auto pinType = type==ADMIN? PinType::ADMIN_PIN : PinType::USER_PIN; PinDialog dialog(pinType); int ok = dialog.exec(); if (ok != QDialog::Accepted) { return authenticationSuccess; } auto password = dialog.getPassword(); tempPassword = generateTemporaryPassword(); try{ switch (pinType){ case PinType::USER_PIN: nm::instance()->user_authenticate(password.c_str(), tempPassword.constData()); break; case PinType::ADMIN_PIN: nm::instance()->first_authenticate(password.c_str(), tempPassword.constData()); break; default: break; } markAuthenticated(); authenticationSuccess = true; return authenticationSuccess; } catch (CommandFailedException &e){ if (!e.reason_wrong_password()) throw; csApplet()->warningBox(tr("Wrong PIN. Please try again.")); } } while (true); return authenticationSuccess; }
void CLdapSecUser::copyTo(ISecUser& destination) { CLdapSecUser* dest = dynamic_cast<CLdapSecUser*>(&destination); if(!dest) return; dest->setAuthenticated(isAuthenticated()); dest->setName(getName()); dest->setFullName(getFullName()); dest->setFirstName(getFirstName()); dest->setLastName(getLastName()); dest->setRealm(getRealm()); dest->credentials().setPassword(credentials().getPassword()); dest->setUserSid(m_usersid.length(), m_usersid.toByteArray()); dest->setUserID(m_userid); dest->setPasswordExpiration(m_passwordExpiration); }
/** * parse returned JSON data * check if user has authorized * then update list */ void EksigatorWindow::parseJson(QByteArray result) { QScriptValue sc; QScriptEngine engine; sc = engine.evaluate(QString(result)); //flush lists while (!updatedTitles.isEmpty()) { updatedTitles.removeFirst(); } while (!notUpdatedTitles.isEmpty()) { notUpdatedTitles.removeFirst(); } if(!isAuthenticated(sc)) { QString loginError = trUtf8("Giriş başarısız, e-postanızı ve API anahtarınızı kontrol edin"); this->ui->statusBar->showMessage(loginError,5000); } else { this->ui->statusBar->clearMessage(); //traverse in object if (sc.isArray()) { QScriptValueIterator it(sc); while (it.hasNext()) { it.next(); QString itemStatus = it.value().property("status").toString(); QString itemLastId = it.value().property("lastId").toString(); QString itemTitle = it.value().property("title").toString(); if( itemStatus.toInt() == 1 ) { updatedTitles << itemTitle; } else { notUpdatedTitles << itemTitle; } } } } }
void LYGithubManager::getFileContents(const QString &path){ if(!isAuthenticated() || repository_.isEmpty() || getFileContentsReply_) return; LYGithubProductBacklogStatusLog::statusLog()->appendStatusMessage("Starting getFileContents request"); QNetworkRequest request; QString fileContentsURL = QString("https://api.github.com/repos/%1/contents/%2").arg(repository_).arg(path); request.setUrl(QUrl(fileContentsURL)); QString userInfo = userName_+":"+password_; QByteArray userData = userInfo.toLocal8Bit().toBase64(); QString headerData = "Basic " + userData; request.setRawHeader("Authorization", headerData.toLocal8Bit()); getFileContentsReply_ = manager_->get(request); connect(getFileContentsReply_, SIGNAL(readyRead()), this, SLOT(onGetFileContentsReturned())); }
//functions UtlBoolean SubscribeServerThread::handleMessage(OsMsg& eventMessage) { // Only handle SIP messages if (eventMessage.getMsgType() != OsMsg::PHONE_APP || eventMessage.getMsgSubType() != SipMessage::NET_SIP_MESSAGE) { return FALSE ; } const SipMessage* message = ((SipMessageEvent&)eventMessage).getMessage(); UtlString userKey; UtlString uri; SipMessage finalResponse; // Test for request/response processing code path if (!message->isResponse()) { // this is a request, so authenticate and authorize the request if ( isValidDomain( message, &finalResponse ) ) { UtlString eventPackage; UtlString id; UtlHashMap otherParams; message->getEventField(&eventPackage, &id, &otherParams); StatusPluginReference* pluginContainer = mPluginTable->getPlugin( eventPackage ); if( pluginContainer ) { //check in credential database if authentication needed UtlString authenticatedUser, authenticatedRealm; if( isAuthenticated ( message, &finalResponse, authenticatedUser, authenticatedRealm ) ) { if ( isAuthorized ( message, &finalResponse, pluginContainer ) ) { // fetch the plugin SubscribeServerPluginBase* plugin = pluginContainer->getPlugin(); if (plugin) { int timeNow = (int)OsDateTime::getSecsSinceEpoch(); int grantedExpiration; UtlString newToTag; // add the subscription to the IMDB SubscribeStatus isSubscriptionAdded = addSubscription(timeNow, message, mDefaultDomain, eventPackage, id, otherParams, newToTag, grantedExpiration); otherParams.destroyAll(); switch ( isSubscriptionAdded ) { case STATUS_SUCCESS: // create response - 202 Accepted Response finalResponse.setResponseData( message, SIP_ACCEPTED_CODE, SIP_ACCEPTED_TEXT); // Set the granted subscription time. finalResponse.setExpiresField(grantedExpiration); plugin->handleSubscribeRequest( *message, finalResponse, authenticatedUser.data(), authenticatedRealm.data(), mDefaultDomain.data()); // ensure that the contact returned will route back to here // (the default supplied by SipUserAgent will not). { UtlString requestUri; message->getRequestUri(&requestUri); finalResponse.setContactField(requestUri); } break; case STATUS_TO_BE_REMOVED: // create response - 202 Accepted Response finalResponse.setResponseData( message, SIP_ACCEPTED_CODE, SIP_ACCEPTED_TEXT); // Set the granted subscription time. finalResponse.setExpiresField(grantedExpiration); plugin->handleSubscribeRequest( *message, finalResponse, authenticatedUser.data(), authenticatedRealm.data(), mDefaultDomain.data()); // ensure that the contact returned will route back to here // (the default supplied by SipUserAgent will not). { UtlString requestUri; message->getRequestUri(&requestUri); finalResponse.setContactField(requestUri); } // Now that final NOTIFY has been sent, remove row removeSubscription(message); break; case STATUS_LESS_THAN_MINEXPIRES: // (already logged in addSubscription) // send 423 Subscription Too Brief response finalResponse.setResponseData( message, SIP_TOO_BRIEF_CODE, SIP_TOO_BRIEF_TEXT ); finalResponse.setHeaderValue( SIP_MIN_EXPIRES_FIELD, mMinExpiresTimeStr, 0 ); break; case STATUS_INVALID_REQUEST: OsSysLog::add(FAC_SIP, PRI_ERR, "SubscribeServerThread::handleMessage()" "Subscription Could Not Be Added " SIP_BAD_REQUEST_TEXT ); finalResponse.setResponseData( message, SIP_BAD_REQUEST_CODE, SIP_BAD_REQUEST_TEXT ); break; case STATUS_FORBIDDEN: OsSysLog::add(FAC_SIP, PRI_ERR, "SubscribeServerThread::handleMessage()" "Subscription Could Not Be Added " SIP_FORBIDDEN_TEXT ); finalResponse.setResponseData( message, SIP_FORBIDDEN_CODE, SIP_FORBIDDEN_TEXT); break; case STATUS_NOT_FOUND: OsSysLog::add(FAC_SIP, PRI_ERR, "SubscribeServerThread::handleMessage()" "Subscription Could Not Be Added " SIP_NOT_FOUND_TEXT ); finalResponse.setResponseData( message, SIP_NOT_FOUND_CODE, SIP_NOT_FOUND_TEXT ); break; case STATUS_BAD_SUBSCRIPTION: // send 481 Subscription Does Not Exist response OsSysLog::add(FAC_SIP, PRI_DEBUG, "SubscribeServerThread::handleMessage()" "Subscription to be renewed does not exist " SIP_BAD_SUBSCRIPTION_TEXT ); finalResponse.setResponseData( message, SIP_BAD_SUBSCRIPTION_CODE, SIP_BAD_SUBSCRIPTION_TEXT ); break; case STATUS_INTERNAL_ERROR: default: OsSysLog::add(FAC_SIP, PRI_ERR, "SubscribeServerThread::handleMessage()" "Subscription Could Not Be Added " "Status %d from addSubscription", isSubscriptionAdded ); finalResponse.setResponseData( message, SIP_SERVER_INTERNAL_ERROR_CODE, "Subscription database error" ); } // Apply the new to-tag, if any, to the response. if (!newToTag.isNull()) { finalResponse.setToFieldTag(newToTag); } } else { OsSysLog::add(FAC_SIP, PRI_CRIT, "SubscribeServerThread::handleMessage()" " container->getPlugin failed for '%s'", eventPackage.data() ); finalResponse.setResponseData( message, SIP_SERVER_INTERNAL_ERROR_CODE, SIP_SERVER_INTERNAL_ERROR_TEXT ); } } else { // not authorized - the response was created in isAuthorized } } else { // not authenticated - the response was created in isAuthenticated } } else // no plugin found for this event type { OsSysLog::add(FAC_SIP, PRI_WARNING, "SubscribeServerThread::handleMessage()" " Request denied - " SIP_BAD_EVENT_TEXT ); finalResponse.setResponseData( message, SIP_BAD_EVENT_CODE, "Event type not supported" ); } // send final response UtlString finalMessageStr; ssize_t finalMessageLen; finalResponse.getBytes(&finalMessageStr, &finalMessageLen); OsSysLog::add(FAC_SIP, PRI_DEBUG, "\n----------------------------------\n" "Sending final response\n%s",finalMessageStr.data()); mpSipUserAgent->setUserAgentHeader( finalResponse ); mpSipUserAgent->send( finalResponse ); } else // Invalid domain { const char* notFoundMsg = SIP_NOT_FOUND_TEXT " Invalid Domain"; finalResponse.setResponseData(message, SIP_NOT_FOUND_CODE, notFoundMsg ); mpSipUserAgent->setUserAgentHeader( finalResponse ); mpSipUserAgent->send( finalResponse ); } } else // response { // The server may send us back a "481" response, if it does we need // to remove the subscription from the SubscriptionDB as the callid // that it corresponds to is stale (probably the phone was rebooted) // In the above case, RFC 3265 says we MUST remove the subscription. // It also says (essentially) that any error that does not imply a retry // SHOULD remove the subscription. We will interpret this to be any // 4xx code _except_ 408 timeout (because that may be a transient error). int responseCode = message->getResponseStatusCode(); if ( responseCode >= SIP_4XX_CLASS_CODE && responseCode != SIP_REQUEST_TIMEOUT_CODE ) { // remove the subscription removeErrorSubscription ( *message ); } } return TRUE; }
void LYGithubManager::getIssues(LYGithubManager::IssuesFilter filter, LYGithubManager::IssuesState state, LYGithubManager::IssuesSort sort, LYGithubManager::IssuesDirection direction, int page){ if(!isAuthenticated() || repository_.isEmpty() || getIssuesReply_) return; LYGithubProductBacklogStatusLog::statusLog()->appendStatusMessage("Starting getIssues request"); fullIssuesReply_.clear(); QNetworkRequest request; QString issuesURL = "https://api.github.com/repos/"+repository_+"/issues"; QString issuesOptions = "?"; issuesOptions.append("filter="); switch(filter){ case LYGithubManager::IssuesFilterAssigned: issuesOptions.append("assigned&"); break; case LYGithubManager::IssuesFilterCreated: issuesOptions.append("created&"); break; case LYGithubManager::IssuesFilterMentioned: issuesOptions.append("mentioned&"); break; case LYGithubManager::IssuesFilterSubscribed: issuesOptions.append("subscribed&"); break; case LYGithubManager::IssuesFilterAll: issuesOptions.append("all&"); break; default: issuesOptions.append("all&"); } issuesOptions.append("state="); switch(state){ case LYGithubManager::IssuesStateOpen: issuesOptions.append("open&"); break; case LYGithubManager::IssuesStateClosed: issuesOptions.append("closed&"); break; default: issuesOptions.append("open&"); } issuesOptions.append("sort="); switch(sort){ case LYGithubManager::IssuesSortCreated: issuesOptions.append("created&"); break; case LYGithubManager::IssuesSortUpdated: issuesOptions.append("updated&"); break; case LYGithubManager::IssuesSortComments: issuesOptions.append("comments&"); break; } issuesOptions.append("direction="); switch(direction){ case LYGithubManager::IssuesDirectionAscending: issuesOptions.append("asc&"); break; case LYGithubManager::IssuesDirectionDescending: issuesOptions.append("desc&"); break; } issuesOptions.append(QString("page=%1&").arg(page)); // Above per_page=45 Qt seems to freak out for some reason. // The qjson parser freaks out if the string coming back is too big it seems. Tried some testing and it was inconclusive, it managed a QByteArray of 149904 but died after one of 118460. // Keeping this count lower and making sure there aren't ridiculously big comments is the solution right now. issuesOptions.append("per_page=30"); lastGetIssuesRequest_ = issuesURL+issuesOptions; request.setUrl(QUrl(issuesURL+issuesOptions)); QString userInfo = userName_+":"+password_; QByteArray userData = userInfo.toLocal8Bit().toBase64(); QString headerData = "Basic " + userData; request.setRawHeader("Authorization", headerData.toLocal8Bit()); getIssuesReply_ = manager_->get(request); connect(getIssuesReply_, SIGNAL(readyRead()), this, SLOT(onIssuesReturned())); }
void BF3::onConnected() { if (!isAuthenticated() && !serverEntry->password.isEmpty()) { con->sendLoginHashedCommand(); } }
auto v11SecretKey = SecretKey::fromSeed(sha256("v11")); SCPQuorumSet n0_qset; n0_qset.threshold = 1; n0_qset.validators.push_back(v10SecretKey.getPublicKey()); auto n0 = s->getNode(s->addNode(v10SecretKey, n0_qset, s->getClock())); SCPQuorumSet n1_qset; n1_qset.threshold = 1; n1_qset.validators.push_back(v11SecretKey.getPublicKey()); auto n1 = s->getNode(s->addNode(v11SecretKey, n1_qset, s->getClock())); s->addPendingConnection(v10SecretKey.getPublicKey(), v11SecretKey.getPublicKey()); s->startAllNodes(); s->crankForAtLeast(std::chrono::seconds(1), false); auto p0 = n0->getOverlayManager().getConnectedPeer( "127.0.0.1", n1->getConfig().PEER_PORT); auto p1 = n1->getOverlayManager().getConnectedPeer( "127.0.0.1", n0->getConfig().PEER_PORT); REQUIRE(p0); REQUIRE(p1); REQUIRE(p0->isAuthenticated()); REQUIRE(p1->isAuthenticated()); s->stopAllNodes(); } }
void BF3::onLoginHashedCommand(const QByteArray &salt) { if (!isAuthenticated() && !serverEntry->password.isEmpty()) { con->sendLoginHashedCommand(salt, serverEntry->password); } }
Joschy::ActionReply YouTubeProvider::upload(const QString &login, Joschy::Video *video) { Joschy::ActionReply reply; if (!isAuthenticated(login)) { reply.setErrorType(Plugin::NotAuthenticatedError); reply.setErrorString(tr("You need to authenticate first")); } QFile file(video->url().toString()); if (!file.exists()) { reply.setErrorType(Plugin::FileNotFoundError); reply.setErrorString(tr("Video %1: No such file or directory").arg(video->url().toString())); } if (!file.open(QIODevice::ReadOnly)) { reply.setErrorType(Plugin::CannotOpenError); reply.setErrorString(file.errorString()); } if (reply.error()) { return reply; } const bool bigVideo = (file.size() > (1024*1024)*10); const QString title = video->title(); const QString description = video->description(); const QString category = m_categorys.key(video->category()); const QString keywords = video->keywords().join(", "); const QString slug = file.fileName().right(file.fileName().lastIndexOf(QDir::separator())+1); const QUrl url("http://uploads.gdata.youtube.com/feeds/api/users/"+login+"/uploads"); const QByteArray mime = "application/octet-stream"; // TODO const QByteArray CRLF = "\r\n"; const QByteArray BOUNDARY = "f93dcbA3"; QString XML = "<?xml version=\"1.0\"?>"+CRLF+\ "<entry xmlns=\"http://www.w3.org/2005/Atom\""+CRLF+\ "xmlns:media=\"http://search.yahoo.com/mrss/\""+CRLF+\ "xmlns:yt=\"http://gdata.youtube.com/schemas/2007\">"+CRLF+\ "<media:group>"+CRLF+\ "<media:title type=\"plain\">%1</media:title>"+CRLF+\ "<media:description type=\"plain\">"+CRLF+\ "%2."+CRLF+\ "</media:description>"+CRLF+\ "<media:category"+CRLF+\ "scheme=\"http://gdata.youtube.com/schemas/2007/categories.cat\">%3"+CRLF+\ "</media:category>"+CRLF+\ "<media:keywords>%4</media:keywords>"+CRLF+\ "</media:group>"+CRLF+\ "</entry>"; XML = XML.arg(title).arg(description).arg(category).arg(keywords); QByteArray postData; postData.append("--"+BOUNDARY); postData.append(CRLF); postData.append("Content-Type: application/atom+xml; charset=UTF-8"); postData.append(CRLF); postData.append(CRLF); postData.append(XML.toLatin1()); postData.append(CRLF); postData.append("--"+BOUNDARY); postData.append(CRLF); postData.append("Content-Type: "+mime); postData.append(CRLF); postData.append("Content-Transfer-Encoding: binary"); postData.append(CRLF); postData.append(CRLF); QByteArray bottom = CRLF; bottom.append("--"+BOUNDARY+"--"); bottom.append(CRLF); if (!bigVideo) { postData.append(file.readAll()); postData.append(bottom); } file.close(); QHash<QByteArray, QByteArray> header; header["Authorization"] = "GoogleLogin auth="+m_tokens[login].toLatin1(); header["GData-Version"] = "2"; header["X-GData-Key"] = "key="+QString(DEV_KEY).toLatin1(); header["Connection"] = "close"; header["Slug"] = slug.toLatin1(); header["Content-Type"] = "multipart/related; boundary=\""+BOUNDARY+"\""; QString id; if (!bigVideo) { header["Content-Length"] = QString::number(postData.size()).toLatin1(); id = layer()->post(url, header, postData); } else { Joschy::PostFile *data = new Joschy::PostFile(file.fileName()); data->setData(postData, bottom); header["Content-Length"] = QString::number(data->size()).toLatin1(); id = layer()->post(url, header, data); m_postFiles[id] = data; } m_actions.insert(id, ResponseParser::UploadType); reply.setId(id); return reply; }
void AMGithubManager::getIssues(AMGithubManager::IssuesFilter filter, AMGithubManager::IssuesState state, AMGithubManager::IssuesSort sort, AMGithubManager::IssuesDirection direction){ if(!isAuthenticated() || repository_.isEmpty() || getIssuesReply_) return; QNetworkRequest request; QString issuesURL = "https://api.github.com/repos/"+repository_+"/issues"; QString issuesOptions = "?"; switch(filter){ issuesOptions.append("filter="); case AMGithubManager::IssuesFilterAssigned: issuesOptions.append("assigned&"); break; case AMGithubManager::IssuesFilterCreated: issuesOptions.append("created&"); break; case AMGithubManager::IssuesFilterMentioned: issuesOptions.append("mentioned&"); break; case AMGithubManager::IssuesFilterSubscribed: issuesOptions.append("subscribed&"); break; } switch(state){ issuesOptions.append("state="); case AMGithubManager::IssuesStateOpen: issuesOptions.append("open&"); break; case AMGithubManager::IssuesStateClosed: issuesOptions.append("closed&"); break; } switch(sort){ issuesOptions.append("sort="); case AMGithubManager::IssuesSortCreated: issuesOptions.append("created&"); break; case AMGithubManager::IssuesSortUpdated: issuesOptions.append("updated&"); break; case AMGithubManager::IssuesSortComments: issuesOptions.append("comments&"); break; } switch(direction){ issuesOptions.append("direction="); case AMGithubManager::IssuesDirectionAscending: issuesOptions.append("asc"); break; case AMGithubManager::IssuesDirectionDescending: issuesOptions.append("desc"); break; } request.setUrl(QUrl(issuesURL+issuesOptions)); QString userInfo = userName_+":"+password_; QByteArray userData = userInfo.toLocal8Bit().toBase64(); QString headerData = "Basic " + userData; request.setRawHeader("Authorization", headerData.toLocal8Bit()); getIssuesReply_ = manager_->get(request); connect(getIssuesReply_, SIGNAL(readyRead()), this, SLOT(onIssuesReturned())); }
void ClientThread::analizeCommand(QByteArray &bytearray){ QString userName; if (bytearray.contains("USER")) { QRegExp rx("^USER\\s(.*)"); rx.indexIn(bytearray); userName = rx.cap(1); mUser = User::getUser(userName); sendString(FTPProtocol::getInstance()->getResponse(331)); return; } if (bytearray.contains("PASS")) { QRegExp rx("^PASS\\s(.*)"); rx.indexIn(bytearray); QString pass = rx.cap(1); if (mUser.isNull()) { sendString(FTPProtocol::getInstance()->getResponse(503,"PASS send before USER")); } else { if (mUser.auth(pass)) { // logged in sendString(FTPProtocol::getInstance()->getResponse(230)); setAuthenticated(true); if (ftpFileSystem != NULL) delete ftpFileSystem; ftpFileSystem = new FtpFileSystem(mUser.getFolder(), mUser.getFileAccess()); } else { // incorrect sendString(FTPProtocol::getInstance()->getResponse(530)); } } return; } if (isAuthenticated()) { // RNFR -> RNTO sequence if (mRenameBeginned){ if (bytearray.contains("RNTO")){ QRegExp rx("^RNTO\\s(.*)"); rx.indexIn(fromEncoding(bytearray)); QString newName = rx.cap(1); mRenameBeginned = false; if (ftpFileSystem->rename(mRenameOldName, newName)) sendString(FTPProtocol::getInstance()->getResponse(250)); else sendString(FTPProtocol::getInstance()->getResponse(550)); return; } sendString(FTPProtocol::getInstance()->getResponse(503)); return; } if (bytearray.contains("SYST")){ QString syst("Windows Type : L8"); sendString(FTPProtocol::getInstance()->getResponse(215, syst)); return; } if (bytearray.contains("FEAT")){ QString syst("211-Features:\n\rMDTM\n\rREST STREAM\n\rSIZE\n\rMLST type*;size*;modify*;\n\rMLSD\n\rUTF8\n\rCLNT\n\rMFMT\n\r211 End"); sendString(syst); return; } if (bytearray.contains("HELP")){ QString syst("HELP OK"); sendString(FTPProtocol::getInstance()->getResponse(214, syst)); return; } if (bytearray.contains("PWD")){ sendString(FTPProtocol::getInstance()->getResponse(257, toEncoding("\""+ftpFileSystem->getWorkingDirectory()+"\""))); return; } if (bytearray.contains("OPTS")){ QRegExp rx("^OPTS ([\\w\\s]+)"); rx.indexIn(bytearray); QRegExp rx2("^UTF8 (\\w+)"); rx2.indexIn(rx.cap(1)); if (rx2.cap(1) == "ON") { mIsUTF8 = true; } if (rx2.cap(1) == "OFF") { mIsUTF8 = false; } sendString(FTPProtocol::getInstance()->getResponse(200)); return; } if (bytearray.contains("TYPE")){ // set transfer type QRegExp rx("^TYPE (\\w)( (\\w))?"); rx.indexIn(bytearray); qDebug() << "type" << rx.cap(1) << rx.cap(3); mType = rx.cap(1); sendString(FTPProtocol::getInstance()->getResponse(200)); return; if (mType == "I") { sendString(FTPProtocol::getInstance()->getResponse(200)); } else { sendString(FTPProtocol::getInstance()->getResponse(550)); } return; } if (bytearray.contains("PORT")){ mIsActiveMode = true; QRegExp rx("^PORT (\\d+),(\\d+),(\\d+),(\\d+),(\\d+),(\\d+)"); rx.indexIn(bytearray); int p1,p2; QString buf(rx.cap(5)); bool flag; p1 = rx.cap(5).toInt(&flag); p2 = rx.cap(6).toInt(&flag); QString addr = rx.cap(1)+"."+rx.cap(2)+"."+rx.cap(3)+"."+rx.cap(4); active_addr = addr; active_port = p1*256+p2; sendString(FTPProtocol::getInstance()->getResponse(200, "Port ok")); return; } if (bytearray.contains("LIST")){ sendString(FTPProtocol::getInstance()->getResponse(150)); sendList(); sendString(FTPProtocol::getInstance()->getResponse(226)); return; } if (bytearray.contains("QUIT")){ sendString(FTPProtocol::getInstance()->getResponse(221)); closeconnection(); return; } if (bytearray.contains("CDUP")){ if (ftpFileSystem->cdUp()) sendString(FTPProtocol::getInstance()->getResponse(250)); else sendString(FTPProtocol::getInstance()->getResponse(550)); return; } if (bytearray.contains("CWD")){ QRegExp rx("^CWD\\s(.*)"); rx.indexIn(fromEncoding(bytearray)); QString subFolder = rx.cap(1); if (ftpFileSystem->changeDir(subFolder)) sendString(FTPProtocol::getInstance()->getResponse(250)); else sendString(FTPProtocol::getInstance()->getResponse(550)); return; } if (bytearray.contains("RETR")){ QRegExp rx("^RETR\\s(.*)"); rx.indexIn(fromEncoding(bytearray)); QString filename = rx.cap(1); QString fullFileName = ftpFileSystem->getFileRead(filename); if (fullFileName != NULL) { sendString(FTPProtocol::getInstance()->getResponse(150)); sendFile(fullFileName); } else { sendString(FTPProtocol::getInstance()->getResponse(550,"Permission denied")); } return; } if (bytearray.contains("STOR")){ QRegExp rx("^STOR\\s(.*)"); rx.indexIn(fromEncoding(bytearray)); QString filename = rx.cap(1); QString fullFileName = ftpFileSystem->getFileWrite(filename); if (fullFileName != NULL) { sendString(FTPProtocol::getInstance()->getResponse(150)); recvFile(fullFileName); } else { sendString(FTPProtocol::getInstance()->getResponse(550,"Permission denied")); } return; } if (bytearray.contains("RMD")){ QRegExp rx("^RMD\\s(.*)"); rx.indexIn(fromEncoding(bytearray)); QString filename = rx.cap(1); if (ftpFileSystem->removeDir(filename)) sendString(FTPProtocol::getInstance()->getResponse(250)); else sendString(FTPProtocol::getInstance()->getResponse(550)); return; } if (bytearray.contains("DELE")){ QRegExp rx("^DELE\\s(.*)"); rx.indexIn(fromEncoding(bytearray)); QString filename = rx.cap(1); if (ftpFileSystem->deleteFile(filename)) sendString(FTPProtocol::getInstance()->getResponse(250)); else sendString(FTPProtocol::getInstance()->getResponse(550)); return; } if (bytearray.contains("MKD")){ QRegExp rx("^MKD\\s(.*)"); rx.indexIn(fromEncoding(bytearray)); QString dirName = rx.cap(1); if (ftpFileSystem->mkDir(dirName)) sendString(FTPProtocol::getInstance()->getResponse(250)); else sendString(FTPProtocol::getInstance()->getResponse(550)); return; } if (bytearray.contains("PASV")){ mIsActiveMode = false; selectPassivePort(); return; } if (bytearray.contains("SIZE")){ QRegExp rx("^SIZE\\s(.*)"); rx.indexIn(fromEncoding(bytearray)); QString fileName = rx.cap(1); qint64 size; if (ftpFileSystem->getSize(fileName, &size)) { sendString(FTPProtocol::getInstance()->getResponse(250, QString::number(size))); } else { sendString(FTPProtocol::getInstance()->getResponse(550)); } return; } if (bytearray.contains("MDTM")){ QRegExp rx("^MDTM\\s(.*)"); rx.indexIn(fromEncoding(bytearray)); QString fileName = rx.cap(1); QString sdate = ftpFileSystem->getLastModified(fileName); if (sdate != NULL) { sendString(FTPProtocol::getInstance()->getResponse(250, sdate)); } else { sendString(FTPProtocol::getInstance()->getResponse(550)); } return; } if (bytearray.contains("RNFR")){ QRegExp rx("^RNFR\\s(.*)"); rx.indexIn(fromEncoding(bytearray)); mRenameOldName = rx.cap(1); if (ftpFileSystem->exist(mRenameOldName) && ftpFileSystem->isWritable(mRenameOldName)) { sendString(FTPProtocol::getInstance()->getResponse(350)); mRenameBeginned = true; } else sendString(FTPProtocol::getInstance()->getResponse(550, "Permission denied")); return; } sendString(FTPProtocol::getInstance()->getResponse(500)); } else sendString(FTPProtocol::getInstance()->getResponse(530)); }
void FrostbiteClient::onLoginHashedCommand(const QByteArray &salt) { if (!isAuthenticated() && !serverEntry->getPassword().isEmpty()) { commandHandler->sendLoginHashedCommand(salt, serverEntry->getPassword()); } }