mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2025-04-02 18:31:50 -04:00
* migrate to cmake * move the 3rd party libs * organize 3rdparty * update the 3rd party version * refine the CMakeLists.txt * update install command * update install command * update install command * update install command * update dependency * update the dependency * update the dependency * remove CPM.cmake * remove QtCreator project file * update cmake file * improve cmake file * add cmakew * use wget * remove echo * update the doc * remove the screenshot * update the doc * update the install steps * check the openconnect version * update the doc * update install scripts * fix install scripts * improve message * improve message * improve install scripts * improve the version check * improve the version check * improve install script * add version * organize includes * add version bump * update CI * update CI * add the release flag * update message
101 lines
2.4 KiB
C++
101 lines
2.4 KiB
C++
#include <QtCore/QXmlStreamReader>
|
|
#include <QtCore/QMap>
|
|
#include <plog/Log.h>
|
|
|
|
#include "preloginresponse.h"
|
|
|
|
QString PreloginResponse::xmlAuthMessage = "authentication-message";
|
|
QString PreloginResponse::xmlLabelUsername = "username-label";
|
|
QString PreloginResponse::xmlLabelPassword = "password-label";
|
|
QString PreloginResponse::xmlSamlMethod = "saml-auth-method";
|
|
QString PreloginResponse::xmlSamlRequest = "saml-request";
|
|
QString PreloginResponse::xmlRegion = "region";
|
|
|
|
PreloginResponse::PreloginResponse()
|
|
{
|
|
add(xmlAuthMessage, "");
|
|
add(xmlLabelUsername, "");
|
|
add(xmlLabelPassword, "");
|
|
add(xmlSamlMethod, "");
|
|
add(xmlSamlRequest, "");
|
|
add(xmlRegion, "");
|
|
}
|
|
|
|
PreloginResponse PreloginResponse::parse(const QByteArray& xml)
|
|
{
|
|
PLOGI << "Start parsing the prelogin response...";
|
|
|
|
QXmlStreamReader xmlReader(xml);
|
|
PreloginResponse response;
|
|
response.setRawResponse(xml);
|
|
|
|
while (!xmlReader.atEnd()) {
|
|
xmlReader.readNextStartElement();
|
|
QString name = xmlReader.name().toString();
|
|
if (response.has(name)) {
|
|
response.add(name, xmlReader.readElementText());
|
|
}
|
|
}
|
|
return response;
|
|
}
|
|
|
|
const QByteArray& PreloginResponse::rawResponse() const
|
|
{
|
|
return _rawResponse;
|
|
}
|
|
|
|
QString PreloginResponse::authMessage() const
|
|
{
|
|
return resultMap.value(xmlAuthMessage);
|
|
}
|
|
|
|
QString PreloginResponse::labelUsername() const
|
|
{
|
|
return resultMap.value(xmlLabelUsername);
|
|
}
|
|
|
|
QString PreloginResponse::labelPassword() const
|
|
{
|
|
return resultMap.value(xmlLabelPassword);
|
|
}
|
|
|
|
QString PreloginResponse::samlMethod() const
|
|
{
|
|
return resultMap.value(xmlSamlMethod);
|
|
}
|
|
|
|
QString PreloginResponse::samlRequest() const
|
|
{
|
|
return QByteArray::fromBase64(resultMap.value(xmlSamlRequest).toUtf8());
|
|
}
|
|
|
|
QString PreloginResponse::region() const
|
|
{
|
|
return resultMap.value(xmlRegion);
|
|
}
|
|
|
|
bool PreloginResponse::hasSamlAuthFields() const
|
|
{
|
|
return !samlMethod().isEmpty() && !samlRequest().isEmpty();
|
|
}
|
|
|
|
bool PreloginResponse::hasNormalAuthFields() const
|
|
{
|
|
return !labelUsername().isEmpty() && !labelPassword().isEmpty();
|
|
}
|
|
|
|
void PreloginResponse::setRawResponse(const QByteArray response)
|
|
{
|
|
_rawResponse = response;
|
|
}
|
|
|
|
bool PreloginResponse::has(const QString name) const
|
|
{
|
|
return resultMap.contains(name);
|
|
}
|
|
|
|
void PreloginResponse::add(const QString name, const QString value)
|
|
{
|
|
resultMap.insert(name, value);
|
|
}
|