diff options
author | Malte Timmermann <mt@openoffice.org> | 2004-07-26 14:45:15 +0000 |
---|---|---|
committer | Malte Timmermann <mt@openoffice.org> | 2004-07-26 14:45:15 +0000 |
commit | e732866dd73615e5f582fa637b6c884e99980732 (patch) | |
tree | 63a366c8a935b758c8ea242b8bcda24c2a26838b /xmlsecurity/source | |
parent | 0295f68c9dadd9e01e383f3d7d1975022c643e8f (diff) |
#i21596# Digital Signatures...
Diffstat (limited to 'xmlsecurity/source')
-rw-r--r-- | xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx | 23 | ||||
-rw-r--r-- | xmlsecurity/source/helper/xmlsignaturehelper.cxx | 9 | ||||
-rw-r--r-- | xmlsecurity/source/helper/xmlsignaturehelper2.cxx | 15 |
3 files changed, 41 insertions, 6 deletions
diff --git a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx index 99a9b449f4c3..9d8d512930a3 100644 --- a/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx +++ b/xmlsecurity/source/dialogs/digitalsignaturesdialog.cxx @@ -2,9 +2,9 @@ * * $RCSfile: digitalsignaturesdialog.cxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: mt $ $Date: 2004-07-26 07:29:31 $ + * last change: $Author: mt $ $Date: 2004-07-26 15:45:14 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -76,6 +76,10 @@ #include <com/sun/star/security/NoPasswordException.hpp> #include <com/sun/star/lang/DisposedException.hpp> +#ifndef _COM_SUN_STAR_PACKAGES_WRONGPASSWORDEXCEPTION_HPP_ +#include <com/sun/star/packages/WrongPasswordException.hpp> +#endif + #include <tools/intn.hxx> #include <tools/date.hxx> #include <tools/time.hxx> @@ -234,12 +238,27 @@ IMPL_LINK( DigitalSignaturesDialog, AddButtonHdl, Button*, EMPTYARG ) for ( sal_Int32 n = 0; n < nElements; n++ ) { bool bBinaryMode = true; + bool bEncrypted = false; sal_Int32 nSep = aElements[n].lastIndexOf( '.' ); if ( nSep != (-1) ) { ::rtl::OUString aExt = aElements[n].copy( nSep+1 ); if ( aExt.equalsIgnoreAsciiCase( aXMLExt ) ) + { bBinaryMode = false; + // if it's encrypted, we will get a packages::WrongPasswordException and must use binary mode. + try + { + maSignatureHelper.GetUriBinding()->getUriBinding( aElements[n] ); + } + catch (packages::WrongPasswordException) + { + bBinaryMode = true; + // opening encrypted stream soesn't work, so don't sign ecncrypted docs in EA + DBG_ERROR( "Can't open encrypted streams..." ); + return -1; + } + } } maSignatureHelper.AddForSigning( nSecurityId, aElements[n], aElements[n], bBinaryMode ); } diff --git a/xmlsecurity/source/helper/xmlsignaturehelper.cxx b/xmlsecurity/source/helper/xmlsignaturehelper.cxx index 05045768594b..7e44191bf0a4 100644 --- a/xmlsecurity/source/helper/xmlsignaturehelper.cxx +++ b/xmlsecurity/source/helper/xmlsignaturehelper.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmlsignaturehelper.cxx,v $ * - * $Revision: 1.15 $ + * $Revision: 1.16 $ * - * last change: $Author: mmi $ $Date: 2004-07-23 03:00:41 $ + * last change: $Author: mt $ $Date: 2004-07-26 15:45:14 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -182,6 +182,11 @@ void XMLSignatureHelper::SetUriBinding( com::sun::star::uno::Reference< com::sun mxUriBinding = rxUriBinding; } +com::sun::star::uno::Reference< com::sun::star::xml::crypto::XUriBinding > XMLSignatureHelper::GetUriBinding() const +{ + return mxUriBinding; +} + void XMLSignatureHelper::SetStorage( const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >& rxStorage ) { DBG_ASSERT( !mxUriBinding.is(), "SetStorage - UriBinding already set!" ); diff --git a/xmlsecurity/source/helper/xmlsignaturehelper2.cxx b/xmlsecurity/source/helper/xmlsignaturehelper2.cxx index 883653b68df0..163001e29cb0 100644 --- a/xmlsecurity/source/helper/xmlsignaturehelper2.cxx +++ b/xmlsecurity/source/helper/xmlsignaturehelper2.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmlsignaturehelper2.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: mt $ $Date: 2004-07-16 15:58:49 $ + * last change: $Author: mt $ $Date: 2004-07-26 15:45:15 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -230,6 +230,17 @@ uno::Reference < io::XStream > UriBindingHelper::OpenInputStream( uno::Reference // Cloning because of I can't keep all storage references open // MBA with think about a better API... xStream = rxStore->cloneStreamElement( rURI ); + // Doesnt work, so better for EA to pass exception and not to sign the doc... + /* + try + { + xStream = rxStore->cloneStreamElement( rURI ); + } + catch (packages::WrongPasswordException) + { + xStream = rxStore->cloneEncryptedStreamElement( rURI, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DUMMY")) ); + } + */ } else { |