Files
k7/AppConfig.h

117 lines
2.9 KiB
C
Raw Permalink Normal View History

2019-10-25 20:16:43 +02:00
/*
* File: AppConfig.h
2022-11-19 15:56:56 +01:00
* Author: Saleem Edah-Tally - nmset@yandex.com
2019-10-25 20:16:43 +02:00
* License : GPL v2
2022-11-19 15:56:56 +01:00
* Copyright Saleem Edah-Tally - © 2019
2019-10-25 20:16:43 +02:00
*
* Created on 9 octobre 2019, 20:23
*/
#ifndef APPCONFIG_H
#define APPCONFIG_H
#include <Wt/WString.h>
#include <Wt/Json/Object.h>
#include <Wt/WSslCertificate.h>
#include <Wt/WText.h>
#include <vector>
using namespace Wt;
using namespace std;
/**
* Json configuration file reader.
*/
2020-11-14 14:46:28 +01:00
class AppConfig
{
2019-10-25 20:16:43 +02:00
public:
AppConfig(WText * notifyWidget);
virtual ~AppConfig();
/**
* Must be called by app. No autoloading of config file.
* @return
*/
bool LoadConfig();
/**
* Can the user import keys ?
* @return
*/
bool CanImport() const;
/**
* Can the user delete keys ? N.B. : he may delete private keys
* only if he manages these keys.
* @return
*/
bool CanDelete() const;
/**
* Allows to edit trust in key owner. Users who don't manage private keys
* can to that too.
* @return
*/
bool CanEditOwnerTrust() const;
/**
* Allows to edit validity of user identity.
* Only users who manage private keys can do that.
* @return
*/
bool CanEditUidValidity() const;
/**
* Allows to edit expiry time of a key.
* Only private keys are concerned.
* @return
*/
bool CanEditExpiryTime() const;
/**
* Allows to create keys. At the application level, it means creating a pair
* of secret and private keys.
* @return
*/
bool CanCreateKeys() const;
/**
* Allows to add or revoke a user identity to a key. It deos not mean
* deleting an identity.
* @return
*/
bool CanAddRevokeUid() const;
/**
* Disown the user of the secret key, or grants him ownership. It just adds
* or remove fpr from the private key array, without any further check. The
* application must call here when relevant.
* @param fpr
* @param own : if true, adds the fpr to the private key array if found.
* Else, removes the fpr if found.
* @return
*/
bool UpdateSecretKeyOwnership(const WString& fpr, bool own);
2019-10-25 20:16:43 +02:00
/**
* List of full private key identifiers. The user may delete these private keys.
* Must be full keyid, short keyid or fingerprint.
* @return
*/
vector<WString> PrivateKeyIds() const;
private:
/**
* To display error messages
*/
WText * m_notifyWidget;
/**
* Root object of the config file
*/
Json::Object m_RootObject;
/**
* User object, identified by the Subject Common Name of the X509 client certificate.
*/
Json::Object m_SubjectCNObject;
/**
* Get an X509 client certificate attribute value
* @param attrName
* @return
*/
const WString GetSubjectDnAttribute(const WSslCertificate::DnAttributeName& attrName) const;
2020-11-14 14:46:28 +01:00
bool WriteTextFile(const WString& filePath, const WString& content);
2019-10-25 20:16:43 +02:00
};
#endif /* APPCONFIG_H */