Add certificate store for access to NSS keys

WIP - add interfaces and methods to get access to NSS-via-poppler
sign certificates, and provide them for signing documents.
This commit is contained in:
Thorsten Behrens 2019-12-11 10:44:55 +01:00 committed by Albert Astals Cid
parent 847b423e2a
commit b96dac6df3
6 changed files with 64 additions and 0 deletions

View file

@ -20,6 +20,7 @@
#include "global.h"
#include "okularcore_export.h"
#include "pagesize.h"
#include "signatureutils.h"
#include <QList>
#include <QObject>
@ -311,6 +312,8 @@ public:
virtual bool sign( const Okular::Annotation* /*pWhichAnnotation*/, const QString& /*rFilename*/) { return false; }
virtual CertificateStore* getCertStore() { return nullptr; }
/**
* This method can be called to trigger the generation of
* a new pixmap as described by @p request.

View file

@ -154,3 +154,16 @@ const CertificateInfo &SignatureInfo::certificateInfo() const
static CertificateInfo dummy;
return dummy;
}
CertificateStore::CertificateStore()
{
}
CertificateStore::~CertificateStore()
{
}
QList<CertificateInfo*> CertificateStore::getSigningCertificates() const
{
return QList<CertificateInfo*>();
}

View file

@ -239,6 +239,29 @@ private:
Q_DISABLE_COPY(SignatureInfo)
};
/**
* @short A helper class to store information about x509 certificate
*/
class OKULARCORE_EXPORT CertificateStore
{
public:
/**
* Destructor
*/
virtual ~CertificateStore();
/**
* Returns list of valid, usable signing certificates
*/
virtual QList<CertificateInfo*> getSigningCertificates() const;
protected:
CertificateStore();
private:
Q_DISABLE_COPY( CertificateStore )
};
}
#endif

View file

@ -103,6 +103,8 @@ public:
bool canSign() const override {return true;}
bool sign( const Okular::Annotation* pWhichAnnotation, const QString& rFilename ) override;
Okular::CertificateStore* getCertStore() override;
protected:
SwapBackingFileResult swapBackingFile(QString const &newFileName, QVector<Okular::Page *> &newPagesVector) override;
bool doCloseDocument() override;

View file

@ -64,4 +64,18 @@ private:
Okular::CertificateInfo *m_certfiticateInfo;
};
#ifdef HAVE_POPPLER_SIGNING
class PopplerCertificateStore : public Okular::CertificateStore
{
public:
PopplerCertificateStore();
~PopplerCertificateStore();
QList<Okular::CertificateInfo*> getSigningCertificates() const override;
//QList<PopplerCertificateInfo*> getSigningCertificates() const override;
};
#endif
#endif

View file

@ -44,6 +44,15 @@ void CertificateTools::setTools(const QStringList& /*items*/)
foreach( const QString cert, certs )
{
QListWidgetItem * listEntry = new QListWidgetItem( cert, m_list );
(void)listEntry;
}
//QVector<Poppler::CertificateInfo*> nssCerts = Poppler::getAvailableSigningCertificates();
Poppler::getAvailableSigningCertificates();
foreach( auto cert, nssCerts )
{
QListWidgetItem * listEntry = new QListWidgetItem( cert->getSubjectInfo().commonName,
m_list );
(void)listEntry;
}
updateButtons();