From 786f730ea2608abaafdc656e2181d11e076b6648 Mon Sep 17 00:00:00 2001 From: Gökçen Eraslan Date: Sat, 7 Jul 2012 19:08:48 +0300 Subject: Add new chooseCertificate method to XDocumentDigitalSignatures UNO interface. This method shows the certificate choosing dialog previously used in ODF signing and returns the selected certificate. For PDF signing support, we need to reuse existing CertifacateChooser class of xmlsecurity module. So the UNO api of ::com::sun::star::security::XDocumentDigitalSignatures is extended. Change-Id: I09f7d0ee180b16b588798820206780df359d133e --- .../star/security/XDocumentDigitalSignatures.idl | 4 +++- .../source/component/documentdigitalsignatures.cxx | 23 ++++++++++++++++++++++ .../source/component/documentdigitalsignatures.hxx | 1 + 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/offapi/com/sun/star/security/XDocumentDigitalSignatures.idl b/offapi/com/sun/star/security/XDocumentDigitalSignatures.idl index be75dc1dee3d..8e9089e75495 100644 --- a/offapi/com/sun/star/security/XDocumentDigitalSignatures.idl +++ b/offapi/com/sun/star/security/XDocumentDigitalSignatures.idl @@ -143,7 +143,9 @@ interface XDocumentDigitalSignatures : com::sun::star::uno::XInterface void addAuthorToTrustedSources( [in] com::sun::star::security::XCertificate Author ); void addLocationToTrustedSources( [in] string Location ); - + /** This method shows CertificateChooser dialog, used by document and PDF signing + */ + com::sun::star::security::XCertificate chooseCertificate(); } ; diff --git a/xmlsecurity/source/component/documentdigitalsignatures.cxx b/xmlsecurity/source/component/documentdigitalsignatures.cxx index 3282dfede4d3..f52c1a4411d0 100644 --- a/xmlsecurity/source/component/documentdigitalsignatures.cxx +++ b/xmlsecurity/source/component/documentdigitalsignatures.cxx @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -424,6 +425,28 @@ void DocumentDigitalSignatures::showCertificate( return bFound; } +Reference< css::security::XCertificate > DocumentDigitalSignatures::chooseCertificate() throw (RuntimeException) +{ + Reference< dcss::xml::crypto::XSecurityEnvironment > xSecEnv; + + XMLSignatureHelper aSignatureHelper( mxCtx ); + if ( aSignatureHelper.Init() ) + xSecEnv = aSignatureHelper.GetSecurityEnvironment(); + + CertificateChooser aChooser( NULL, mxCtx, xSecEnv, aSignatureHelper.GetSignatureInformations()); + + if (aChooser.Execute() != RET_OK) + return Reference< css::security::XCertificate >(0); + + Reference< css::security::XCertificate > xCert = aChooser.GetSelectedCertificate(); + + if ( !xCert.is() ) + return Reference< css::security::XCertificate >(0); + + return xCert; +} + + ::sal_Bool DocumentDigitalSignatures::isLocationTrusted( const ::rtl::OUString& Location ) throw (RuntimeException) { sal_Bool bFound = sal_False; diff --git a/xmlsecurity/source/component/documentdigitalsignatures.hxx b/xmlsecurity/source/component/documentdigitalsignatures.hxx index 3525370d10b5..a16ee9a5c6b5 100644 --- a/xmlsecurity/source/component/documentdigitalsignatures.hxx +++ b/xmlsecurity/source/component/documentdigitalsignatures.hxx @@ -94,6 +94,7 @@ public: void SAL_CALL addAuthorToTrustedSources( const ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificate >& Author ) throw (::com::sun::star::uno::RuntimeException); void SAL_CALL addLocationToTrustedSources( const ::rtl::OUString& Location ) throw (::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificate > SAL_CALL chooseCertificate( ) throw (::com::sun::star::uno::RuntimeException); }; com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL DocumentDigitalSignatures_CreateInstance( -- cgit v1.2.3