From 29c478496baf432245f299572cd80cf2ae095f3c Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sun, 11 Feb 2018 04:39:42 +0100 Subject: [PATCH] Ref T249, using obfuscation for server/user --- src/blackmisc/network/server.cpp | 7 ++++--- src/blackmisc/network/server.h | 14 ++++++++------ src/blackmisc/network/user.cpp | 12 ++++++------ src/blackmisc/network/user.h | 13 ++++++++----- 4 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/blackmisc/network/server.cpp b/src/blackmisc/network/server.cpp index 8f72cb2d5..bc73fed4a 100644 --- a/src/blackmisc/network/server.cpp +++ b/src/blackmisc/network/server.cpp @@ -33,7 +33,7 @@ namespace BlackMisc CServer::CServer( const QString &name, const QString &description, const QString &address, int port, const CUser &user, const CFsdSetup &setup, const CEcosystem &ecosytem, ServerType serverType, bool isAcceptingConnections) - : m_name(name), m_description(description), m_address(address), m_port(port), m_user(user), + : m_name(decode(name)), m_description(decode(description)), m_address(decode(address)), m_port(port), m_user(user), m_fsdSetup(setup), m_ecosystem(ecosytem), m_serverType(serverType), m_isAcceptingConnections(isAcceptingConnections) {} @@ -65,11 +65,12 @@ namespace BlackMisc const CServer &CServer::swiftFsdTestServer(bool withPw) { // CUser("guest", "Guest Client project", "", "guest") + // use CObfuscation::endocde to get the strings static const CServer dvp("Testserver", "Client project testserver", "fsd.swift-project.org", 6809, - CUser("1234567", "Test User", "", "123456"), + CUser("OBF:AwJ6BweZqpmtmORL", "OBF:AwI/594lQTJGZnmSwB0=", "", "OBF:AwKi3JkHNAczBno="), CFsdSetup(), CEcosystem(CEcosystem::swiftTest()), CServer::FSDServerVatsim); static const CServer dvnp("Testserver", "Client project testserver", "fsd.swift-project.org", 6809, - CUser("1234567", "Test User", "", ""), + CUser("OBF:AwJ6BweZqpmtmORL", "OBF:AwI/594lQTJGZnmSwB0=", "", ""), CFsdSetup(), CEcosystem(CEcosystem::swiftTest()), CServer::FSDServerVatsim); return withPw ? dvp : dvnp; } diff --git a/src/blackmisc/network/server.h b/src/blackmisc/network/server.h index 2555a54c5..01f2e92a9 100644 --- a/src/blackmisc/network/server.h +++ b/src/blackmisc/network/server.h @@ -12,11 +12,12 @@ #ifndef BLACKMISC_NETWORK_SERVER_H #define BLACKMISC_NETWORK_SERVER_H -#include "blackmisc/blackmiscexport.h" -#include "blackmisc/metaclass.h" #include "blackmisc/network/user.h" #include "blackmisc/network/fsdsetup.h" #include "blackmisc/network/ecosystem.h" +#include "blackmisc/obfuscation.h" +#include "blackmisc/blackmiscexport.h" +#include "blackmisc/metaclass.h" #include "blackmisc/propertyindex.h" #include "blackmisc/statusmessagelist.h" #include "blackmisc/timestampbased.h" @@ -33,7 +34,8 @@ namespace BlackMisc //! Value object encapsulating information of a server class BLACKMISC_EXPORT CServer : public CValueObject, - public ITimestampBased + public ITimestampBased, + public CObfuscation { public: //! Properties by index @@ -90,7 +92,7 @@ namespace BlackMisc const QString &getAddress() const { return m_address; } //! Set address (e.g. myserver.foo.com) - void setAddress(const QString &address) { m_address = address.trimmed(); } + void setAddress(const QString &address) { m_address = decode(address); } //! Get user const CUser &getUser() const { return m_user; } @@ -105,7 +107,7 @@ namespace BlackMisc bool hasName() const { return !m_name.isEmpty(); } //! Set name - void setName(const QString &name) { m_name = name.trimmed(); } + void setName(const QString &name) { m_name = decode(name); } //! Matches server name? bool matchesName(const QString &name) const; @@ -120,7 +122,7 @@ namespace BlackMisc const QString &getDescription() const { return m_description; } //! Set description - void setDescription(const QString &description) { m_description = description.trimmed().simplified(); } + void setDescription(const QString &description) { m_description = decode(description).simplified(); } //! Get port int getPort() const { return m_port; } diff --git a/src/blackmisc/network/user.cpp b/src/blackmisc/network/user.cpp index b4ad74ee4..2bdf609a4 100644 --- a/src/blackmisc/network/user.cpp +++ b/src/blackmisc/network/user.cpp @@ -35,17 +35,17 @@ namespace BlackMisc } CUser::CUser(const QString &id, const QString &realname, const CCallsign &callsign) - : m_id(id.trimmed()), m_realname(realname), m_callsign(callsign) + : m_id(decode(id)), m_realname(decode(realname)), m_callsign(callsign) { this->deriveHomeBaseFromCallsign(); - this->setRealName(realname); // extracts homebase if this is included in real name + this->setRealName(m_realname); // extracts homebase if this is included in real name } CUser::CUser(const QString &id, const QString &realname, const QString &email, const QString &password, const CCallsign &callsign) - : m_id(id.trimmed()), m_realname(realname), m_email(email), m_password(password), m_callsign(callsign) + : m_id(decode(id)), m_realname(decode(realname)), m_email(decode(email)), m_password(decode(password)), m_callsign(callsign) { this->deriveHomeBaseFromCallsign(); - this->setRealName(realname); // extracts homebase + this->setRealName(m_realname); // extracts homebase } QString CUser::getRealNameAndHomeBase(const QString &separator) const @@ -64,7 +64,7 @@ namespace BlackMisc QString CUser::convertToQString(bool i18n) const { Q_UNUSED(i18n); - if (m_realname.isEmpty()) return ""; + if (m_realname.isEmpty()) return QStringLiteral(""); QString s = m_realname; if (this->hasId()) { @@ -91,7 +91,7 @@ namespace BlackMisc void CUser::setRealName(const QString &realname) { - QString rn(removeAccents(realname.trimmed().simplified())); + QString rn(removeAccents(decode(realname).simplified())); if (rn.isEmpty()) { m_realname.clear(); diff --git a/src/blackmisc/network/user.h b/src/blackmisc/network/user.h index 13044f191..287d179e5 100644 --- a/src/blackmisc/network/user.h +++ b/src/blackmisc/network/user.h @@ -14,13 +14,14 @@ #include "blackmisc/aviation/airporticaocode.h" #include "blackmisc/aviation/callsign.h" -#include "blackmisc/blackmiscexport.h" +#include "blackmisc/obfuscation.h" #include "blackmisc/icon.h" #include "blackmisc/metaclass.h" #include "blackmisc/propertyindex.h" #include "blackmisc/statusmessagelist.h" #include "blackmisc/valueobject.h" #include "blackmisc/variant.h" +#include "blackmisc/blackmiscexport.h" #include #include @@ -32,7 +33,9 @@ namespace BlackMisc /*! * Value object encapsulating information of a user. */ - class BLACKMISC_EXPORT CUser : public CValueObject + class BLACKMISC_EXPORT CUser : + public CValueObject, + public CObfuscation { public: /*! @@ -70,7 +73,7 @@ namespace BlackMisc const QString &getPassword() const { return m_password; } //! Set password - void setPassword(const QString &pw) { m_password = pw.trimmed(); } + void setPassword(const QString &pw) { m_password = decode(pw); } //! Valid user object? bool isValid() const { return !isNull(); } @@ -109,7 +112,7 @@ namespace BlackMisc const QString &getEmail() const { return m_email; } //! Set email. - void setEmail(const QString &email) { m_email = email.trimmed(); } + void setEmail(const QString &email) { m_email = decode(email); } //! Valid email? bool hasValidEmail() const { return !m_email.isEmpty(); } @@ -118,7 +121,7 @@ namespace BlackMisc const QString &getId() const { return m_id; } //! Set id - void setId(const QString &id) { m_id = id.trimmed(); } + void setId(const QString &id) { m_id = decode(id); } //! Homebase const Aviation::CAirportIcaoCode &getHomeBase() const { return m_homebase; }