summaryrefslogtreecommitdiff
path: root/xmlsecurity
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-01-06 09:21:22 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-01-06 09:43:27 +0100
commite514a5583103fcfa0f77a0f91a28b800a9915872 (patch)
tree1dd0f4711def4ed2b86c12fa0699f2d540fc4507 /xmlsecurity
parentef16f72de9e7abf563239b2ff4083a73430f839f (diff)
xmlsecurity: allow creating multiple signatures with the same certificate
Now that the user can provide a description of the signature, it makes sense to allow multiple signatures from the same user, assuming that the descriptions explain the purpose of the different signatures. Change-Id: I2cd4680594732d6b40dc3ffbcb6b4a9a6ca87919
Diffstat (limited to 'xmlsecurity')
-rw-r--r--xmlsecurity/inc/xmlsecurity/certificatechooser.hxx3
-rw-r--r--xmlsecurity/source/component/documentdigitalsignatures.cxx2
-rw-r--r--xmlsecurity/source/dialogs/certificatechooser.cxx35
-rw-r--r--xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx2
4 files changed, 7 insertions, 35 deletions
diff --git a/xmlsecurity/inc/xmlsecurity/certificatechooser.hxx b/xmlsecurity/inc/xmlsecurity/certificatechooser.hxx
index 24b86372a9fa..f37638066cd0 100644
--- a/xmlsecurity/inc/xmlsecurity/certificatechooser.hxx
+++ b/xmlsecurity/inc/xmlsecurity/certificatechooser.hxx
@@ -46,7 +46,6 @@ private:
css::uno::Reference< css::uno::XComponentContext > mxCtx;
css::uno::Reference< css::xml::crypto::XSecurityEnvironment > mxSecurityEnvironment;
css::uno::Sequence< css::uno::Reference< css::security::XCertificate > > maCerts;
- SignatureInformations maCertsToIgnore;
VclPtr<SvSimpleTable> m_pCertLB;
VclPtr<PushButton> m_pViewBtn;
@@ -65,7 +64,7 @@ private:
void ImplInitialize();
public:
- CertificateChooser( vcl::Window* pParent, css::uno::Reference< css::uno::XComponentContext>& rxCtx, css::uno::Reference< css::xml::crypto::XSecurityEnvironment >& rxSecurityEnvironment, const SignatureInformations& rCertsToIgnore );
+ CertificateChooser(vcl::Window* pParent, css::uno::Reference< css::uno::XComponentContext>& rxCtx, css::uno::Reference< css::xml::crypto::XSecurityEnvironment >& rxSecurityEnvironment);
virtual ~CertificateChooser();
virtual void dispose() override;
diff --git a/xmlsecurity/source/component/documentdigitalsignatures.cxx b/xmlsecurity/source/component/documentdigitalsignatures.cxx
index 3ee458fc9f66..f020df44b537 100644
--- a/xmlsecurity/source/component/documentdigitalsignatures.cxx
+++ b/xmlsecurity/source/component/documentdigitalsignatures.cxx
@@ -439,7 +439,7 @@ Reference< css::security::XCertificate > DocumentDigitalSignatures::chooseCertif
if ( aSignatureHelper.Init() )
xSecEnv = aSignatureHelper.GetSecurityEnvironment();
- ScopedVclPtrInstance< CertificateChooser > aChooser( nullptr, mxCtx, xSecEnv, aSignatureHelper.GetSignatureInformations());
+ ScopedVclPtrInstance< CertificateChooser > aChooser(nullptr, mxCtx, xSecEnv);
if (aChooser->Execute() != RET_OK)
return Reference< css::security::XCertificate >(nullptr);
diff --git a/xmlsecurity/source/dialogs/certificatechooser.cxx b/xmlsecurity/source/dialogs/certificatechooser.cxx
index fcffef660cb0..99fb5a1f406d 100644
--- a/xmlsecurity/source/dialogs/certificatechooser.cxx
+++ b/xmlsecurity/source/dialogs/certificatechooser.cxx
@@ -48,9 +48,8 @@ sal_uInt16 CertificateChooser::GetSelectedEntryPos() const
return (sal_uInt16) nSel;
}
-CertificateChooser::CertificateChooser( vcl::Window* _pParent, uno::Reference< uno::XComponentContext>& _rxCtx, uno::Reference< css::xml::crypto::XSecurityEnvironment >& _rxSecurityEnvironment, const SignatureInformations& _rCertsToIgnore )
+CertificateChooser::CertificateChooser(vcl::Window* _pParent, uno::Reference<uno::XComponentContext>& _rxCtx, uno::Reference<xml::crypto::XSecurityEnvironment>& _rxSecurityEnvironment)
: ModalDialog(_pParent, "SelectCertificateDialog", "xmlsec/ui/selectcertificatedialog.ui")
- , maCertsToIgnore( _rCertsToIgnore )
{
get(m_pOKBtn, "ok");
get(m_pViewBtn, "viewcert");
@@ -136,39 +135,13 @@ void CertificateChooser::ImplInitialize()
::com::sun::star::security::SerialNumberAdapter::create(mxCtx);
sal_Int32 nCertificates = maCerts.getLength();
- sal_Int32 nCertificatesToIgnore = maCertsToIgnore.size();
for( sal_Int32 nCert = nCertificates; nCert; )
{
uno::Reference< security::XCertificate > xCert = maCerts[ --nCert ];
- bool bIgnoreThis = false;
+ // Check if we have a private key for this...
+ long nCertificateCharacters = mxSecurityEnvironment->getCertificateCharacters(xCert);
- // Do we already use that?
- if( nCertificatesToIgnore )
- {
- OUString aIssuerName = xCert->getIssuerName();
- for( sal_Int32 nSig = 0; nSig < nCertificatesToIgnore; ++nSig )
- {
- const SignatureInformation& rInf = maCertsToIgnore[ nSig ];
- if ( ( aIssuerName == rInf.ouX509IssuerName ) &&
- ( xSerialNumberAdapter->toString( xCert->getSerialNumber() ) == rInf.ouX509SerialNumber ) )
- {
- bIgnoreThis = true;
- break;
- }
- }
- }
-
- if ( !bIgnoreThis )
- {
- // Check if we have a private key for this...
- long nCertificateCharacters = mxSecurityEnvironment->getCertificateCharacters( xCert );
-
- if ( !( nCertificateCharacters & security::CertificateCharacters::HAS_PRIVATE_KEY ) )
- bIgnoreThis = true;
-
- }
-
- if ( bIgnoreThis )
+ if (!(nCertificateCharacters & security::CertificateCharacters::HAS_PRIVATE_KEY))
{
::comphelper::removeElementAt( maCerts, nCert );
nCertificates = maCerts.getLength();
diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
index 70d1d9b5d9a6..590a8a90427e 100644
--- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
+++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
@@ -430,7 +430,7 @@ IMPL_LINK_NOARG_TYPED(DigitalSignaturesDialog, AddButtonHdl, Button*, void)
uno::Reference<com::sun::star::security::XSerialNumberAdapter> xSerialNumberAdapter =
::com::sun::star::security::SerialNumberAdapter::create(mxCtx);
- ScopedVclPtrInstance< CertificateChooser > aChooser( this, mxCtx, xSecEnv, maCurrentSignatureInformations );
+ ScopedVclPtrInstance< CertificateChooser > aChooser( this, mxCtx, xSecEnv );
if ( aChooser->Execute() == RET_OK )
{
uno::Reference< ::com::sun::star::security::XCertificate > xCert = aChooser->GetSelectedCertificate();