| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- #include "formnotice.h"
- #include "ui_formnotice.h"
- #include "sncdatabase.h"
- #include "respencrypt.h"
- #include "respgetservertime.h"
- #include <QtCore>
- FormNotice::FormNotice(QWidget *parent) :
- QWidget(parent),
- ui(new Ui::FormNotice)
- {
- ui->setupUi(this);
- m_webview = new CacheWebView(this);
- m_webview->setMinimumWidth(280);
- m_webview->setMaximumWidth(280);
- ui->verticalLayout->addWidget(m_webview);
- m_ssows = new WSSSO();
- }
- void FormNotice::setNoticeUrl(QString pageUrl)
- {
- m_pageUrl = pageUrl;
- m_webview->setPageUrl(m_pageUrl,QCoreApplication::applicationDirPath()+"/cache");
- }
- void FormNotice::setAccountInfo(QMap<QString, QString> info)
- {
- m_userHash = info.value("userhash");
- m_ssoHash = info.value("ssohash");
- if(m_userHash.isEmpty())
- {
- m_webview->setPageUrl(m_pageUrl,QCoreApplication::applicationDirPath()+"/../cache");
- }
- else
- {
- QString url = getUserCenterUrl();
- m_webview->setPageUrl(url,QCoreApplication::applicationDirPath()+"/../cache");
- }
- }
- void FormNotice::setClientID(QString clientID)
- {
- m_clientID = clientID;
- }
- FormNotice::~FormNotice()
- {
- if(m_ssows)
- {
- m_ssows->abort();
- delete m_ssows;
- }
- delete ui;
- delete m_webview;
- qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")\
- <<"FormNotice Destroyed.";
- }
- QString FormNotice::getUserCenterUrl()
- {
- QString json = m_ssows->encrypt(m_ssoHash);
- RespEncrypt resp1(json);
- QString data = resp1.getEncryptData();
- json = m_ssows->getServerTime();
- RespGetServerTime resp2(json);
- QString authCode;
- QByteArray ba;
- QString str = SNCDataBase::getAuthCodeUrl().arg(resp2.getServerTime().mid(0,16));
- ba = QCryptographicHash::hash ( str.toAscii(), QCryptographicHash::Md5 );
- authCode.append(ba.toHex());
- QString url = SNCDataBase::getSSOAccountUrl() + "?s=mf&r="+authCode+"&u="+data+"&p=ad_"+m_clientID;
- return url;
- }
|