mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2025-04-02 18:31:50 -04:00
chore: PLOG -> LOG
This commit is contained in:
parent
fab8e7591e
commit
343a6d03c1
@ -29,7 +29,7 @@ void CDPCommandManager::initialize(QString endpoint)
|
|||||||
reply, &QNetworkReply::finished,
|
reply, &QNetworkReply::finished,
|
||||||
[reply, this]() {
|
[reply, this]() {
|
||||||
if (reply->error()) {
|
if (reply->error()) {
|
||||||
PLOGE << "CDP request error";
|
LOGE << "CDP request error";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,10 +78,10 @@ void CDPCommandManager::onTextMessageReceived(QString message)
|
|||||||
|
|
||||||
void CDPCommandManager::onSocketDisconnected()
|
void CDPCommandManager::onSocketDisconnected()
|
||||||
{
|
{
|
||||||
PLOGI << "WebSocket disconnected";
|
LOGI << "WebSocket disconnected";
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDPCommandManager::onSocketError(QAbstractSocket::SocketError error)
|
void CDPCommandManager::onSocketError(QAbstractSocket::SocketError error)
|
||||||
{
|
{
|
||||||
PLOGE << "WebSocket error" << error;
|
LOGE << "WebSocket error" << error;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ GatewayAuthenticator::~GatewayAuthenticator()
|
|||||||
|
|
||||||
void GatewayAuthenticator::authenticate()
|
void GatewayAuthenticator::authenticate()
|
||||||
{
|
{
|
||||||
PLOGI << "Start gateway authentication...";
|
LOGI << "Start gateway authentication...";
|
||||||
|
|
||||||
LoginParams loginParams { params.clientos() };
|
LoginParams loginParams { params.clientos() };
|
||||||
loginParams.setUser(params.username());
|
loginParams.setUser(params.username());
|
||||||
@ -43,7 +43,7 @@ void GatewayAuthenticator::authenticate()
|
|||||||
|
|
||||||
void GatewayAuthenticator::login(const LoginParams &loginParams)
|
void GatewayAuthenticator::login(const LoginParams &loginParams)
|
||||||
{
|
{
|
||||||
PLOGI << "Trying to login the gateway at " << loginUrl << " with " << loginParams.toUtf8();
|
LOGI << "Trying to login the gateway at " << loginUrl << " with " << loginParams.toUtf8();
|
||||||
|
|
||||||
QNetworkReply *reply = createRequest(loginUrl, loginParams.toUtf8());
|
QNetworkReply *reply = createRequest(loginUrl, loginParams.toUtf8());
|
||||||
connect(reply, &QNetworkReply::finished, this, &GatewayAuthenticator::onLoginFinished);
|
connect(reply, &QNetworkReply::finished, this, &GatewayAuthenticator::onLoginFinished);
|
||||||
@ -55,7 +55,7 @@ void GatewayAuthenticator::onLoginFinished()
|
|||||||
QByteArray response = reply->readAll();
|
QByteArray response = reply->readAll();
|
||||||
|
|
||||||
if (reply->error() || response.contains("Authentication failure")) {
|
if (reply->error() || response.contains("Authentication failure")) {
|
||||||
PLOGE << QString("Failed to login the gateway at %1, %2").arg(loginUrl, reply->errorString());
|
LOGE << QString("Failed to login the gateway at %1, %2").arg(loginUrl, reply->errorString());
|
||||||
|
|
||||||
if (normalLoginWindow) {
|
if (normalLoginWindow) {
|
||||||
normalLoginWindow->setProcessing(false);
|
normalLoginWindow->setProcessing(false);
|
||||||
@ -68,7 +68,7 @@ void GatewayAuthenticator::onLoginFinished()
|
|||||||
|
|
||||||
// 2FA
|
// 2FA
|
||||||
if (response.contains("Challenge")) {
|
if (response.contains("Challenge")) {
|
||||||
PLOGI << "The server need input the challenge...";
|
LOGI << "The server need input the challenge...";
|
||||||
showChallenge(response);
|
showChallenge(response);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -83,7 +83,7 @@ void GatewayAuthenticator::onLoginFinished()
|
|||||||
|
|
||||||
void GatewayAuthenticator::doAuth()
|
void GatewayAuthenticator::doAuth()
|
||||||
{
|
{
|
||||||
PLOGI << "Perform the gateway prelogin at " << preloginUrl;
|
LOGI << "Perform the gateway prelogin at " << preloginUrl;
|
||||||
|
|
||||||
QNetworkReply *reply = createRequest(preloginUrl);
|
QNetworkReply *reply = createRequest(preloginUrl);
|
||||||
connect(reply, &QNetworkReply::finished, this, &GatewayAuthenticator::onPreloginFinished);
|
connect(reply, &QNetworkReply::finished, this, &GatewayAuthenticator::onPreloginFinished);
|
||||||
@ -94,13 +94,13 @@ void GatewayAuthenticator::onPreloginFinished()
|
|||||||
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
|
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
|
||||||
|
|
||||||
if (reply->error()) {
|
if (reply->error()) {
|
||||||
PLOGE << QString("Failed to prelogin the gateway at %1, %2").arg(preloginUrl, reply->errorString());
|
LOGE << QString("Failed to prelogin the gateway at %1, %2").arg(preloginUrl, reply->errorString());
|
||||||
|
|
||||||
emit fail("Error occurred on the gateway prelogin interface.");
|
emit fail("Error occurred on the gateway prelogin interface.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PLOGI << "Gateway prelogin succeeded.";
|
LOGI << "Gateway prelogin succeeded.";
|
||||||
|
|
||||||
PreloginResponse response = PreloginResponse::parse(reply->readAll());
|
PreloginResponse response = PreloginResponse::parse(reply->readAll());
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ void GatewayAuthenticator::onPreloginFinished()
|
|||||||
} else if (response.hasNormalAuthFields()) {
|
} else if (response.hasNormalAuthFields()) {
|
||||||
normalAuth(response.labelUsername(), response.labelPassword(), response.authMessage());
|
normalAuth(response.labelUsername(), response.labelPassword(), response.authMessage());
|
||||||
} else {
|
} else {
|
||||||
PLOGE << QString("Unknown prelogin response for %1, got %2").arg(preloginUrl, QString::fromUtf8(response.rawResponse()));
|
LOGE << QString("Unknown prelogin response for %1, got %2").arg(preloginUrl, QString::fromUtf8(response.rawResponse()));
|
||||||
emit fail("Unknown response for gateway prelogin interface.");
|
emit fail("Unknown response for gateway prelogin interface.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ void GatewayAuthenticator::onPreloginFinished()
|
|||||||
|
|
||||||
void GatewayAuthenticator::normalAuth(QString labelUsername, QString labelPassword, QString authMessage)
|
void GatewayAuthenticator::normalAuth(QString labelUsername, QString labelPassword, QString authMessage)
|
||||||
{
|
{
|
||||||
PLOGI << QString("Trying to perform the normal login with %1 / %2 credentials").arg(labelUsername, labelPassword);
|
LOGI << QString("Trying to perform the normal login with %1 / %2 credentials").arg(labelUsername, labelPassword);
|
||||||
|
|
||||||
normalLoginWindow = new NormalLoginWindow;
|
normalLoginWindow = new NormalLoginWindow;
|
||||||
normalLoginWindow->setPortalAddress(gateway);
|
normalLoginWindow->setPortalAddress(gateway);
|
||||||
@ -136,7 +136,7 @@ void GatewayAuthenticator::normalAuth(QString labelUsername, QString labelPasswo
|
|||||||
|
|
||||||
void GatewayAuthenticator::onPerformNormalLogin(const QString &username, const QString &password)
|
void GatewayAuthenticator::onPerformNormalLogin(const QString &username, const QString &password)
|
||||||
{
|
{
|
||||||
PLOGI << "Start to perform normal login...";
|
LOGI << "Start to perform normal login...";
|
||||||
|
|
||||||
normalLoginWindow->setProcessing(true);
|
normalLoginWindow->setProcessing(true);
|
||||||
params.setUsername(username);
|
params.setUsername(username);
|
||||||
@ -158,7 +158,7 @@ void GatewayAuthenticator::onLoginWindowFinished()
|
|||||||
|
|
||||||
void GatewayAuthenticator::samlAuth(QString samlMethod, QString samlRequest, QString preloginUrl)
|
void GatewayAuthenticator::samlAuth(QString samlMethod, QString samlRequest, QString preloginUrl)
|
||||||
{
|
{
|
||||||
PLOGI << "Trying to perform SAML login with saml-method " << samlMethod;
|
LOGI << "Trying to perform SAML login with saml-method " << samlMethod;
|
||||||
|
|
||||||
SAMLLoginWindow *loginWindow = new SAMLLoginWindow;
|
SAMLLoginWindow *loginWindow = new SAMLLoginWindow;
|
||||||
|
|
||||||
@ -181,9 +181,9 @@ void GatewayAuthenticator::samlAuth(QString samlMethod, QString samlRequest, QSt
|
|||||||
void GatewayAuthenticator::onSAMLLoginSuccess(const QMap<QString, QString> &samlResult)
|
void GatewayAuthenticator::onSAMLLoginSuccess(const QMap<QString, QString> &samlResult)
|
||||||
{
|
{
|
||||||
if (samlResult.contains("preloginCookie")) {
|
if (samlResult.contains("preloginCookie")) {
|
||||||
PLOGI << "SAML login succeeded, got the prelogin-cookie " << samlResult.value("preloginCookie");
|
LOGI << "SAML login succeeded, got the prelogin-cookie " << samlResult.value("preloginCookie");
|
||||||
} else {
|
} else {
|
||||||
PLOGI << "SAML login succeeded, got the portal-userauthcookie " << samlResult.value("userAuthCookie");
|
LOGI << "SAML login succeeded, got the portal-userauthcookie " << samlResult.value("userAuthCookie");
|
||||||
}
|
}
|
||||||
|
|
||||||
LoginParams loginParams { params.clientos() };
|
LoginParams loginParams { params.clientos() };
|
||||||
@ -215,7 +215,7 @@ void GatewayAuthenticator::showChallenge(const QString &responseText)
|
|||||||
|
|
||||||
connect(challengeDialog, &ChallengeDialog::accepted, this, [this] {
|
connect(challengeDialog, &ChallengeDialog::accepted, this, [this] {
|
||||||
params.setPassword(challengeDialog->getChallenge());
|
params.setPassword(challengeDialog->getChallenge());
|
||||||
PLOGI << "Challenge submitted, try to re-authenticate...";
|
LOGI << "Challenge submitted, try to re-authenticate...";
|
||||||
authenticate();
|
authenticate();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ void GPClient::initVpnStatus() {
|
|||||||
|
|
||||||
void GPClient::populateGatewayMenu()
|
void GPClient::populateGatewayMenu()
|
||||||
{
|
{
|
||||||
PLOGI << "Populating the Switch Gateway menu...";
|
LOGI << "Populating the Switch Gateway menu...";
|
||||||
|
|
||||||
const QList<GPGateway> gateways = allGateways();
|
const QList<GPGateway> gateways = allGateways();
|
||||||
gatewaySwitchMenu->clear();
|
gatewaySwitchMenu->clear();
|
||||||
@ -241,7 +241,7 @@ void GPClient::onGatewayChanged(QAction *action)
|
|||||||
|
|
||||||
void GPClient::doConnect()
|
void GPClient::doConnect()
|
||||||
{
|
{
|
||||||
PLOGI << "Start connecting...";
|
LOGI << "Start connecting...";
|
||||||
|
|
||||||
const QString btnText = ui->connectButton->text();
|
const QString btnText = ui->connectButton->text();
|
||||||
const QString portal = this->portal();
|
const QString portal = this->portal();
|
||||||
@ -257,16 +257,16 @@ void GPClient::doConnect()
|
|||||||
|
|
||||||
// Login to the previously saved gateway
|
// Login to the previously saved gateway
|
||||||
if (!currentGateway().name().isEmpty()) {
|
if (!currentGateway().name().isEmpty()) {
|
||||||
PLOGI << "Start gateway login using the previously saved gateway...";
|
LOGI << "Start gateway login using the previously saved gateway...";
|
||||||
isQuickConnect = true;
|
isQuickConnect = true;
|
||||||
gatewayLogin();
|
gatewayLogin();
|
||||||
} else {
|
} else {
|
||||||
// Perform the portal login
|
// Perform the portal login
|
||||||
PLOGI << "Start portal login...";
|
LOGI << "Start portal login...";
|
||||||
portalLogin();
|
portalLogin();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PLOGI << "Start disconnecting the VPN...";
|
LOGI << "Start disconnecting the VPN...";
|
||||||
|
|
||||||
ui->statusLabel->setText("Disconnecting...");
|
ui->statusLabel->setText("Disconnecting...");
|
||||||
updateConnectionStatus(VpnStatus::pending);
|
updateConnectionStatus(VpnStatus::pending);
|
||||||
@ -305,11 +305,11 @@ void GPClient::portalLogin()
|
|||||||
|
|
||||||
void GPClient::onPortalSuccess(const PortalConfigResponse portalConfig, const QString region)
|
void GPClient::onPortalSuccess(const PortalConfigResponse portalConfig, const QString region)
|
||||||
{
|
{
|
||||||
PLOGI << "Portal authentication succeeded.";
|
LOGI << "Portal authentication succeeded.";
|
||||||
|
|
||||||
// No gateway found in portal configuration
|
// No gateway found in portal configuration
|
||||||
if (portalConfig.allGateways().size() == 0) {
|
if (portalConfig.allGateways().size() == 0) {
|
||||||
PLOGI << "No gateway found in portal configuration, treat the portal address as a gateway.";
|
LOGI << "No gateway found in portal configuration, treat the portal address as a gateway.";
|
||||||
tryGatewayLogin();
|
tryGatewayLogin();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -324,13 +324,13 @@ void GPClient::onPortalSuccess(const PortalConfigResponse portalConfig, const QS
|
|||||||
|
|
||||||
void GPClient::onPortalPreloginFail(const QString msg)
|
void GPClient::onPortalPreloginFail(const QString msg)
|
||||||
{
|
{
|
||||||
PLOGI << "Portal prelogin failed: " << msg;
|
LOGI << "Portal prelogin failed: " << msg;
|
||||||
tryGatewayLogin();
|
tryGatewayLogin();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPClient::onPortalConfigFail(const QString msg)
|
void GPClient::onPortalConfigFail(const QString msg)
|
||||||
{
|
{
|
||||||
PLOGI << "Failed to get the portal configuration, " << msg << " Treat the portal address as gateway.";
|
LOGI << "Failed to get the portal configuration, " << msg << " Treat the portal address as gateway.";
|
||||||
tryGatewayLogin();
|
tryGatewayLogin();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,7 +345,7 @@ void GPClient::onPortalFail(const QString &msg)
|
|||||||
|
|
||||||
void GPClient::tryGatewayLogin()
|
void GPClient::tryGatewayLogin()
|
||||||
{
|
{
|
||||||
PLOGI << "Try to preform login on the the gateway interface...";
|
LOGI << "Try to preform login on the the gateway interface...";
|
||||||
|
|
||||||
// Treat the portal input as the gateway address
|
// Treat the portal input as the gateway address
|
||||||
GPGateway g;
|
GPGateway g;
|
||||||
@ -364,7 +364,7 @@ void GPClient::tryGatewayLogin()
|
|||||||
// Login to the gateway
|
// Login to the gateway
|
||||||
void GPClient::gatewayLogin()
|
void GPClient::gatewayLogin()
|
||||||
{
|
{
|
||||||
PLOGI << "Performing gateway login...";
|
LOGI << "Performing gateway login...";
|
||||||
|
|
||||||
GatewayAuthenticatorParams params = GatewayAuthenticatorParams::fromPortalConfigResponse(portalConfig);
|
GatewayAuthenticatorParams params = GatewayAuthenticatorParams::fromPortalConfigResponse(portalConfig);
|
||||||
params.setClientos(settings::get("clientos", "Linux").toString());
|
params.setClientos(settings::get("clientos", "Linux").toString());
|
||||||
@ -387,7 +387,7 @@ void GPClient::gatewayLogin()
|
|||||||
|
|
||||||
void GPClient::onGatewaySuccess(const QString &authCookie)
|
void GPClient::onGatewaySuccess(const QString &authCookie)
|
||||||
{
|
{
|
||||||
PLOGI << "Gateway login succeeded, got the cookie " << authCookie;
|
LOGI << "Gateway login succeeded, got the cookie " << authCookie;
|
||||||
|
|
||||||
isQuickConnect = false;
|
isQuickConnect = false;
|
||||||
QList<QString> gatewayAddresses;
|
QList<QString> gatewayAddresses;
|
||||||
@ -450,7 +450,7 @@ QList<GPGateway> GPClient::allGateways() const
|
|||||||
|
|
||||||
void GPClient::setAllGateways(QList<GPGateway> gateways)
|
void GPClient::setAllGateways(QList<GPGateway> gateways)
|
||||||
{
|
{
|
||||||
PLOGI << "Updating all the gateways...";
|
LOGI << "Updating all the gateways...";
|
||||||
|
|
||||||
settings::save(portal() + "_gateways", GPGateway::serialize(gateways));
|
settings::save(portal() + "_gateways", GPGateway::serialize(gateways));
|
||||||
populateGatewayMenu();
|
populateGatewayMenu();
|
||||||
@ -470,7 +470,7 @@ GPGateway GPClient::currentGateway() const
|
|||||||
|
|
||||||
void GPClient::setCurrentGateway(const GPGateway gateway)
|
void GPClient::setCurrentGateway(const GPGateway gateway)
|
||||||
{
|
{
|
||||||
PLOGI << "Updating the current gateway to " << gateway.name();
|
LOGI << "Updating the current gateway to " << gateway.name();
|
||||||
|
|
||||||
settings::save(portal() + "_selectedGateway", gateway.name());
|
settings::save(portal() + "_selectedGateway", gateway.name());
|
||||||
populateGatewayMenu();
|
populateGatewayMenu();
|
||||||
@ -512,5 +512,5 @@ void GPClient::onVPNError(QString errorMessage)
|
|||||||
|
|
||||||
void GPClient::onVPNLogAvailable(QString log)
|
void GPClient::onVPNLogAvailable(QString log)
|
||||||
{
|
{
|
||||||
PLOGI << log;
|
LOGI << log;
|
||||||
}
|
}
|
||||||
|
@ -33,13 +33,13 @@ QNetworkReply* gpclient::helper::createRequest(QString url, QByteArray params)
|
|||||||
|
|
||||||
GPGateway gpclient::helper::filterPreferredGateway(QList<GPGateway> gateways, const QString ruleName)
|
GPGateway gpclient::helper::filterPreferredGateway(QList<GPGateway> gateways, const QString ruleName)
|
||||||
{
|
{
|
||||||
PLOGI << gateways.size() << " gateway(s) available, filter the gateways with rule: " << ruleName;
|
LOGI << gateways.size() << " gateway(s) available, filter the gateways with rule: " << ruleName;
|
||||||
|
|
||||||
GPGateway gateway = gateways.first();
|
GPGateway gateway = gateways.first();
|
||||||
|
|
||||||
for (GPGateway g : gateways) {
|
for (GPGateway g : gateways) {
|
||||||
if (g.priorityOf(ruleName) > gateway.priorityOf(ruleName)) {
|
if (g.priorityOf(ruleName) > gateway.priorityOf(ruleName)) {
|
||||||
PLOGI << "Find a preferred gateway: " << g.name();
|
LOGI << "Find a preferred gateway: " << g.name();
|
||||||
gateway = g;
|
gateway = g;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -49,8 +49,8 @@ GPGateway gpclient::helper::filterPreferredGateway(QList<GPGateway> gateways, co
|
|||||||
|
|
||||||
QUrlQuery gpclient::helper::parseGatewayResponse(const QByteArray &xml)
|
QUrlQuery gpclient::helper::parseGatewayResponse(const QByteArray &xml)
|
||||||
{
|
{
|
||||||
PLOGI << "Start parsing the gateway response...";
|
LOGI << "Start parsing the gateway response...";
|
||||||
PLOGI << "The gateway response is: " << xml;
|
LOGI << "The gateway response is: " << xml;
|
||||||
|
|
||||||
QXmlStreamReader xmlReader{xml};
|
QXmlStreamReader xmlReader{xml};
|
||||||
QList<QString> args;
|
QList<QString> args;
|
||||||
|
@ -21,7 +21,7 @@ int main(int argc, char *argv[])
|
|||||||
plog::ColorConsoleAppender<plog::TxtFormatter> consoleAppender(plog::streamStdErr);
|
plog::ColorConsoleAppender<plog::TxtFormatter> consoleAppender(plog::streamStdErr);
|
||||||
plog::init(plog::debug, &consoleAppender);
|
plog::init(plog::debug, &consoleAppender);
|
||||||
|
|
||||||
PLOGI << "GlobalProtect started, version: " << VERSION;
|
LOGI << "GlobalProtect started, version: " << VERSION;
|
||||||
|
|
||||||
auto port = QString::fromLocal8Bit(qgetenv(ENV_CDP_PORT));
|
auto port = QString::fromLocal8Bit(qgetenv(ENV_CDP_PORT));
|
||||||
auto hidpiSupport = QString::fromLocal8Bit(qgetenv(QT_AUTO_SCREEN_SCALE_FACTOR));
|
auto hidpiSupport = QString::fromLocal8Bit(qgetenv(QT_AUTO_SCREEN_SCALE_FACTOR));
|
||||||
|
@ -30,7 +30,7 @@ PortalAuthenticator::~PortalAuthenticator()
|
|||||||
|
|
||||||
void PortalAuthenticator::authenticate()
|
void PortalAuthenticator::authenticate()
|
||||||
{
|
{
|
||||||
PLOGI << "Preform portal prelogin at " << preloginUrl;
|
LOGI << "Preform portal prelogin at " << preloginUrl;
|
||||||
|
|
||||||
QNetworkReply *reply = createRequest(preloginUrl);
|
QNetworkReply *reply = createRequest(preloginUrl);
|
||||||
connect(reply, &QNetworkReply::finished, this, &PortalAuthenticator::onPreloginFinished);
|
connect(reply, &QNetworkReply::finished, this, &PortalAuthenticator::onPreloginFinished);
|
||||||
@ -41,17 +41,17 @@ void PortalAuthenticator::onPreloginFinished()
|
|||||||
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
|
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
|
||||||
|
|
||||||
if (reply->error()) {
|
if (reply->error()) {
|
||||||
PLOGE << QString("Error occurred while accessing %1, %2").arg(preloginUrl, reply->errorString());
|
LOGE << QString("Error occurred while accessing %1, %2").arg(preloginUrl, reply->errorString());
|
||||||
emit preloginFailed("Error occurred on the portal prelogin interface.");
|
emit preloginFailed("Error occurred on the portal prelogin interface.");
|
||||||
delete reply;
|
delete reply;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PLOGI << "Portal prelogin succeeded.";
|
LOGI << "Portal prelogin succeeded.";
|
||||||
|
|
||||||
preloginResponse = PreloginResponse::parse(reply->readAll());
|
preloginResponse = PreloginResponse::parse(reply->readAll());
|
||||||
|
|
||||||
PLOGI << "Finished parsing the prelogin response. The region field is: " << preloginResponse.region();
|
LOGI << "Finished parsing the prelogin response. The region field is: " << preloginResponse.region();
|
||||||
|
|
||||||
if (preloginResponse.hasSamlAuthFields()) {
|
if (preloginResponse.hasSamlAuthFields()) {
|
||||||
// Do SAML authentication
|
// Do SAML authentication
|
||||||
@ -60,7 +60,7 @@ void PortalAuthenticator::onPreloginFinished()
|
|||||||
// Do normal username/password authentication
|
// Do normal username/password authentication
|
||||||
tryAutoLogin();
|
tryAutoLogin();
|
||||||
} else {
|
} else {
|
||||||
PLOGE << QString("Unknown prelogin response for %1 got %2").arg(preloginUrl).arg(QString::fromUtf8(preloginResponse.rawResponse()));
|
LOGE << QString("Unknown prelogin response for %1 got %2").arg(preloginUrl).arg(QString::fromUtf8(preloginResponse.rawResponse()));
|
||||||
emit preloginFailed("Unknown response for portal prelogin interface.");
|
emit preloginFailed("Unknown response for portal prelogin interface.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ void PortalAuthenticator::tryAutoLogin()
|
|||||||
const QString password = settings::get("password").toString();
|
const QString password = settings::get("password").toString();
|
||||||
|
|
||||||
if (!username.isEmpty() && !password.isEmpty()) {
|
if (!username.isEmpty() && !password.isEmpty()) {
|
||||||
PLOGI << "Trying auto login using the saved credentials";
|
LOGI << "Trying auto login using the saved credentials";
|
||||||
isAutoLogin = true;
|
isAutoLogin = true;
|
||||||
fetchConfig(settings::get("username").toString(), settings::get("password").toString());
|
fetchConfig(settings::get("username").toString(), settings::get("password").toString());
|
||||||
} else {
|
} else {
|
||||||
@ -83,7 +83,7 @@ void PortalAuthenticator::tryAutoLogin()
|
|||||||
|
|
||||||
void PortalAuthenticator::normalAuth()
|
void PortalAuthenticator::normalAuth()
|
||||||
{
|
{
|
||||||
PLOGI << "Trying to launch the normal login window...";
|
LOGI << "Trying to launch the normal login window...";
|
||||||
|
|
||||||
normalLoginWindow = new NormalLoginWindow;
|
normalLoginWindow = new NormalLoginWindow;
|
||||||
normalLoginWindow->setPortalAddress(portal);
|
normalLoginWindow->setPortalAddress(portal);
|
||||||
@ -118,7 +118,7 @@ void PortalAuthenticator::onLoginWindowFinished()
|
|||||||
|
|
||||||
void PortalAuthenticator::samlAuth()
|
void PortalAuthenticator::samlAuth()
|
||||||
{
|
{
|
||||||
PLOGI << "Trying to perform SAML login with saml-method " << preloginResponse.samlMethod();
|
LOGI << "Trying to perform SAML login with saml-method " << preloginResponse.samlMethod();
|
||||||
|
|
||||||
SAMLLoginWindow *loginWindow = new SAMLLoginWindow;
|
SAMLLoginWindow *loginWindow = new SAMLLoginWindow;
|
||||||
|
|
||||||
@ -141,9 +141,9 @@ void PortalAuthenticator::samlAuth()
|
|||||||
void PortalAuthenticator::onSAMLLoginSuccess(const QMap<QString, QString> samlResult)
|
void PortalAuthenticator::onSAMLLoginSuccess(const QMap<QString, QString> samlResult)
|
||||||
{
|
{
|
||||||
if (samlResult.contains("preloginCookie")) {
|
if (samlResult.contains("preloginCookie")) {
|
||||||
PLOGI << "SAML login succeeded, got the prelogin-cookie " << samlResult.value("preloginCookie");
|
LOGI << "SAML login succeeded, got the prelogin-cookie " << samlResult.value("preloginCookie");
|
||||||
} else {
|
} else {
|
||||||
PLOGI << "SAML login succeeded, got the portal-userauthcookie " << samlResult.value("userAuthCookie");
|
LOGI << "SAML login succeeded, got the portal-userauthcookie " << samlResult.value("userAuthCookie");
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchConfig(samlResult.value("username"), "", samlResult.value("preloginCookie"), samlResult.value("userAuthCookie"));
|
fetchConfig(samlResult.value("username"), "", samlResult.value("preloginCookie"), samlResult.value("userAuthCookie"));
|
||||||
@ -167,7 +167,7 @@ void PortalAuthenticator::fetchConfig(QString username, QString password, QStrin
|
|||||||
this->username = username;
|
this->username = username;
|
||||||
this->password = password;
|
this->password = password;
|
||||||
|
|
||||||
PLOGI << "Fetching the portal config from " << configUrl << " for user: " << username;
|
LOGI << "Fetching the portal config from " << configUrl << " for user: " << username;
|
||||||
|
|
||||||
QNetworkReply *reply = createRequest(configUrl, loginParams.toUtf8());
|
QNetworkReply *reply = createRequest(configUrl, loginParams.toUtf8());
|
||||||
connect(reply, &QNetworkReply::finished, this, &PortalAuthenticator::onFetchConfigFinished);
|
connect(reply, &QNetworkReply::finished, this, &PortalAuthenticator::onFetchConfigFinished);
|
||||||
@ -178,7 +178,7 @@ void PortalAuthenticator::onFetchConfigFinished()
|
|||||||
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
|
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
|
||||||
|
|
||||||
if (reply->error()) {
|
if (reply->error()) {
|
||||||
PLOGE << QString("Failed to fetch the portal config from %1, %2").arg(configUrl).arg(reply->errorString());
|
LOGE << QString("Failed to fetch the portal config from %1, %2").arg(configUrl).arg(reply->errorString());
|
||||||
|
|
||||||
// Login failed, enable the fields of the normal login window
|
// Login failed, enable the fields of the normal login window
|
||||||
if (normalLoginWindow) {
|
if (normalLoginWindow) {
|
||||||
@ -193,7 +193,7 @@ void PortalAuthenticator::onFetchConfigFinished()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PLOGI << "Fetch the portal config succeeded.";
|
LOGI << "Fetch the portal config succeeded.";
|
||||||
PortalConfigResponse response = PortalConfigResponse::parse(reply->readAll());
|
PortalConfigResponse response = PortalConfigResponse::parse(reply->readAll());
|
||||||
|
|
||||||
// Add the username & password to the response object
|
// Add the username & password to the response object
|
||||||
@ -202,7 +202,7 @@ void PortalAuthenticator::onFetchConfigFinished()
|
|||||||
|
|
||||||
// Close the login window
|
// Close the login window
|
||||||
if (normalLoginWindow) {
|
if (normalLoginWindow) {
|
||||||
PLOGI << "Closing the NormalLoginWindow...";
|
LOGI << "Closing the NormalLoginWindow...";
|
||||||
|
|
||||||
normalLoginWindow->close();
|
normalLoginWindow->close();
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ PortalConfigResponse::~PortalConfigResponse()
|
|||||||
|
|
||||||
PortalConfigResponse PortalConfigResponse::parse(const QByteArray xml)
|
PortalConfigResponse PortalConfigResponse::parse(const QByteArray xml)
|
||||||
{
|
{
|
||||||
PLOGI << "Start parsing the portal configuration...";
|
LOGI << "Start parsing the portal configuration...";
|
||||||
|
|
||||||
QXmlStreamReader xmlReader(xml);
|
QXmlStreamReader xmlReader(xml);
|
||||||
PortalConfigResponse response;
|
PortalConfigResponse response;
|
||||||
@ -29,17 +29,17 @@ PortalConfigResponse PortalConfigResponse::parse(const QByteArray xml)
|
|||||||
QString name = xmlReader.name().toString();
|
QString name = xmlReader.name().toString();
|
||||||
|
|
||||||
if (name == xmlUserAuthCookie) {
|
if (name == xmlUserAuthCookie) {
|
||||||
PLOGI << "Start reading " << name;
|
LOGI << "Start reading " << name;
|
||||||
response.setUserAuthCookie(xmlReader.readElementText());
|
response.setUserAuthCookie(xmlReader.readElementText());
|
||||||
} else if (name == xmlPrelogonUserAuthCookie) {
|
} else if (name == xmlPrelogonUserAuthCookie) {
|
||||||
PLOGI << "Start reading " << name;
|
LOGI << "Start reading " << name;
|
||||||
response.setPrelogonUserAuthCookie(xmlReader.readElementText());
|
response.setPrelogonUserAuthCookie(xmlReader.readElementText());
|
||||||
} else if (name == xmlGateways) {
|
} else if (name == xmlGateways) {
|
||||||
response.setAllGateways(parseGateways(xmlReader));
|
response.setAllGateways(parseGateways(xmlReader));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PLOGI << "Finished parsing portal configuration.";
|
LOGI << "Finished parsing portal configuration.";
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
@ -61,7 +61,7 @@ QString PortalConfigResponse::password() const
|
|||||||
|
|
||||||
QList<GPGateway> PortalConfigResponse::parseGateways(QXmlStreamReader &xmlReader)
|
QList<GPGateway> PortalConfigResponse::parseGateways(QXmlStreamReader &xmlReader)
|
||||||
{
|
{
|
||||||
PLOGI << "Start parsing the gateways from portal configuration...";
|
LOGI << "Start parsing the gateways from portal configuration...";
|
||||||
|
|
||||||
QList<GPGateway> gateways;
|
QList<GPGateway> gateways;
|
||||||
|
|
||||||
@ -83,13 +83,13 @@ QList<GPGateway> PortalConfigResponse::parseGateways(QXmlStreamReader &xmlReader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PLOGI << "Finished parsing the gateways.";
|
LOGI << "Finished parsing the gateways.";
|
||||||
|
|
||||||
return gateways;
|
return gateways;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PortalConfigResponse::parseGateway(QXmlStreamReader &reader, GPGateway &gateway) {
|
void PortalConfigResponse::parseGateway(QXmlStreamReader &reader, GPGateway &gateway) {
|
||||||
PLOGI << "Start parsing gateway...";
|
LOGI << "Start parsing gateway...";
|
||||||
|
|
||||||
auto finished = false;
|
auto finished = false;
|
||||||
while (!finished) {
|
while (!finished) {
|
||||||
@ -108,7 +108,7 @@ void PortalConfigResponse::parseGateway(QXmlStreamReader &reader, GPGateway &gat
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PortalConfigResponse::parsePriorityRule(QXmlStreamReader &reader, GPGateway &gateway) {
|
void PortalConfigResponse::parsePriorityRule(QXmlStreamReader &reader, GPGateway &gateway) {
|
||||||
PLOGI << "Start parsing priority rule...";
|
LOGI << "Start parsing priority rule...";
|
||||||
|
|
||||||
QMap<QString, int> priorityRules;
|
QMap<QString, int> priorityRules;
|
||||||
auto finished = false;
|
auto finished = false;
|
||||||
|
@ -23,7 +23,7 @@ PreloginResponse::PreloginResponse()
|
|||||||
|
|
||||||
PreloginResponse PreloginResponse::parse(const QByteArray& xml)
|
PreloginResponse PreloginResponse::parse(const QByteArray& xml)
|
||||||
{
|
{
|
||||||
PLOGI << "Start parsing the prelogin response...";
|
LOGI << "Start parsing the prelogin response...";
|
||||||
|
|
||||||
QXmlStreamReader xmlReader(xml);
|
QXmlStreamReader xmlReader(xml);
|
||||||
PreloginResponse response;
|
PreloginResponse response;
|
||||||
|
@ -42,7 +42,7 @@ void SAMLLoginWindow::login(const QString samlMethod, const QString samlRequest,
|
|||||||
} else if (samlMethod == "REDIRECT") {
|
} else if (samlMethod == "REDIRECT") {
|
||||||
webView->load(samlRequest);
|
webView->load(samlRequest);
|
||||||
} else {
|
} else {
|
||||||
PLOGE << "Unknown saml-auth-method expected POST or REDIRECT, got " << samlMethod;
|
LOGE << "Unknown saml-auth-method expected POST or REDIRECT, got " << samlMethod;
|
||||||
emit fail("Unknown saml-auth-method, got " + samlMethod);
|
emit fail("Unknown saml-auth-method, got " + samlMethod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user