| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508 |
- #include "sso.h"
- SSO::SSO(QString host, QString port)
- {
- this->server_host = host;
- this->server_path = "/wsdl";
- this->server_url = "http://"+this->server_host+this->server_path;
- QRegExp exp("\\d{1,4}");
- if(exp.exactMatch(port))
- {
- //this->server_port = port.toInt();
- this->server_port = 86;
- }
- else
- {
- this->server_port = 80;
- }
- m_cancel = false;
- }
- void SSO::onCanceled()
- {
- m_cancel = true;
- emit responseProcessed();
- if(json.isEmpty())
- json = "ABORT";
- }
- QString SSO::userLogin(QString userCode, QString userPwd, QString src,QString mcode)
- {
- this->json = "";
- QObject::connect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- QObject::connect(this, SIGNAL(responseProcessed()),&loop, SLOT(quit()));
- QString md5;
- QByteArray ba;
- ba = QCryptographicHash::hash ( userPwd.toAscii(), QCryptographicHash::Md5 );
- md5.append(ba.toHex());
- setLoginRequest(userCode,md5, src,mcode);
- loop.exec();
- QObject::disconnect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- return json;
- }
- QString SSO::userLogout(QString userHash, QString src,QString mcode)
- {
- this->json = "";
- QObject::connect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- QObject::connect(this, SIGNAL(responseProcessed()),&loop, SLOT(quit()));
- setLogoutRequest(userHash,src,mcode);
- loop.exec();
- QObject::disconnect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- return json;
- }
- QString SSO::heartBeat(QString userHash,QString src,QString refreshStamp,QString mcode)
- {
- this->json = "";
- QObject::connect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- QObject::connect(this, SIGNAL(responseProcessed()),&loop, SLOT(quit()));
- setHeartBeatRequest(userHash,src,refreshStamp,mcode);
- loop.exec();
- QObject::disconnect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- return json;
- }
- QString SSO::regSysAccount(QString sysCode, QString userHash,QString regSrc)
- {
- this->json = "";
- QObject::connect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- QObject::connect(this, SIGNAL(responseProcessed()),&loop, SLOT(quit()));
- setRegSysAccountRequest(sysCode,userHash,regSrc);
- loop.exec();
- QObject::disconnect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- return json;
- }
- QString SSO::bindSysAccount(QString sysCode, QString bindUserCode, QString bindUserPwd, QString userHash)
- {
- this->json = "";
- QObject::connect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- QObject::connect(this, SIGNAL(responseProcessed()),&loop, SLOT(quit()));
- QString md5;
- QByteArray ba;
- ba = QCryptographicHash::hash ( bindUserPwd.toAscii(), QCryptographicHash::Md5 );
- md5.append(ba.toHex());
- setBindSysAccountRequest(sysCode,bindUserCode,md5,userHash);
- loop.exec();
- QObject::disconnect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- return json;
- }
- QString SSO::getSysAccount(QString sysCode, QString userHash)
- {
- this->json = "";
- QObject::connect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- QObject::connect(this, SIGNAL(responseProcessed()),&loop, SLOT(quit()));
- setGetSysAccountRequest(sysCode,userHash);
- loop.exec();
- QObject::disconnect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- return json;
- }
- QString SSO::getUserSSO(QString userHash)
- {
- this->json = "";
- QObject::connect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- QObject::connect(this, SIGNAL(responseProcessed()),&loop, SLOT(quit()));
- setGetUserSSORequest(userHash);
- loop.exec();
- QObject::disconnect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- return json;
- }
- QString SSO::getMfPayInfo(QString dateStart, QString dateEnd, QString userHash)
- {
- this->json = "";
- QObject::connect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- QObject::connect(this, SIGNAL(responseProcessed()),&loop, SLOT(quit()));
- setGetMfPayInfoRequest(dateStart,dateEnd,userHash);
- loop.exec();
- QObject::disconnect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- return json;
- }
- QString SSO::getTransferInfo(QString dateStart, QString dateEnd, QString userHash)
- {
- this->json = "";
- QObject::connect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- QObject::connect(this, SIGNAL(responseProcessed()),&loop, SLOT(quit()));
- setGetTransferInfoRequest(dateStart,dateEnd,userHash);
- loop.exec();
- QObject::disconnect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- return json;
- }
- QString SSO::userTransfer(QString sndsyscode, QString rcvsyscode, QString trsfmoney, QString trsfmemo, QString userHash)
- {
- this->json = "";
- QObject::connect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- QObject::connect(this, SIGNAL(responseProcessed()),&loop, SLOT(quit()));
- setUserTransferRequest(sndsyscode,rcvsyscode,trsfmoney,trsfmemo,userHash);
- loop.exec();
- QObject::disconnect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- return json;
- }
- QString SSO::mfUserPay(QString func, QString userHash)
- {
- this->json = "";
- QObject::connect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- QObject::connect(this, SIGNAL(responseProcessed()),&loop, SLOT(quit()));
- setMfUserPay(func,userHash);
- loop.exec();
- QObject::disconnect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- return json;
- }
- QString SSO::userReg(QString userCode, QString userPwd, QString detailInfo, QString src,QString mcode,QString authCode,QString regType)
- {
- this->json = "";
- QObject::connect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- QObject::connect(this, SIGNAL(responseProcessed()),&loop, SLOT(quit()));
- setUserRegRequest(userCode, userPwd, detailInfo, src,mcode, authCode,regType);
- loop.exec();
- QObject::disconnect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- return json;
- }
- QString SSO::editUserInfo(QString detailInfo, QString userHash)
- {
- this->json = "";
- QObject::connect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- QObject::connect(this, SIGNAL(responseProcessed()),&loop, SLOT(quit()));
- setEditUserInfoRequest(detailInfo, userHash);
- loop.exec();
- QObject::disconnect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- return json;
- }
- QString SSO::getMFUserInfo(QString userHash)
- {
- this->json = "";
- QObject::connect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- QObject::connect(this, SIGNAL(responseProcessed()),&loop, SLOT(quit()));
- setGetMFUserInfoRequest(userHash);
- loop.exec();
- QObject::disconnect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- return json;
- }
- QString SSO::getMFUserBalance(QString userHash)
- {
- this->json = "";
- QObject::connect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- QObject::connect(this, SIGNAL(responseProcessed()),&loop, SLOT(quit()));
- setGetMFUserBalanceRequest(userHash);
- loop.exec();
- QObject::disconnect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- return json;
- }
- QString SSO::changePass(QString oldPassword, QString newPassword, QString userHash)
- {
- this->json = "";
- QObject::connect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- QObject::connect(this, SIGNAL(responseProcessed()),&loop, SLOT(quit()));
- QString md51;
- QByteArray ba1;
- ba1 = QCryptographicHash::hash ( oldPassword.toAscii(), QCryptographicHash::Md5 );
- md51.append(ba1.toHex());
- QString md52;
- QByteArray ba2;
- ba2 = QCryptographicHash::hash ( newPassword.toAscii(), QCryptographicHash::Md5 );
- md52.append(ba2.toHex());
- setChangePassRequest(md51,md52,userHash);
- loop.exec();
- QObject::disconnect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- return json;
- }
- QString SSO::getSysParam(QString src,QString authCode)
- {
- this->json = "";
- QObject::connect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- QObject::connect(this, SIGNAL(responseProcessed()),&loop, SLOT(quit()));
- setGetSysParamsRequest(src,authCode);
- loop.exec();
- QObject::disconnect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- return json;
- }
- QString SSO::getServerTime(QString authCode)
- {
- this->json = "";
- QObject::connect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- QObject::connect(this, SIGNAL(responseProcessed()),&loop, SLOT(quit()));
- setGetServerTimeRequest(authCode);
- loop.exec();
- QObject::disconnect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- return json;
- }
- QString SSO::encrypt(QString data, QString authCode, QString key)
- {
- this->json = "";
- QObject::connect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- QObject::connect(this, SIGNAL(responseProcessed()),&loop, SLOT(quit()));
- setEncryptRequest(data,authCode,key);
- loop.exec();
- QObject::disconnect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- return json;
- }
- QString SSO::decrypt(QString data, QString authCode, QString key)
- {
- this->json = "";
- QObject::connect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- QObject::connect(this, SIGNAL(responseProcessed()),&loop, SLOT(quit()));
- setDecryptRequest(data,authCode,key);
- loop.exec();
- QObject::disconnect(&http, SIGNAL(responseReady()),this, SLOT(getResponse()));
- return json;
- }
- void SSO::setLoginRequest(QString userCode, QString userPwd, QString src,QString mcode)
- {
- QtSoapMessage request;
- request.setMethod("UserLogin", this->server_url);
- request.addMethodArgument("userCode","",userCode);
- request.addMethodArgument("userPwd", "",userPwd);
- request.addMethodArgument("src","",src);
- request.addMethodArgument("mcode","",mcode);
- http.setHost(this->server_host,this->server_port);
- http.submitRequest(request,this->server_path);
- }
- void SSO::setLogoutRequest(QString userHash, QString src,QString mcode)
- {
- QtSoapMessage request;
- request.setMethod("UserLogout", this->server_url);
- request.addMethodArgument("userHash","",userHash);
- request.addMethodArgument("src","",src);
- request.addMethodArgument("mcode","",mcode);
- http.setHost(this->server_host,this->server_port);
- http.submitRequest(request,this->server_path);
- }
- void SSO::setHeartBeatRequest(QString userHash,QString src,QString refreshStamp,QString mcode)
- {
- QtSoapMessage request;
- request.setMethod("HeartBeat", this->server_url);
- request.addMethodArgument("userHash","",userHash);
- request.addMethodArgument("src","",src);
- request.addMethodArgument("refreshStamp","",refreshStamp);
- request.addMethodArgument("mcode","",mcode);
- http.setHost(this->server_host,this->server_port);
- http.submitRequest(request,this->server_path);
- }
- void SSO::setEncryptRequest(QString data, QString authCode, QString key)
- {
- QtSoapMessage request;
- request.setMethod("Encrypt", this->server_url);
- request.addMethodArgument("data","",data);
- request.addMethodArgument("authCode","",authCode);
- request.addMethodArgument("key","",key);
- http.setHost(this->server_host,this->server_port);
- http.submitRequest(request,this->server_path);
- }
- void SSO::setDecryptRequest(QString data, QString authCode, QString key)
- {
- QtSoapMessage request;
- request.setMethod("Decrypt", this->server_url);
- request.addMethodArgument("data","",data);
- request.addMethodArgument("authCode","",authCode);
- request.addMethodArgument("key","",key);
- http.setHost(this->server_host,this->server_port);
- http.submitRequest(request,this->server_path);
- }
- void SSO::setRegSysAccountRequest(QString sysCode, QString userHash,QString regSrc)
- {
- QtSoapMessage request;
- request.setMethod("RegSysAccount", this->server_url);
- request.addMethodArgument("sysCode","",sysCode);
- request.addMethodArgument("userHash","",userHash);
- request.addMethodArgument("regsrc","",regSrc);
- http.setHost(this->server_host,this->server_port);
- http.submitRequest(request,this->server_path);
- }
- void SSO::setBindSysAccountRequest(QString sysCode, QString bindUserCode, QString bindUserPwd, QString userHash)
- {
- QtSoapMessage request;
- request.setMethod("BindSysAccount", this->server_url);
- request.addMethodArgument("sysCode","",sysCode);
- request.addMethodArgument("bindUserCode","",bindUserCode);
- request.addMethodArgument("bindUserPwd","",bindUserPwd);
- request.addMethodArgument("userHash","",userHash);
- http.setHost(this->server_host,this->server_port);
- http.submitRequest(request,this->server_path);
- }
- void SSO::setGetSysAccountRequest(QString sysCode, QString userHash)
- {
- QtSoapMessage request;
- request.setMethod("GetSysAccount", this->server_url);
- request.addMethodArgument("sysCode","",sysCode);
- request.addMethodArgument("userHash","",userHash);
- http.setHost(this->server_host,this->server_port);
- http.submitRequest(request,this->server_path);
- }
- void SSO::setGetUserSSORequest(QString userHash)
- {
- QtSoapMessage request;
- request.setMethod("GetUserSSO", this->server_url);
- request.addMethodArgument("userHash","",userHash);
- http.setHost(this->server_host,this->server_port);
- http.submitRequest(request,this->server_path);
- }
- void SSO::setGetMfPayInfoRequest(QString dateStart, QString dateEnd, QString userHash)
- {
- QtSoapMessage request;
- request.setMethod("GetMfPayInfo", this->server_url);
- request.addMethodArgument("dateStart","",dateStart);
- request.addMethodArgument("dateEnd","",dateEnd);
- request.addMethodArgument("userHash","",userHash);
- http.setHost(this->server_host,this->server_port);
- http.submitRequest(request,this->server_path);
- }
- void SSO::setGetTransferInfoRequest(QString dateStart, QString dateEnd, QString userHash)
- {
- QtSoapMessage request;
- request.setMethod("GetTransferInfo", this->server_url);
- request.addMethodArgument("dateStart","",dateStart);
- request.addMethodArgument("dateEnd","",dateEnd);
- request.addMethodArgument("userHash","",userHash);
- http.setHost(this->server_host,this->server_port);
- http.submitRequest(request,this->server_path);
- }
- void SSO::setUserTransferRequest(QString sndsyscode, QString rcvsyscode, QString trsfmoney, QString trsfmemo, QString userHash)
- {
- QtSoapMessage request;
- request.setMethod("UserTransfer", this->server_url);
- request.addMethodArgument("sndsyscode","",sndsyscode);
- request.addMethodArgument("rcvsyscode","",rcvsyscode);
- request.addMethodArgument("trsfmoney","",trsfmoney);
- request.addMethodArgument("trsfmemo","",trsfmemo);
- request.addMethodArgument("userHash","",userHash);
- http.setHost(this->server_host,this->server_port);
- http.submitRequest(request,this->server_path);
- }
- void SSO::setMfUserPay(QString func, QString userHash)
- {
- QtSoapMessage request;
- request.setMethod("MfUserPay", this->server_url);
- request.addMethodArgument("func","",func);
- request.addMethodArgument("userHash","",userHash);
- http.setHost(this->server_host,this->server_port);
- http.submitRequest(request,this->server_path);
- }
- void SSO::setUserRegRequest(QString userCode, QString userPwd, QString detailInfo, QString src,QString mcode, QString authCode,QString regType)
- {
- QtSoapMessage request;
- request.setMethod("UserReg", this->server_url);
- request.addMethodArgument("userCode","",userCode);
- request.addMethodArgument("userPwd","",userPwd);
- request.addMethodArgument("detailInfo","",detailInfo);
- request.addMethodArgument("src","",src);
- request.addMethodArgument("mcode","",mcode);
- request.addMethodArgument("authCode","",authCode);
- request.addMethodArgument("regType","",regType);
- http.setHost(this->server_host,this->server_port);
- http.submitRequest(request,this->server_path);
- }
- void SSO::setEditUserInfoRequest(QString detailInfo, QString userHash)
- {
- QtSoapMessage request;
- request.setMethod("EditUserInfo", this->server_url);
- request.addMethodArgument("detailInfo","",detailInfo);
- request.addMethodArgument("userHash","",userHash);
- http.setHost(this->server_host,this->server_port);
- http.submitRequest(request,this->server_path);
- }
- void SSO::setGetMFUserInfoRequest(QString userHash)
- {
- QtSoapMessage request;
- request.setMethod("GetMfUserInfo", this->server_url);
- request.addMethodArgument("userHash","",userHash);
- http.setHost(this->server_host,this->server_port);
- http.submitRequest(request,this->server_path);
- }
- void SSO::setGetMFUserBalanceRequest(QString userHash)
- {
- QtSoapMessage request;
- request.setMethod("GetMfUserBalance", this->server_url);
- request.addMethodArgument("userHash","",userHash);
- http.setHost(this->server_host,this->server_port);
- http.submitRequest(request,this->server_path);
- }
- void SSO::setChangePassRequest(QString oldPassword, QString newPassword, QString userHash)
- {
- QtSoapMessage request;
- request.setMethod("ChgUserPwd", this->server_url);
- request.addMethodArgument("oldPwd","",oldPassword);
- request.addMethodArgument("newPwd", "",newPassword);
- request.addMethodArgument("userHash","",userHash);
- http.setHost(this->server_host,this->server_port);
- http.submitRequest(request,this->server_path);
- }
- void SSO::setGetSysParamsRequest(QString src, QString authCode)
- {
- QtSoapMessage request;
- request.setMethod("GetSysParam", this->server_url);
- request.addMethodArgument("src","",src);
- request.addMethodArgument("authCode", "",authCode);
- http.setHost(this->server_host,this->server_port);
- http.submitRequest(request,this->server_path);
- }
- void SSO::setGetServerTimeRequest(QString authCode)
- {
- QtSoapMessage request;
- request.setMethod("GetServerTime", this->server_url);
- request.addMethodArgument("authCode", "",authCode);
- http.setHost(this->server_host,this->server_port);
- http.submitRequest(request,this->server_path);
- }
- void SSO::getResponse()
- {
- // Get the response, check for error.
- const QtSoapMessage &message = http.getResponse();
- if (message.isFault()) {
- qDebug()<<message.faultString().value().toString();
- json = "";
- emit responseProcessed();
- return;
- }
- const QtSoapType &response = message.returnValue();
- json = response.value().toString();
- // qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")\
- // <<json;
- emit responseProcessed();
- return;
- }
|