summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGökçen Eraslan <gokcen.eraslan@gmail.com>2012-07-07 16:08:48 (GMT)
committerGökçen Eraslan <gokcen.eraslan@gmail.com>2012-07-07 16:08:48 (GMT)
commit786f730ea2608abaafdc656e2181d11e076b6648 (patch)
treeed3b30ce0e9ce3ec123621bf413f63417c31661b
parent64f614d93e0ff2b719e8dd360c0ed684569439bc (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
-rw-r--r--offapi/com/sun/star/security/XDocumentDigitalSignatures.idl4
-rw-r--r--xmlsecurity/source/component/documentdigitalsignatures.cxx23
-rw-r--r--xmlsecurity/source/component/documentdigitalsignatures.hxx1
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 be75dc1..8e9089e 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 3282dfe..f52c1a4 100644
--- a/xmlsecurity/source/component/documentdigitalsignatures.cxx
+++ b/xmlsecurity/source/component/documentdigitalsignatures.cxx
@@ -28,6 +28,7 @@
#include <documentdigitalsignatures.hxx>
#include <xmlsecurity/digitalsignaturesdialog.hxx>
+#include <xmlsecurity/certificatechooser.hxx>
#include <xmlsecurity/certificateviewer.hxx>
#include <xmlsecurity/macrosecurity.hxx>
#include <xmlsecurity/biginteger.hxx>
@@ -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 3525370..a16ee9a 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(