2017-07-03 09:30:10 +02:00
|
|
|
/*!
|
|
|
|
* \brief Parses self authentication data from XML data and provides its content.
|
|
|
|
*
|
2018-03-28 15:10:51 +02:00
|
|
|
* \copyright Copyright (c) 2014-2018 Governikus GmbH & Co. KG, Germany
|
2017-07-03 09:30:10 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "EnumHelper.h"
|
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
|
2017-12-20 14:54:05 +01:00
|
|
|
#include <QCoreApplication>
|
2017-07-03 09:30:10 +02:00
|
|
|
#include <QDateTime>
|
|
|
|
#include <QDomElement>
|
|
|
|
#include <QMap>
|
2017-12-20 14:54:05 +01:00
|
|
|
#include <QPair>
|
|
|
|
#include <QSharedData>
|
|
|
|
#include <QString>
|
|
|
|
#include <QVector>
|
2017-07-03 09:30:10 +02:00
|
|
|
|
|
|
|
namespace governikus
|
|
|
|
{
|
|
|
|
|
|
|
|
defineEnumType(SelfAuthDataPermission,
|
|
|
|
UNKNOWN /* used for parser only */,
|
|
|
|
ALLOWED,
|
|
|
|
PROHIBITED,
|
|
|
|
NOTONCHIP)
|
|
|
|
|
|
|
|
defineEnumType(SelfAuthData,
|
|
|
|
UNKNOWN, /* used for parser only */
|
|
|
|
DocumentType,
|
|
|
|
IssuingState,
|
|
|
|
DateOfExpiry,
|
|
|
|
GivenNames,
|
|
|
|
FamilyNames,
|
|
|
|
ArtisticName,
|
|
|
|
AcademicTitle,
|
|
|
|
BirthName,
|
|
|
|
DateOfBirth,
|
|
|
|
PlaceOfBirth,
|
|
|
|
PlaceOfResidence,
|
|
|
|
Nationality,
|
|
|
|
ResidencePermitI,
|
|
|
|
RestrictedID,
|
|
|
|
AgeVerification,
|
|
|
|
PlaceVerification,
|
|
|
|
/* additional fields */
|
|
|
|
PlaceOfResidenceStreet,
|
|
|
|
PlaceOfResidenceCity,
|
|
|
|
PlaceOfResidenceCountry,
|
|
|
|
PlaceOfResidenceZipCode,
|
|
|
|
PlaceOfResidenceNoPlaceInfo)
|
|
|
|
|
|
|
|
|
|
|
|
class SelfAuthenticationData
|
|
|
|
{
|
2017-12-20 14:54:05 +01:00
|
|
|
public:
|
|
|
|
using OrderedSelfData = QVector<QPair<QString, QString> >;
|
2017-07-03 09:30:10 +02:00
|
|
|
|
|
|
|
private:
|
2017-12-20 14:54:05 +01:00
|
|
|
class SelfData
|
|
|
|
: public QSharedData
|
|
|
|
{
|
|
|
|
Q_DECLARE_TR_FUNCTIONS(governikus::SelfData)
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool parse(const QDomDocument& pDoc, const QString& pElementName, const std::function<bool(const QDomElement&)>& pParserFunc);
|
|
|
|
bool parseOperationsAllowedByUser(const QDomElement& pElement);
|
|
|
|
bool parsePersonalData(const QDomElement& pElement);
|
|
|
|
bool tryToInsertChild(const QDomElement& pElement, SelfAuthData pAuthData);
|
|
|
|
|
|
|
|
public:
|
|
|
|
bool mValid;
|
|
|
|
const QDateTime mDateTime;
|
|
|
|
QMap<SelfAuthData, SelfAuthDataPermission> mOperationsAllowed;
|
|
|
|
QMap<SelfAuthData, QString> mSelfAuthData;
|
|
|
|
|
|
|
|
SelfData(const QByteArray& pData);
|
|
|
|
QString getValue(SelfAuthData pData) const;
|
|
|
|
OrderedSelfData getOrderedSelfInfo() const;
|
|
|
|
};
|
|
|
|
|
|
|
|
QSharedDataPointer<SelfData> d;
|
2017-07-03 09:30:10 +02:00
|
|
|
|
|
|
|
public:
|
2017-12-20 14:54:05 +01:00
|
|
|
SelfAuthenticationData(const QByteArray& pData = QByteArray());
|
|
|
|
~SelfAuthenticationData() = default;
|
2017-07-03 09:30:10 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if parsing of given data was successful.
|
|
|
|
*/
|
|
|
|
bool isValid() const;
|
|
|
|
QString getValue(SelfAuthData pData) const;
|
|
|
|
const QDateTime& getDateTime() const;
|
2017-12-20 14:54:05 +01:00
|
|
|
OrderedSelfData getOrderedSelfData() const;
|
2017-07-03 09:30:10 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace governikus */
|