mirror of
https://invent.kde.org/graphics/okular
synced 2024-10-02 14:14:10 +00:00
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:
parent
847b423e2a
commit
b96dac6df3
|
@ -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.
|
||||
|
|
|
@ -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*>();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue