[Libreoffice-commits] core.git: 2 commits - xmlsecurity/inc xmlsecurity/source xmlsecurity/uiconfig
Miklos Vajna
vmiklos at collabora.co.uk
Wed Jan 6 00:43:59 PST 2016
xmlsecurity/inc/xmlsecurity/certificatechooser.hxx | 6 +
xmlsecurity/source/component/documentdigitalsignatures.cxx | 2
xmlsecurity/source/dialogs/certificatechooser.cxx | 42 +++----------
xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx | 3
xmlsecurity/uiconfig/ui/selectcertificatedialog.ui | 34 ++++++++++
5 files changed, 52 insertions(+), 35 deletions(-)
New commits:
commit e514a5583103fcfa0f77a0f91a28b800a9915872
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed Jan 6 09:21:22 2016 +0100
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
diff --git a/xmlsecurity/inc/xmlsecurity/certificatechooser.hxx b/xmlsecurity/inc/xmlsecurity/certificatechooser.hxx
index 24b8637..f376380 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 3ee458f..f020df4 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 fcffef6..99fb5a1 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 70d1d9b..590a8a9 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();
commit ef16f72de9e7abf563239b2ff4083a73430f839f
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed Jan 6 09:07:46 2016 +0100
xmlsecurity: add UI to provide a description when signing
Change-Id: I6fdbcb342d06e05b4965ccf7f593ac130426828a
diff --git a/xmlsecurity/inc/xmlsecurity/certificatechooser.hxx b/xmlsecurity/inc/xmlsecurity/certificatechooser.hxx
index 25f0c60..24b8637 100644
--- a/xmlsecurity/inc/xmlsecurity/certificatechooser.hxx
+++ b/xmlsecurity/inc/xmlsecurity/certificatechooser.hxx
@@ -51,6 +51,7 @@ private:
VclPtr<SvSimpleTable> m_pCertLB;
VclPtr<PushButton> m_pViewBtn;
VclPtr<OKButton> m_pOKBtn;
+ VclPtr<Edit> m_pDescriptionED;
bool mbInitialized;
@@ -71,6 +72,8 @@ public:
short Execute() override;
css::uno::Reference< css::security::XCertificate > GetSelectedCertificate();
+ /// Gets the description string provided when selecting the certificate.
+ OUString GetDescription();
};
diff --git a/xmlsecurity/source/dialogs/certificatechooser.cxx b/xmlsecurity/source/dialogs/certificatechooser.cxx
index 8728c6f..fcffef6 100644
--- a/xmlsecurity/source/dialogs/certificatechooser.cxx
+++ b/xmlsecurity/source/dialogs/certificatechooser.cxx
@@ -54,6 +54,7 @@ CertificateChooser::CertificateChooser( vcl::Window* _pParent, uno::Reference< u
{
get(m_pOKBtn, "ok");
get(m_pViewBtn, "viewcert");
+ get(m_pDescriptionED, "description");
Size aControlSize(275, 122);
const long nControlWidth = aControlSize.Width();
@@ -199,11 +200,17 @@ uno::Reference< css::security::XCertificate > CertificateChooser::GetSelectedCer
return xCert;
}
+OUString CertificateChooser::GetDescription()
+{
+ return m_pDescriptionED->GetText();
+}
+
IMPL_LINK_NOARG_TYPED(CertificateChooser, CertificateHighlightHdl, SvTreeListBox*, void)
{
bool bEnable = GetSelectedCertificate().is();
m_pViewBtn->Enable( bEnable );
m_pOKBtn->Enable( bEnable );
+ m_pDescriptionED->Enable(bEnable);
}
IMPL_LINK_NOARG_TYPED(CertificateChooser, CertificateSelectHdl, SvTreeListBox*, bool)
diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
index 872cd90..70d1d9b 100644
--- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
+++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx
@@ -469,6 +469,7 @@ IMPL_LINK_NOARG_TYPED(DigitalSignaturesDialog, AddButtonHdl, Button*, void)
}
maSignatureHelper.SetDateTime( nSecurityId, Date( Date::SYSTEM ), tools::Time( tools::Time::SYSTEM ) );
+ maSignatureHelper.SetDescription(nSecurityId, aChooser->GetDescription());
// We open a signature stream in which the existing and the new
//signature is written. ImplGetSignatureInformation (later in this function) will
diff --git a/xmlsecurity/uiconfig/ui/selectcertificatedialog.ui b/xmlsecurity/uiconfig/ui/selectcertificatedialog.ui
index adda450..1869bb8 100644
--- a/xmlsecurity/uiconfig/ui/selectcertificatedialog.ui
+++ b/xmlsecurity/uiconfig/ui/selectcertificatedialog.ui
@@ -165,6 +165,40 @@
<property name="top_attach">3</property>
</packing>
</child>
+ <child>
+ <object class="GtkBox" id="dialog-hbox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Description:</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="description">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">4</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">True</property>
More information about the Libreoffice-commits
mailing list