Ref T249, using obfuscation for server/user

This commit is contained in:
Klaus Basan
2018-02-11 04:39:42 +01:00
parent f8cd1d65ef
commit 29c478496b
4 changed files with 26 additions and 20 deletions

View File

@@ -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;
}

View File

@@ -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<CServer>,
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; }

View File

@@ -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 "<no realname>";
if (m_realname.isEmpty()) return QStringLiteral("<no realname>");
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();

View File

@@ -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 <QMetaType>
#include <QString>
@@ -32,7 +33,9 @@ namespace BlackMisc
/*!
* Value object encapsulating information of a user.
*/
class BLACKMISC_EXPORT CUser : public CValueObject<CUser>
class BLACKMISC_EXPORT CUser :
public CValueObject<CUser>,
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; }