commit
8f0c2cb0e1
|
@ -645,9 +645,6 @@ int DbusUpperInterface::SetInformation(QString strJson)
|
|||
case LOCK_CMD_ID_BIOAUTH_STOPAUTH:
|
||||
nRet = BioStopAuth(rootObj);
|
||||
break;
|
||||
case LOCK_CMD_ID_SEND_USER_PASSWORD:
|
||||
nRet = sendPassword(rootObj);
|
||||
break;
|
||||
case LOCK_CMD_ID_KWIN_BLOCK_SHORTCUT:
|
||||
nRet = blockShortcut(rootObj);
|
||||
break;
|
||||
|
@ -2108,15 +2105,11 @@ QString DbusUpperInterface::getPublicEncrypt()
|
|||
return QString(pubKey);
|
||||
}
|
||||
|
||||
bool DbusUpperInterface::sendPassword(const QJsonObject &objInfo)
|
||||
bool DbusUpperInterface::sendPassword(const QString username,QByteArray password)
|
||||
{
|
||||
if(priKey.isEmpty())
|
||||
return false;
|
||||
|
||||
QJsonObject obj = objInfo["Content"].toObject();
|
||||
QString username = obj["username"].toString();
|
||||
QByteArray password = obj["password"].toVariant().toByteArray();
|
||||
|
||||
QByteArray decryptText;
|
||||
rsac.decrypt(password, decryptText, priKey); // 解密
|
||||
|
||||
|
@ -2124,7 +2117,15 @@ bool DbusUpperInterface::sendPassword(const QJsonObject &objInfo)
|
|||
if(m_pamAuth && m_pamAuth->inAuthentication() && (m_pamAuth->authenticationUser() == username)){
|
||||
m_pamAuth->respond(QString(decryptText));
|
||||
}
|
||||
else if(m_pamAuth){
|
||||
m_pamAuth->authenticate(username);
|
||||
QTimer::singleShot(100, this, [=](){
|
||||
m_pamAuth->respond(QString(decryptText));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void DbusUpperInterface::BioFindDeviceByName(QJsonObject &reqObj, QJsonObject &retObj)
|
||||
|
|
|
@ -126,6 +126,10 @@ public:
|
|||
*/
|
||||
int SetInformation(QString strJson);
|
||||
|
||||
QString getPublicEncrypt();
|
||||
|
||||
bool sendPassword(const QString username,QByteArray password);
|
||||
|
||||
public Q_SLOTS:
|
||||
/**
|
||||
* @brief 服务退出
|
||||
|
@ -347,10 +351,6 @@ private:
|
|||
|
||||
int BioStopAuth(const QJsonObject &objInfo);
|
||||
|
||||
QString getPublicEncrypt();
|
||||
|
||||
bool sendPassword(const QJsonObject &objInfo);
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief 初始化数据
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "dbusupperinterface.h"
|
||||
#include "screensaveradaptor.h"
|
||||
#include "personalizeddata.h"
|
||||
#include "msysdbus.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
@ -102,5 +103,15 @@ int main(int argc, char *argv[])
|
|||
});
|
||||
}
|
||||
|
||||
MSysDbus *m_sysDbus = new MSysDbus(interface,nullptr);
|
||||
|
||||
QString displayNum = QString(qgetenv("DISPLAY")).replace(":", "").replace(".", "_");
|
||||
QString sysService = "org.ukui.screensaver._" + displayNum;
|
||||
if (!QDBusConnection::systemBus().registerService("org.ukui.screensaver")) {
|
||||
qDebug()<<"registerService failed";
|
||||
}
|
||||
|
||||
QDBusConnection::systemBus().registerObject("/", "org.ukui.screensaver",m_sysDbus, QDBusConnection::ExportAllSlots);
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
|
|
|
@ -16,56 +16,47 @@
|
|||
*
|
||||
**/
|
||||
#include <QDBusInterface>
|
||||
#include <QDebug>
|
||||
#include <QDBusReply>
|
||||
#include "dbusupperinterface.h"
|
||||
#include "msysdbus.h"
|
||||
#include "rsac.h"
|
||||
#include "lockdialogmodel.h"
|
||||
#include <openssl/rsa.h>
|
||||
#include <openssl/pem.h>
|
||||
#include <QTimer>
|
||||
|
||||
MSysDbus::MSysDbus(LockDialogModel *model, QObject *parent)
|
||||
MSysDbus::MSysDbus(DbusUpperInterface *interface,QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_modelLockDialog(model)
|
||||
|
||||
, m_interface(interface)
|
||||
{
|
||||
registerUniauth();
|
||||
}
|
||||
|
||||
bool MSysDbus::sendPassword(const QString username,QByteArray password)
|
||||
{
|
||||
|
||||
if(m_modelLockDialog){
|
||||
return Q_EMIT m_modelLockDialog->sendPassword(username,password);
|
||||
}
|
||||
return true;
|
||||
if(m_interface)
|
||||
return m_interface->sendPassword(username,password);
|
||||
|
||||
qWarning()<<"m_interface is nullptr";
|
||||
return false;
|
||||
}
|
||||
|
||||
QString MSysDbus::getPublicEncrypt()
|
||||
{
|
||||
if(m_modelLockDialog){
|
||||
return Q_EMIT m_modelLockDialog->getPublicEncrypt();
|
||||
}
|
||||
if(m_interface)
|
||||
return m_interface->getPublicEncrypt();
|
||||
|
||||
qWarning()<<"m_interface is nullptr";
|
||||
return "";
|
||||
}
|
||||
|
||||
void MSysDbus::initRSA()
|
||||
{
|
||||
//rsac.generateKeyPair(priKey, pubKey, 2048);
|
||||
}
|
||||
|
||||
void MSysDbus::registerUniauth()
|
||||
{
|
||||
QDBusInterface iface("org.ukui.UniauthBackend",
|
||||
"/org/ukui/UniauthBackend",
|
||||
"org.ukui.UniauthBackend",
|
||||
QDBusConnection::systemBus());
|
||||
QDBusReply<QString> stateReply = iface.call("registerLoginApp");
|
||||
if(!stateReply.isValid())
|
||||
{
|
||||
qDebug() << "registerLoginApp:" << stateReply.error();
|
||||
return ;
|
||||
}
|
||||
iface.call("registerLoginApp");
|
||||
}
|
||||
|
||||
|
||||
|
@ -75,6 +66,6 @@ void MSysDbus::sendSignalLoginFinished(QString username,bool res)
|
|||
"/org/ukui/UniauthBackend",
|
||||
"org.ukui.UniauthBackend",
|
||||
QDBusConnection::systemBus());
|
||||
QDBusReply<QString> stateReply = iface.call("sendSignalLoginFinished",username,res);
|
||||
iface.call("sendSignalLoginFinished",username,res);
|
||||
}
|
||||
|
|
@ -22,14 +22,13 @@
|
|||
#include <QObject>
|
||||
#include <QByteArray>
|
||||
#include "rsac.h"
|
||||
class DbusUpperInterface;
|
||||
|
||||
class LockDialogModel;
|
||||
class MSysDbus: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MSysDbus(LockDialogModel *model, QObject *parent = nullptr);
|
||||
void setAuthWidget(LockDialogModel *model);
|
||||
explicit MSysDbus(DbusUpperInterface *interface,QObject *parent = nullptr);
|
||||
|
||||
public Q_SLOTS:
|
||||
Q_SCRIPTABLE bool sendPassword(const QString username,QByteArray password);
|
||||
|
@ -38,15 +37,10 @@ Q_SIGNALS:
|
|||
void closed();
|
||||
|
||||
private:
|
||||
void initRSA();
|
||||
void registerUniauth();
|
||||
void sendSignalLoginFinished(QString username,bool res);
|
||||
|
||||
QString m_userName = "";
|
||||
QString m_password = "";
|
||||
LockDialogModel *m_modelLockDialog = nullptr;
|
||||
QByteArray priKey, pubKey;
|
||||
RSAC rsac;
|
||||
DbusUpperInterface *m_interface = nullptr;
|
||||
};
|
||||
|
||||
|
|
@ -41,7 +41,6 @@
|
|||
#include "fullbackgroundwidget.h"
|
||||
#include "screensaverwndadaptor.h"
|
||||
#include "pluginsloader.h"
|
||||
#include "msysdbus.h"
|
||||
#include "languagesetting.h"
|
||||
#include "displayservice.h"
|
||||
|
||||
|
@ -164,12 +163,6 @@ int main(int argc, char *argv[])
|
|||
syslog(LOG_INFO, "[ukui-screensaver-dialog] window show done!!");
|
||||
#endif
|
||||
|
||||
MSysDbus *m_sysDbus = new MSysDbus(lockDialogModel,window);
|
||||
|
||||
if (!QDBusConnection::systemBus().registerService("org.ukui.screensaver")) {
|
||||
qDebug()<<"registerService failed";
|
||||
}
|
||||
|
||||
if(cmdArgs.isLock) {
|
||||
Q_EMIT lockDialogModel->showLock(false);
|
||||
}
|
||||
|
|
|
@ -948,6 +948,7 @@ void AuthDialog::onPamAuthCompleted()
|
|||
setUkeyTypeTip("");
|
||||
authMode = UNKNOWN;
|
||||
m_uCurLoginOptType = LOGINOPT_TYPE_PASSWORD;
|
||||
|
||||
Q_EMIT authSucceed(m_curUserInfo->name());
|
||||
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue