summaryrefslogtreecommitdiff
path: root/xmlsecurity/source
diff options
context:
space:
mode:
Diffstat (limited to 'xmlsecurity/source')
-rw-r--r--xmlsecurity/source/component/documentdigitalsignatures.cxx18
-rw-r--r--xmlsecurity/source/component/documentdigitalsignatures.hxx5
-rw-r--r--xmlsecurity/source/dialogs/certificatechooser.cxx24
-rw-r--r--xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx2
4 files changed, 44 insertions, 5 deletions
diff --git a/xmlsecurity/source/component/documentdigitalsignatures.cxx b/xmlsecurity/source/component/documentdigitalsignatures.cxx
index 6449ed254787..fb4a7fb1b717 100644
--- a/xmlsecurity/source/component/documentdigitalsignatures.cxx
+++ b/xmlsecurity/source/component/documentdigitalsignatures.cxx
@@ -445,7 +445,7 @@ sal_Bool DocumentDigitalSignatures::isAuthorTrusted(
return bFound;
}
-Reference< css::security::XCertificate > DocumentDigitalSignatures::chooseCertificate(OUString& rDescription)
+Reference< css::security::XCertificate > DocumentDigitalSignatures::chooseCertificateImpl(OUString& rDescription, UserAction eAction)
{
std::vector< Reference< css::xml::crypto::XXMLSecurityContext > > xSecContexts;
@@ -455,7 +455,7 @@ Reference< css::security::XCertificate > DocumentDigitalSignatures::chooseCertif
xSecContexts.push_back(aSignatureManager.getGpgSecurityContext());
}
- ScopedVclPtrInstance< CertificateChooser > aChooser(nullptr, mxCtx, xSecContexts);
+ ScopedVclPtrInstance< CertificateChooser > aChooser(nullptr, mxCtx, xSecContexts, eAction);
if (aChooser->Execute() != RET_OK)
return Reference< css::security::XCertificate >(nullptr);
@@ -469,6 +469,20 @@ Reference< css::security::XCertificate > DocumentDigitalSignatures::chooseCertif
return xCert;
}
+Reference< css::security::XCertificate > DocumentDigitalSignatures::chooseCertificate(OUString& rDescription)
+{
+ return chooseCertificateImpl( rDescription, UserAction::Sign );
+}
+
+Reference< css::security::XCertificate > DocumentDigitalSignatures::chooseSigningCertificate(OUString& rDescription)
+{
+ return chooseCertificateImpl( rDescription, UserAction::Sign );
+}
+
+Reference< css::security::XCertificate > DocumentDigitalSignatures::chooseEncryptionCertificate(OUString& rDescription)
+{
+ return chooseCertificateImpl( rDescription, UserAction::Encrypt );
+}
sal_Bool DocumentDigitalSignatures::isLocationTrusted( const OUString& Location )
{
diff --git a/xmlsecurity/source/component/documentdigitalsignatures.hxx b/xmlsecurity/source/component/documentdigitalsignatures.hxx
index 6e23e2d7487d..36e8a6446587 100644
--- a/xmlsecurity/source/component/documentdigitalsignatures.hxx
+++ b/xmlsecurity/source/component/documentdigitalsignatures.hxx
@@ -27,6 +27,7 @@
#include <com/sun/star/security/XDocumentDigitalSignatures.hpp>
#include <com/sun/star/io/XStream.hpp>
#include <com/sun/star/io/XInputStream.hpp>
+#include <certificatechooser.hxx>
#include <documentsignaturehelper.hxx>
namespace com { namespace sun { namespace star {
@@ -61,6 +62,8 @@ private:
/// @throws css::uno::RuntimeException
css::uno::Sequence< css::security::DocumentSignatureInformation > ImplVerifySignatures( const css::uno::Reference< css::embed::XStorage >& rxStorage, const ::com::sun::star::uno::Reference< css::io::XInputStream >& xSignStream, DocumentSignatureMode eMode );
+ css::uno::Reference< css::security::XCertificate > chooseCertificateImpl(OUString& rDescription, UserAction eAction);
+
public:
explicit DocumentDigitalSignatures( const css::uno::Reference< css::uno::XComponentContext>& rxCtx );
virtual ~DocumentDigitalSignatures() override;
@@ -101,6 +104,8 @@ public:
void SAL_CALL addLocationToTrustedSources( const OUString& Location ) override;
css::uno::Reference< css::security::XCertificate > SAL_CALL chooseCertificate(OUString& rDescription) override;
+ css::uno::Reference< css::security::XCertificate > SAL_CALL chooseSigningCertificate(OUString& rDescription) override;
+ css::uno::Reference< css::security::XCertificate > SAL_CALL chooseEncryptionCertificate(OUString& rDescription) override;
};
/// @throws css::uno::Exception
diff --git a/xmlsecurity/source/dialogs/certificatechooser.cxx b/xmlsecurity/source/dialogs/certificatechooser.cxx
index 701367474f1f..52aa7e976e75 100644
--- a/xmlsecurity/source/dialogs/certificatechooser.cxx
+++ b/xmlsecurity/source/dialogs/certificatechooser.cxx
@@ -36,10 +36,14 @@ using namespace css;
CertificateChooser::CertificateChooser(vcl::Window* _pParent,
uno::Reference<uno::XComponentContext> const & _rxCtx,
- std::vector< css::uno::Reference< css::xml::crypto::XXMLSecurityContext > > const & rxSecurityContexts)
+ std::vector< css::uno::Reference< css::xml::crypto::XXMLSecurityContext > > const & rxSecurityContexts,
+ UserAction eAction)
: ModalDialog(_pParent, "SelectCertificateDialog", "xmlsec/ui/selectcertificatedialog.ui"),
- mvUserData()
+ mvUserData(),
+ meAction( eAction )
{
+ get(m_pFTSign, "sign");
+ get(m_pFTEncrypt, "encrypt");
get(m_pOKBtn, "ok");
get(m_pViewBtn, "viewcert");
get(m_pDescriptionED, "description");
@@ -76,6 +80,8 @@ CertificateChooser::~CertificateChooser()
void CertificateChooser::dispose()
{
+ m_pFTSign.clear();
+ m_pFTEncrypt.clear();
m_pCertLB.disposeAndClear();
m_pViewBtn.clear();
m_pOKBtn.clear();
@@ -151,6 +157,20 @@ void CertificateChooser::ImplInitialize()
if ( mbInitialized )
return;
+ switch (meAction)
+ {
+ case UserAction::Sign:
+ m_pFTSign->Show();
+ m_pOKBtn->SetText( get<FixedText>("str_sign")->GetText() );
+ break;
+
+ case UserAction::Encrypt:
+ m_pFTEncrypt->Show();
+ m_pOKBtn->SetText( get<FixedText>("str_encrypt")->GetText() );
+ break;
+
+ }
+
for (auto &secContext : mxSecurityContexts)
{
if (!secContext.is())
diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
index 2b79174c615f..073ac07d44d4 100644
--- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
+++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
@@ -405,7 +405,7 @@ IMPL_LINK_NOARG(DigitalSignaturesDialog, AddButtonHdl, Button*, void)
if (DocumentSignatureHelper::CanSignWithGPG(maSignatureManager.mxStore, m_sODFVersion))
xSecContexts.push_back(maSignatureManager.getGpgSecurityContext());
- ScopedVclPtrInstance< CertificateChooser > aChooser( this, mxCtx, xSecContexts );
+ ScopedVclPtrInstance< CertificateChooser > aChooser( this, mxCtx, xSecContexts, UserAction::Sign );
if ( aChooser->Execute() == RET_OK )
{
sal_Int32 nSecurityId;