-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathFTPClientService.cpp
41 lines (29 loc) · 1.65 KB
/
FTPClientService.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "FTPClientService.h"
FTPClientService::FTPClientService(unsigned int nRecvSecTimeout) : ClientService(nRecvSecTimeout) {
this->nDefaultPort = FTP_CLIENT_SERVICE_DEFAULT_PORT;
this->nDefaultPortSSL = FTP_CLIENT_SERVICE_SSL_DEFAULT_PORT;
this->nDefaultPortTLS = FTP_CLIENT_SERVICE_TLS_DEFAULT_PORT;
this->sEndCommandLine = FTP_CLIENT_SERVICE_END_COMMAND_LINE;
this->bReceiveOnConnect = true;
}
bool FTPClientService::authCryptographicSecurity() {
this->bAuthCryptographicSecurity = true;
return this->bAuthCryptographicSecurity;
}
bool FTPClientService::authLoginUser() {
vector< pair<string, string> > * oStringTokens = new vector< pair<string, string> >();
this->bAuthLoginUser = false;
if (FString::trim(this->sLoginUsername).length() > 0) {
oStringTokens->push_back(pair<string, string>(GLOBAL_STF_FILE_ENCODE_NOTATION_LOGIN_USERNAME, this->sLoginUsername));
if (this->sendSocketData(FString::replaceTokens(FTP_CLIENT_SERVICE_AUTH_COMMAND_USER, oStringTokens) + this->getEndCommandLine())) {
this->recvSocketData();
oStringTokens->clear();
oStringTokens->push_back(pair<string, string>(GLOBAL_STF_FILE_ENCODE_NOTATION_LOGIN_PASSWORD, this->sLoginPassword));
if (this->sendSocketData(FString::replaceTokens(FTP_CLIENT_SERVICE_AUTH_COMMAND_PASSWORD, oStringTokens) + this->getEndCommandLine())) {
string sRecvSocketData = this->recvSocketData();
if (sRecvSocketData.find(FTP_CLIENT_SERVICE_AUTH_SUCCESS_REPLY_CODE) != string::npos) this->bAuthLoginUser = true;
}
}
}
return this->bAuthLoginUser;
}