[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - xmlsecurity/inc xmlsecurity/source
xmlsecurity/inc/sigstruct.hxx |1 xmlsecurity/inc/xmlsignaturehelper.hxx |2 xmlsecurity/inc/xsecctl.hxx|4 + xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx | 47 + xmlsecurity/source/helper/documentsignaturemanager.cxx |2 xmlsecurity/source/helper/xmlsignaturehelper.cxx |6 +- xmlsecurity/source/helper/xsecctl.cxx |7 ++ xmlsecurity/source/helper/xsecparser.cxx | 16 + xmlsecurity/source/helper/xsecparser.hxx |2 xmlsecurity/source/helper/xsecsign.cxx |5 + xmlsecurity/source/helper/xsecverify.cxx | 11 +++ 11 files changed, 76 insertions(+), 27 deletions(-) New commits: commit d3219c5e801056c1c3ca0d9912794b804c2d763e Author: Samuel Mehrbrodt Date: Mon Jul 10 10:02:10 2017 +0200 tdf#108977 Show signature info for keys we don't have locally gpg4libre Reviewed-on: https://gerrit.libreoffice.org/39742 Reviewed-by: Thorsten Behrens Tested-by: Thorsten Behrens (cherry picked from commit 820bd4b3b64a5746599c48c729037a959ff61c84) Change-Id: I89593224590007e61bce95c14922c08551282067 Reviewed-on: https://gerrit.libreoffice.org/39761 Tested-by: Jenkins Reviewed-by: Miklos Vajna diff --git a/xmlsecurity/inc/sigstruct.hxx b/xmlsecurity/inc/sigstruct.hxx index 68e64176206b..ff6ee5e5d3a5 100644 --- a/xmlsecurity/inc/sigstruct.hxx +++ b/xmlsecurity/inc/sigstruct.hxx @@ -77,6 +77,7 @@ struct SignatureInformation OUString ouGpgKeyID; OUString ouGpgCertificate; +OUString ouGpgOwner; OUString ouSignatureValue; css::util::DateTime stDateTime; diff --git a/xmlsecurity/inc/xmlsignaturehelper.hxx b/xmlsecurity/inc/xmlsignaturehelper.hxx index 261a4792cd61..a473b1efd840 100644 --- a/xmlsecurity/inc/xmlsignaturehelper.hxx +++ b/xmlsecurity/inc/xmlsignaturehelper.hxx @@ -155,7 +155,7 @@ public: void AddEncapsulatedX509Certificate(const OUString& ouEncapsulatedX509Certificate); void SetGpgCertificate(sal_Int32 nSecurityId, const OUString& ouGpgCertDigest, -const OUString& ouGpgCert); +const OUString& ouGpgCert, const OUString& ouGpgOwner); voidSetDateTime( sal_Int32 nSecurityId, const Date& rDate, const tools::Time& rTime ); void SetDescription(sal_Int32 nSecurityId, const OUString& rDescription); diff --git a/xmlsecurity/inc/xsecctl.hxx b/xmlsecurity/inc/xsecctl.hxx index a38c1cbf8e3d..9ddc22affbae 100644 --- a/xmlsecurity/inc/xsecctl.hxx +++ b/xmlsecurity/inc/xsecctl.hxx @@ -309,6 +309,7 @@ private: void setDigestValue( sal_Int32 nDigestID, OUString& ouDigestValue ); void setGpgKeyID( OUString& ouKeyID ); void setGpgCertificate( OUString& ouGpgCert ); +void setGpgOwner( OUString& ouGpgOwner ); void setDate( OUString& ouDate ); void setDescription(const OUString& rDescription); @@ -388,7 +389,8 @@ public: void setGpgCertificate( sal_Int32 nSecurityId, const OUString& ouCertDigest, -const OUString& ouCert); +const OUString& ouCert, +const OUString& ouOwner); void setDate( sal_Int32 nSecurityId, diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx index 6df31eec715f..22154dc4b2a3 100644 --- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx +++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx @@ -532,7 +532,6 @@ void DigitalSignaturesDialog::ImplFillSignaturesBox() const SignatureInformation& rInfo = maSignatureManager.maCurrentSignatureInformations[n]; uno::Reference< css::security::XCertificate > xCert = getCertificate(rInfo); -// TODO - should use pgpdata from info provider? OUString aSubject; OUString aIssuer; OUString aDateTimeStr; @@ -559,28 +558,34 @@ void DigitalSignaturesDialog::ImplFillSignaturesBox() aSubject = XmlSec::GetContentPart( xCert->getSubjectName() ); aIssuer = XmlSec::GetContentPart( xCert->getIssuerName() ); -// String with date and time information (#i20172#) -aDateTimeStr = XmlSec::GetDateTimeString( rInfo.stDateTime ); -aDescription = rInfo.ouDescription; - -// Decide type string. -if (maSignatureManager.mxStore.is()) -{ -// XML based: XAdES or not. -if (!rInfo.ouCertDigest.isEmpty()) -aType = "XAdES"; -else -aType = "XML-DSig"; -} +} +else if (!rInfo.ouGpgCertificate.isEmpty()) +{ +// In case we don't have the gpg key locally, get some data from the document +aIssuer = r
[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - xmlsecurity/inc xmlsecurity/source
xmlsecurity/inc/xmlsec-wrapper.h |3 xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx | 39 ++ xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.hxx |2 3 files changed, 29 insertions(+), 15 deletions(-) New commits: commit c349af53490d5e883ec791fb743092243c7ad46e Author: Miklos Vajna Date: Tue Jun 20 21:47:38 2017 +0200 xmlsecurity nss: adopt the private key of the signing certificate explicitly xmlsec1-customkeymanage.patch.1 of our bundled xmlsec extends xmlSecNssKeyDataX509VerifyAndExtractKey(), so that it calls xmlSecNssPKIAdoptKey() for the private key of the signing certificate. Make this explicit in xmlsecurity/ code, so we don't depend on the patched xmlSecNssKeyDataX509VerifyAndExtractKey(). This is harmless for the patched xmlsec, but it prevents this error: warn:xmlsecurity.xmlsec:26221:1:xmlsecurity/source/xmlsec/errorcallback.cxx:48: keys.c:1246: xmlSecKeysMngrGetKey() '' 'xmlSecKeysMngrFindKey' 1 ' ' warn:xmlsecurity.xmlsec:26221:1:xmlsecurity/source/xmlsec/errorcallback.cxx:48: xmldsig.c:790: xmlSecDSigCtxProcessKeyInfoNode() '' '' 45 'details=NULL' warn:xmlsecurity.xmlsec:26221:1:xmlsecurity/source/xmlsec/errorcallback.cxx:48: xmldsig.c:503: xmlSecDSigCtxProcessSignatureNode() '' 'xmlSecDSigCtxProcessKeyInfoNode' 1 ' ' warn:xmlsecurity.xmlsec:26221:1:xmlsecurity/source/xmlsec/errorcallback.cxx:48: xmldsig.c:286: xmlSecDSigCtxSign() '' 'xmlSecDSigCtxSignatureProcessNode' 1 ' ' when xmlsec is not patched. (This is needed, but not enough to build against system xmlsec.) Change-Id: I5d68a8be7aefcb529566213f9b9c2985eab6a80a Reviewed-on: https://gerrit.libreoffice.org/39023 Reviewed-by: Miklos Vajna Tested-by: Jenkins Reviewed-on: https://gerrit.libreoffice.org/39273 Reviewed-by: Rene Engelhard Tested-by: Rene Engelhard diff --git a/xmlsecurity/inc/xmlsec-wrapper.h b/xmlsecurity/inc/xmlsec-wrapper.h index 3d5c24b9b6f1..4a8a6554311b 100644 --- a/xmlsecurity/inc/xmlsec-wrapper.h +++ b/xmlsecurity/inc/xmlsec-wrapper.h @@ -40,6 +40,9 @@ #include "xmlsec/xmlenc.h" #include "xmlsec/xmlsec.h" #include "xmlsec/xmltree.h" +#ifdef XMLSEC_CRYPTO_NSS +#include "xmlsec/nss/pkikeys.h" +#endif #endif diff --git a/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx index 959e62cc34e0..a5b29017d180 100644 --- a/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx +++ b/xmlsecurity/source/xmlsec/nss/securityenvironment_nssimpl.cxx @@ -474,6 +474,9 @@ Reference< XCertificate > SecurityEnvironment_NssImpl::getCertificate( const OUS } Sequence< Reference < XCertificate > > SecurityEnvironment_NssImpl::buildCertificatePath( const Reference< XCertificate >& begin ) { +// Remember the signing certificate. +m_xSigningCertificate = begin; + const X509Certificate_NssImpl* xcert ; const CERTCertificate* cert ; CERTCertList* certChain ; @@ -881,19 +884,8 @@ X509Certificate_NssImpl* NssPrivKeyToXCert( SECKEYPrivateKey* priKey ) return xcert ; } - -/* Native methods */ xmlSecKeysMngrPtr SecurityEnvironment_NssImpl::createKeysManager() { -unsigned int i ; -CERTCertDBHandle* handler = nullptr ; -PK11SymKey* symKey = nullptr ; -SECKEYPublicKey* pubKey = nullptr ; -SECKEYPrivateKey* priKey = nullptr ; -xmlSecKeysMngrPtr pKeysMngr = nullptr ; - -handler = m_pHandler; - /*- * The following lines is based on the private version of xmlSec-NSS * crypto engine @@ -905,14 +897,15 @@ xmlSecKeysMngrPtr SecurityEnvironment_NssImpl::createKeysManager() { for (CIT_SLOTS islots = m_Slots.begin();islots != m_Slots.end(); ++islots, ++count) slots[count] = *islots; -pKeysMngr = xmlSecNssAppliedKeysMngrCreate(slots, cSlots, handler ) ; +xmlSecKeysMngrPtr pKeysMngr = xmlSecNssAppliedKeysMngrCreate(slots, cSlots, m_pHandler ) ; if( pKeysMngr == nullptr ) throw RuntimeException() ; /*- * Adopt symmetric key into keys manager */ -for( i = 0 ; ( symKey = this->getSymKey( i ) ) != nullptr ; i ++ ) { +PK11SymKey* symKey = nullptr ; +for( unsigned int i = 0 ; ( symKey = this->getSymKey( i ) ) != nullptr ; i ++ ) { if( xmlSecNssAppliedKeysMngrSymKeyLoad( pKeysMngr, symKey ) < 0 ) { throw RuntimeException() ; } @@ -921,7 +914,8 @@ xmlSecKeysMngrPtr SecurityEnvironment_NssImpl::createKeysManager() { /*- * Adopt asymmetric public key into keys manager */ -for( i = 0 ; ( pubKey = this->getPubKey( i ) ) != nullptr ; i ++ ) { +SECKEYPublicKey* pubKey = nullptr ; +for( unsigned int i = 0 ; ( pubKey = this->getPubKey( i ) ) != nullptr ; i ++ ) { if( xmlSecNssAppliedKeysMngrPubKeyLoad( pKeysMngr, pubKey ) < 0 ) { throw RuntimeException()
[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - xmlsecurity/inc xmlsecurity/source
xmlsecurity/inc/documentsignaturehelper.hxx|3 ++ xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx |5 +++- xmlsecurity/source/helper/documentsignaturehelper.cxx | 19 + xmlsecurity/source/helper/documentsignaturemanager.cxx |1 4 files changed, 26 insertions(+), 2 deletions(-) New commits: commit 8b9f00fced21014bed6695b962084c8af0249dbc Author: Samuel Mehrbrodt Date: Mon Jun 26 12:32:48 2017 +0200 tdf#108711 GPG key selection should only be possible for ODF >= 1.2 documents gpg4libre Change-Id: I6dbdaefddacf55c9381d156ada20cb3f25d4b3cb Reviewed-on: https://gerrit.libreoffice.org/39263 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt (cherry picked from commit e2378bbf4539455e445205ad868c43246ec423ed) Reviewed-on: https://gerrit.libreoffice.org/39287 Reviewed-by: Thorsten Behrens diff --git a/xmlsecurity/inc/documentsignaturehelper.hxx b/xmlsecurity/inc/documentsignaturehelper.hxx index c2b5b85e34a2..a8f3cb1f5d40 100644 --- a/xmlsecurity/inc/documentsignaturehelper.hxx +++ b/xmlsecurity/inc/documentsignaturehelper.hxx @@ -81,6 +81,9 @@ namespace DocumentSignatureHelper DocumentSignatureAlgorithm getDocumentAlgorithm( const OUString & sODFVersion, const SignatureInformation & sigInfo); +bool CanSignWithGPG(const css::uno::Reference < css::embed::XStorage >& rxStore, +const OUString& sOdfVersion); + bool checkIfAllFilesAreSigned( const ::std::vector< OUString > & sElementList, const SignatureInformation & sigInfo, const DocumentSignatureAlgorithm alg); diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx index 5f4464b8b957..2b950e62777e 100644 --- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx +++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -400,7 +401,9 @@ IMPL_LINK_NOARG(DigitalSignaturesDialog, AddButtonHdl, Button*, void) { std::vector> xSecContexts; xSecContexts.push_back(maSignatureManager.getSecurityContext()); -xSecContexts.push_back(maSignatureManager.getGpgSecurityContext()); +// Gpg signing is only possible with ODF >= 1.2 documents +if (DocumentSignatureHelper::CanSignWithGPG(maSignatureManager.mxStore, m_sODFVersion)) +xSecContexts.push_back(maSignatureManager.getGpgSecurityContext()); ScopedVclPtrInstance< CertificateChooser > aChooser( this, mxCtx, xSecContexts ); if ( aChooser->Execute() == RET_OK ) diff --git a/xmlsecurity/source/helper/documentsignaturehelper.cxx b/xmlsecurity/source/helper/documentsignaturehelper.cxx index 1d8d1c0d72cb..a8b355116ff3 100644 --- a/xmlsecurity/source/helper/documentsignaturehelper.cxx +++ b/xmlsecurity/source/helper/documentsignaturehelper.cxx @@ -408,6 +408,25 @@ SignatureStreamHelper DocumentSignatureHelper::OpenSignatureStream( return aHelper; } +/** Check whether the current file can be signed with GPG (only ODF >= 1.2 can currently) */ +bool DocumentSignatureHelper::CanSignWithGPG( +const Reference < css::embed::XStorage >& rxStore, +const OUString& sOdfVersion) +{ +uno::Reference xNameAccess(rxStore, uno::UNO_QUERY); +if (!xNameAccess.is()) +throw RuntimeException(); + +if (xNameAccess->hasByName("META-INF")) // ODF +{ +return !isODFPre_1_2(sOdfVersion); +} + +return false; +} + + + //sElementList contains all files which are expected to be signed. Only those files must me signed, //no more, no less. //The DocumentSignatureAlgorithm indicates if the document was created with OOo 2.x. Then diff --git a/xmlsecurity/source/helper/documentsignaturemanager.cxx b/xmlsecurity/source/helper/documentsignaturemanager.cxx index ee863e4c2530..41f7e5594cf2 100644 --- a/xmlsecurity/source/helper/documentsignaturemanager.cxx +++ b/xmlsecurity/source/helper/documentsignaturemanager.cxx @@ -269,7 +269,6 @@ bool DocumentSignatureManager::add(const uno::Reference& if (xServiceInfo->getImplementationName() == "com.sun.star.xml.security.gpg.XMLSecurityContext_GpgImpl") { // GPG keys only really have PGPKeyId and PGPKeyPacket -// TODO: prevent selection of gpg keys for pdfs and ooxml early on! if (!mxStore.is()) { SAL_WARN("xmlsecurity.helper", "cannot sign pdfs with GPG keys"); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - xmlsecurity/inc xmlsecurity/source xmlsecurity/uiconfig
xmlsecurity/inc/resourcemanager.hxx|2 ++ xmlsecurity/source/dialogs/certificatechooser.cxx | 10 ++ xmlsecurity/source/dialogs/resourcemanager.cxx | 13 + xmlsecurity/uiconfig/ui/selectcertificatedialog.ui | 11 +++ 4 files changed, 32 insertions(+), 4 deletions(-) New commits: commit 5119d81e41e9c7199d3f419e24cba81537edff55 Author: Katarina Behrens Date: Tue Jun 20 14:21:06 2017 +0200 gpg4libre: Show certificate kind OpenPGP vs. X509 as 1 table column Shuffled the columns around a little bit Change-Id: Ib0a979458db680d712737ff997e1c3b4e4564f3f Reviewed-on: https://gerrit.libreoffice.org/38984 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt (cherry picked from commit 72f84c1a0efbce8da02cbf6d5947d2ddfd45c533) Reviewed-on: https://gerrit.libreoffice.org/39148 Reviewed-by: Sophie Gautier Reviewed-by: Heiko Tietze diff --git a/xmlsecurity/inc/resourcemanager.hxx b/xmlsecurity/inc/resourcemanager.hxx index ece7fba24fe2..659c65bc0431 100644 --- a/xmlsecurity/inc/resourcemanager.hxx +++ b/xmlsecurity/inc/resourcemanager.hxx @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -39,6 +40,7 @@ namespace XmlSec DateTimeGetDateTime( const css::util::DateTime& _rDT ); OUStringGetDateTimeString( const css::util::DateTime& _rDT ); OUStringGetDateString( const css::util::DateTime& _rDT ); +OUStringGetCertificateKind( const css::security::CertificateKind& rKind ); std::vector< std::pair< OUString, OUString> > parseDN(const OUString& rRawString); diff --git a/xmlsecurity/source/dialogs/certificatechooser.cxx b/xmlsecurity/source/dialogs/certificatechooser.cxx index 726b4038aa96..cb9d2db4d4e5 100644 --- a/xmlsecurity/source/dialogs/certificatechooser.cxx +++ b/xmlsecurity/source/dialogs/certificatechooser.cxx @@ -52,10 +52,11 @@ CertificateChooser::CertificateChooser(vcl::Window* _pParent, pSignatures->set_height_request(aControlSize.Height()); m_pCertLB = VclPtr::Create(*pSignatures); -static long nTabs[] = { 4, 0, 20*nControlWidth/100, 40*nControlWidth/100, 80*nControlWidth/100 }; +static long nTabs[] = { 5, 0, 20*nControlWidth/100, 50*nControlWidth/100, 60*nControlWidth/100, 70*nControlWidth/100 }; m_pCertLB->SetTabs( &nTabs[0] ); m_pCertLB->InsertHeaderEntry(get("issuedto")->GetText() + "\t" + get("issuedby")->GetText() -+ "\t" + get("usage")->GetText() + "\t" + get("expiration")->GetText()); ++ "\t" + get("type")->GetText() + "\t" + get("expiration")->GetText() ++ "\t" + get("usage")->GetText()); m_pCertLB->SetSelectHdl( LINK( this, CertificateChooser, CertificateHighlightHdl ) ); m_pCertLB->SetDoubleClickHdl( LINK( this, CertificateChooser, CertificateSelectHdl ) ); m_pViewBtn->SetClickHdl( LINK( this, CertificateChooser, ViewButtonHdl ) ); @@ -189,8 +190,9 @@ void CertificateChooser::ImplInitialize() mvUserData.push_back(userData); SvTreeListEntry* pEntry = m_pCertLB->InsertEntry( XmlSec::GetContentPart( xCerts[ nC ]->getSubjectName() ) + "\t" + XmlSec::GetContentPart( xCerts[ nC ]->getIssuerName() ) -+ "\t" + UsageInClearText( xCerts[ nC ]->getCertificateUsage() ) -+ "\t" + XmlSec::GetDateString( xCerts[ nC ]->getNotValidAfter() ) ); ++ "\t" + XmlSec::GetCertificateKind( xCerts[ nC ]->getCertificateKind() ) ++ "\t" + XmlSec::GetDateString( xCerts[ nC ]->getNotValidAfter() ) ++ "\t" + UsageInClearText( xCerts[ nC ]->getCertificateUsage() ) ); pEntry->SetUserData( userData.get() ); } } diff --git a/xmlsecurity/source/dialogs/resourcemanager.cxx b/xmlsecurity/source/dialogs/resourcemanager.cxx index e989af368b60..2f2e6596f720 100644 --- a/xmlsecurity/source/dialogs/resourcemanager.cxx +++ b/xmlsecurity/source/dialogs/resourcemanager.cxx @@ -68,6 +68,19 @@ namespace XmlSec return GetLocaleData().getDate( GetDateTime( _rDT ) ); } +OUString GetCertificateKind( const css::security::CertificateKind &rKind ) +{ +switch (rKind) +{ +case css::security::CertificateKind_X509: +return OUString("X.509"); +case css::security::CertificateKind_OPENPGP: +return OUString("OpenPGP"); +default: +return OUString(); +} +} + /* Creates two strings based on the distinguished name which are displayed in the certificate details view. The first string contains only the values of the attribute diff --git a/xmlsecurity/uiconfig/ui/selectcertificatedialog.ui b/xmlsecurity/uiconfig/ui/selectcertificatedialog.ui index 0d9d60152cb6..57494738eda0 100644 --- a/xmlsecurity/uiconfig/ui/selectcertificatedialog.ui +++ b/xmlsecurity/uiconfig/ui/selectce
[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - xmlsecurity/inc xmlsecurity/source
xmlsecurity/inc/digitalsignaturesdialog.hxx |2 xmlsecurity/inc/documentsignaturemanager.hxx |2 xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx |2 xmlsecurity/source/gpg/SecurityEnvironment.cxx |1 xmlsecurity/source/helper/documentsignaturemanager.cxx |5 -- xmlsecurity/source/xmlsec/mscrypt/xmlsecuritycontext_mscryptimpl.cxx | 23 -- 6 files changed, 7 insertions(+), 28 deletions(-) New commits: commit d86170942e322aabd928bf56854cb7cf08bd13a1 Author: Thorsten Behrens Date: Thu Jun 22 13:25:20 2017 +0200 gpg4libre: cleanup some issues Backport from master, squashed in: - gpg4libre: Init xmlsec in one place before creating the services - xmlsecurity: fix loplugin:unusedvariablecheck warning - xmlsecurity: fix loplugin:passstuffbyref warnings - xmlsecurity: remove newly introduced redundant namespace alias, used only once Change-Id: I46a05074706bba77ebc488f0df296e35e2b7d553 Reviewed-on: https://gerrit.libreoffice.org/39096 Reviewed-by: Thorsten Behrens Tested-by: Thorsten Behrens diff --git a/xmlsecurity/inc/digitalsignaturesdialog.hxx b/xmlsecurity/inc/digitalsignaturesdialog.hxx index e49419e57a4a..9f488bb91c9f 100644 --- a/xmlsecurity/inc/digitalsignaturesdialog.hxx +++ b/xmlsecurity/inc/digitalsignaturesdialog.hxx @@ -103,7 +103,7 @@ private: css::uno::Reference getCertificate(const SignatureInformation& rInfo); css::uno::Reference getSecurityEnvironmentForCertificate( -css::uno::Reference xCert); +const css::uno::Reference& xCert); //Checks if adding is allowed. //See the spec at specs/www/appwide/security/Electronic_Signatures_and_Security.sxw diff --git a/xmlsecurity/inc/documentsignaturemanager.hxx b/xmlsecurity/inc/documentsignaturemanager.hxx index eed54a5a32c7..f354ad8c8cbb 100644 --- a/xmlsecurity/inc/documentsignaturemanager.hxx +++ b/xmlsecurity/inc/documentsignaturemanager.hxx @@ -62,7 +62,7 @@ public: SignatureStreamHelper ImplOpenSignatureStream(sal_Int32 eStreamMode, bool bTempStream); /// Add a new signature, using xCert as a signing certificate, and rDescription as description. bool add(const css::uno::Reference& xCert, - const css::uno::Reference xSecurityContext, + const css::uno::Reference& xSecurityContext, const OUString& rDescription, sal_Int32& nSecurityId, bool bAdESCompliant); /// Remove signature at nPosition. void remove(sal_uInt16 nPosition); diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx index a9fbe930b30d..f52b65dc9917 100644 --- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx +++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx @@ -675,7 +675,7 @@ uno::Reference DigitalSignaturesDialog::getCertificate(c return xCert; } -uno::Reference DigitalSignaturesDialog::getSecurityEnvironmentForCertificate(uno::Reference xCert) +uno::Reference DigitalSignaturesDialog::getSecurityEnvironmentForCertificate(const uno::Reference& xCert) { if (xCert->getCertificateKind() == CertificateKind_OPENPGP) return maSignatureManager.getGpgSecurityEnvironment(); diff --git a/xmlsecurity/source/gpg/SecurityEnvironment.cxx b/xmlsecurity/source/gpg/SecurityEnvironment.cxx index 2b8a2d567afd..9892ec6ac5c8 100644 --- a/xmlsecurity/source/gpg/SecurityEnvironment.cxx +++ b/xmlsecurity/source/gpg/SecurityEnvironment.cxx @@ -93,7 +93,6 @@ Sequence< Reference < XCertificate > > SecurityEnvironmentGpg::getPersonalCertif Reference< XCertificate > SecurityEnvironmentGpg::getCertificate( const OUString& issuerName, const Sequence< sal_Int8 >& /*serialNumber*/ ) { CertificateImpl* xCert=nullptr; -std::list< CertificateImpl* > certsList; m_ctx->setKeyListMode(GPGME_KEYLIST_MODE_LOCAL); OString ostr = OUStringToOString( issuerName , RTL_TEXTENCODING_UTF8 ); diff --git a/xmlsecurity/source/helper/documentsignaturemanager.cxx b/xmlsecurity/source/helper/documentsignaturemanager.cxx index ded3de8d9960..ee863e4c2530 100644 --- a/xmlsecurity/source/helper/documentsignaturemanager.cxx +++ b/xmlsecurity/source/helper/documentsignaturemanager.cxx @@ -41,7 +41,6 @@ #include using namespace css; -namespace cssu = com::sun::star::uno; DocumentSignatureManager::DocumentSignatureManager(const uno::Reference& xContext, DocumentSignatureMode eMode) : mxContext(xContext), @@ -254,7 +253,7 @@ SignatureStreamHelper DocumentSignatureManager::ImplOpenSignatureStream(sal_Int3 } bool DocumentSignatureManager::add(const uno::Reference& xCert, - const uno::Reference xSecurityContext, + const uno::Reference& xSecurityContext, const OUString& rDescriptio
[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - xmlsecurity/inc xmlsecurity/source xmlsecurity/uiconfig
xmlsecurity/inc/digitalsignaturesdialog.hxx|2 xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx | 47 ++ xmlsecurity/uiconfig/ui/digitalsignaturesdialog.ui | 77 ++--- 3 files changed, 78 insertions(+), 48 deletions(-) New commits: commit 093f469eeec48e66050127e48f4a73f5c211621c Author: Katarina Behrens Date: Tue Mar 14 13:25:37 2017 +0100 gpg4libre: add 'Start certificate manager' button Change-Id: Ief3239fd1b3ff1f4e2e95e4413aa9f707f3dfb50 Reviewed-on: https://gerrit.libreoffice.org/36689 Tested-by: Jenkins Reviewed-by: Thorsten Behrens (cherry picked from commit 28ae89f4655ee7d630f2400e3994c227dcf47f70) Reviewed-on: https://gerrit.libreoffice.org/38478 Reviewed-by: Christian Lohmaier diff --git a/xmlsecurity/inc/digitalsignaturesdialog.hxx b/xmlsecurity/inc/digitalsignaturesdialog.hxx index 4c3c6de7e951..44cf85da7d50 100644 --- a/xmlsecurity/inc/digitalsignaturesdialog.hxx +++ b/xmlsecurity/inc/digitalsignaturesdialog.hxx @@ -75,6 +75,7 @@ private: VclPtr m_pViewBtn; VclPtr m_pAddBtn; VclPtr m_pRemoveBtn; +VclPtr m_pStartCertMgrBtn; VclPtrm_pCloseBtn; @@ -94,6 +95,7 @@ private: DECL_LINK(SignatureSelectHdl, SvTreeListBox*, bool ); DECL_LINK(StartVerifySignatureHdl, LinkParamNone*, bool ); DECL_LINK(OKButtonHdl, Button*, void ); +DECL_STATIC_LINK(DigitalSignaturesDialog, CertMgrButtonHdl, Button*, void ); voidImplGetSignatureInformations(bool bUseTempStream, bool bCacheLastSignature); voidImplFillSignaturesBox(); diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx index b88dd97337f8..f691ab063157 100644 --- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx +++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx @@ -35,8 +35,11 @@ #include #include #include +#include +#include +#include - +#include #include #include @@ -119,6 +122,7 @@ DigitalSignaturesDialog::DigitalSignaturesDialog( get(m_pAddBtn, "sign"); get(m_pRemoveBtn, "remove"); get(m_pCloseBtn, "close"); +get(m_pStartCertMgrBtn, "start_certmanager"); get(m_pSigsValidImg, "validimg"); get(m_pSigsValidFI, "validft"); get(m_pSigsInvalidImg, "invalidimg"); @@ -165,6 +169,8 @@ DigitalSignaturesDialog::DigitalSignaturesDialog( m_pRemoveBtn->SetClickHdl( LINK( this, DigitalSignaturesDialog, RemoveButtonHdl ) ); m_pRemoveBtn->Disable(); +m_pStartCertMgrBtn->SetClickHdl( LINK( this, DigitalSignaturesDialog, CertMgrButtonHdl ) ); + m_pCloseBtn->SetClickHdl( LINK( this, DigitalSignaturesDialog, OKButtonHdl) ); switch( maSignatureManager.meSignatureMode ) @@ -205,6 +211,7 @@ void DigitalSignaturesDialog::dispose() m_pAddBtn.clear(); m_pRemoveBtn.clear(); m_pCloseBtn.clear(); +m_pStartCertMgrBtn.clear(); ModalDialog::dispose(); } @@ -445,6 +452,44 @@ IMPL_LINK_NOARG(DigitalSignaturesDialog, RemoveButtonHdl, Button*, void) } } +IMPL_STATIC_LINK_NOARG(DigitalSignaturesDialog, CertMgrButtonHdl, Button*, void) +{ +const OUString aGUIServers[] = { OUString("kleopatra"), OUString("gpa"), OUString("kgpg") }; +// FIXME: the same for Windows + registry search for gpg4win +const char* cPath = getenv("PATH"); + +if (cPath) +{ + OUString aPath(cPath, strlen(cPath), osl_getThreadTextEncoding()); + OUString sFoundGUIServer, sExecutable; + + for ( auto const &rServer : aGUIServers ) + { + osl::FileBase::RC searchError = osl::File::searchFileURL(rServer, aPath, sFoundGUIServer ); + if (searchError == osl::FileBase::E_None) + { + osl::File::getSystemPathFromFileURL( sFoundGUIServer, sExecutable ); + break; + } + + } + + if ( !sExecutable.isEmpty() ) + { + uno::Reference< uno::XComponentContext > xContext = + ::comphelper::getProcessComponentContext(); + uno::Reference< css::system::XSystemShellExecute > xSystemShell( +css::system::SystemShellExecute::create(xContext) ); + + xSystemShell->execute( sExecutable, OUString(), + css::system::SystemShellExecuteFlags::DEFAULTS ); + } + //else FIXME: none of the certificate managers' there + +} + +} + IMPL_LINK_NOARG(DigitalSignaturesDialog, StartVerifySignatureHdl, LinkParamNone*, bool) { return mbVerifySignatures; diff --git a/xmlsecurity/uiconfig/ui/digitalsignaturesdialog.ui b/xmlsecurity/uiconfig/ui/digitalsignaturesdialog.ui index 31bec8316eb3..487bebdf8764 100644 --- a/xmlsecurity/uiconfig/ui/digitalsignaturesdialog.ui +++ b/xmlsecurity/uiconfig/ui/digitalsignaturesdialog.ui @@ -1,6 +1,8 @@ + - + + False 6 @@ -65,14 +67,12 @@