diff options
author | Gökçen Eraslan <gokcen.eraslan@gmail.com> | 2012-07-07 19:08:48 +0300 |
---|---|---|
committer | Gökçen Eraslan <gokcen.eraslan@gmail.com> | 2012-07-07 19:08:48 +0300 |
commit | 786f730ea2608abaafdc656e2181d11e076b6648 (patch) | |
tree | ed3b30ce0e9ce3ec123621bf413f63417c31661b | |
parent | 64f614d93e0ff2b719e8dd360c0ed684569439bc (diff) |
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
3 files changed, 27 insertions, 1 deletions
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 | |||
143 | void addAuthorToTrustedSources( [in] com::sun::star::security::XCertificate Author ); | 143 | void addAuthorToTrustedSources( [in] com::sun::star::security::XCertificate Author ); |
144 | void addLocationToTrustedSources( [in] string Location ); | 144 | void addLocationToTrustedSources( [in] string Location ); |
145 | 145 | ||
146 | 146 | /** This method shows CertificateChooser dialog, used by document and PDF signing | |
147 | */ | ||
148 | com::sun::star::security::XCertificate chooseCertificate(); | ||
147 | 149 | ||
148 | } ; | 150 | } ; |
149 | 151 | ||
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 @@ | |||
28 | 28 | ||
29 | #include <documentdigitalsignatures.hxx> | 29 | #include <documentdigitalsignatures.hxx> |
30 | #include <xmlsecurity/digitalsignaturesdialog.hxx> | 30 | #include <xmlsecurity/digitalsignaturesdialog.hxx> |
31 | #include <xmlsecurity/certificatechooser.hxx> | ||
31 | #include <xmlsecurity/certificateviewer.hxx> | 32 | #include <xmlsecurity/certificateviewer.hxx> |
32 | #include <xmlsecurity/macrosecurity.hxx> | 33 | #include <xmlsecurity/macrosecurity.hxx> |
33 | #include <xmlsecurity/biginteger.hxx> | 34 | #include <xmlsecurity/biginteger.hxx> |
@@ -424,6 +425,28 @@ void DocumentDigitalSignatures::showCertificate( | |||
424 | return bFound; | 425 | return bFound; |
425 | } | 426 | } |
426 | 427 | ||
428 | Reference< css::security::XCertificate > DocumentDigitalSignatures::chooseCertificate() throw (RuntimeException) | ||
429 | { | ||
430 | Reference< dcss::xml::crypto::XSecurityEnvironment > xSecEnv; | ||
431 | |||
432 | XMLSignatureHelper aSignatureHelper( mxCtx ); | ||
433 | if ( aSignatureHelper.Init() ) | ||
434 | xSecEnv = aSignatureHelper.GetSecurityEnvironment(); | ||
435 | |||
436 | CertificateChooser aChooser( NULL, mxCtx, xSecEnv, aSignatureHelper.GetSignatureInformations()); | ||
437 | |||
438 | if (aChooser.Execute() != RET_OK) | ||
439 | return Reference< css::security::XCertificate >(0); | ||
440 | |||
441 | Reference< css::security::XCertificate > xCert = aChooser.GetSelectedCertificate(); | ||
442 | |||
443 | if ( !xCert.is() ) | ||
444 | return Reference< css::security::XCertificate >(0); | ||
445 | |||
446 | return xCert; | ||
447 | } | ||
448 | |||
449 | |||
427 | ::sal_Bool DocumentDigitalSignatures::isLocationTrusted( const ::rtl::OUString& Location ) throw (RuntimeException) | 450 | ::sal_Bool DocumentDigitalSignatures::isLocationTrusted( const ::rtl::OUString& Location ) throw (RuntimeException) |
428 | { | 451 | { |
429 | sal_Bool bFound = sal_False; | 452 | 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: | |||
94 | void SAL_CALL addAuthorToTrustedSources( const ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificate >& Author ) throw (::com::sun::star::uno::RuntimeException); | 94 | void SAL_CALL addAuthorToTrustedSources( const ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificate >& Author ) throw (::com::sun::star::uno::RuntimeException); |
95 | void SAL_CALL addLocationToTrustedSources( const ::rtl::OUString& Location ) throw (::com::sun::star::uno::RuntimeException); | 95 | void SAL_CALL addLocationToTrustedSources( const ::rtl::OUString& Location ) throw (::com::sun::star::uno::RuntimeException); |
96 | 96 | ||
97 | ::com::sun::star::uno::Reference< ::com::sun::star::security::XCertificate > SAL_CALL chooseCertificate( ) throw (::com::sun::star::uno::RuntimeException); | ||
97 | }; | 98 | }; |
98 | 99 | ||
99 | com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL DocumentDigitalSignatures_CreateInstance( | 100 | com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL DocumentDigitalSignatures_CreateInstance( |