diff options
author | Mathias Bauer <mba@openoffice.org> | 2009-10-06 07:38:24 +0200 |
---|---|---|
committer | Mathias Bauer <mba@openoffice.org> | 2009-10-06 07:38:24 +0200 |
commit | 52cd4cc8ffbe5870b6415b1a29afc45b40b1f307 (patch) | |
tree | 7431ac560dddc37c0321c07fbebbda1f0eff5165 /xmlsecurity/source/component | |
parent | d88a241861a06e13916865b19e2e03040ee208b0 (diff) |
#103496#: move VCL free ConfigItems to unotools
Diffstat (limited to 'xmlsecurity/source/component')
-rw-r--r-- | xmlsecurity/source/component/documentdigitalsignatures.cxx | 112 |
1 files changed, 56 insertions, 56 deletions
diff --git a/xmlsecurity/source/component/documentdigitalsignatures.cxx b/xmlsecurity/source/component/documentdigitalsignatures.cxx index ba73b5e32..29c9ad970 100644 --- a/xmlsecurity/source/component/documentdigitalsignatures.cxx +++ b/xmlsecurity/source/component/documentdigitalsignatures.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -53,7 +53,7 @@ #include <com/sun/star/ucb/Command.hpp> #include <tools/urlobj.hxx> #include <vcl/msgbox.hxx> -#include <svtools/securityoptions.hxx> +#include <unotools/securityoptions.hxx> #include <com/sun/star/security/CertificateValidity.hpp> #include <com/sun/star/security/SerialNumberAdapter.hpp> #include <ucbhelper/contentbroker.hxx> @@ -74,13 +74,13 @@ namespace css = ::com::sun::star; DocumentDigitalSignatures::DocumentDigitalSignatures( const Reference< XComponentContext >& rxCtx ): mxCtx(rxCtx), - m_sODFVersion(ODFVER_012_TEXT), + m_sODFVersion(ODFVER_012_TEXT), m_nArgumentsCount(0), m_bHasDocumentSignature(false) { } -void DocumentDigitalSignatures::initialize( const Sequence< Any >& aArguments) +void DocumentDigitalSignatures::initialize( const Sequence< Any >& aArguments) throw (css::uno::Exception, css::uno::RuntimeException) { if (aArguments.getLength() == 0 || aArguments.getLength() > 2) @@ -101,47 +101,47 @@ void DocumentDigitalSignatures::initialize( const Sequence< Any >& aArguments) OUSTR("DocumentDigitalSignatures::initialize: the second arguments must be a bool"), Reference<XInterface>(static_cast<XInitialization*>(this), UNO_QUERY), 1); - //the Version is supported as of ODF1.2, so for and 1.1 document or older we will receive the + //the Version is supported as of ODF1.2, so for and 1.1 document or older we will receive the //an empty string. In this case we set it to ODFVER_010_TEXT. Then we can later check easily //if initialize was called. Only then m_sODFVersion.getLength() is greater than 0 if (m_sODFVersion.getLength() == 0) m_sODFVersion = ODFVER_010_TEXT; } -sal_Bool DocumentDigitalSignatures::signDocumentContent( - const Reference< css::embed::XStorage >& rxStorage, - const Reference< css::io::XStream >& xSignStream) +sal_Bool DocumentDigitalSignatures::signDocumentContent( + const Reference< css::embed::XStorage >& rxStorage, + const Reference< css::io::XStream >& xSignStream) throw (RuntimeException) { OSL_ENSURE(m_sODFVersion.getLength(), "DocumentDigitalSignatures: ODF Version not set, assuming minimum 1.2"); return ImplViewSignatures( rxStorage, xSignStream, SignatureModeDocumentContent, false ); } -Sequence< css::security::DocumentSignatureInformation > -DocumentDigitalSignatures::verifyDocumentContentSignatures( - const Reference< css::embed::XStorage >& rxStorage, +Sequence< css::security::DocumentSignatureInformation > +DocumentDigitalSignatures::verifyDocumentContentSignatures( + const Reference< css::embed::XStorage >& rxStorage, const Reference< css::io::XInputStream >& xSignInStream ) throw (RuntimeException) { OSL_ENSURE(m_sODFVersion.getLength(),"DocumentDigitalSignatures: ODF Version not set, assuming minimum 1.2"); return ImplVerifySignatures( rxStorage, xSignInStream, SignatureModeDocumentContent ); } -void DocumentDigitalSignatures::showDocumentContentSignatures( - const Reference< css::embed::XStorage >& rxStorage, +void DocumentDigitalSignatures::showDocumentContentSignatures( + const Reference< css::embed::XStorage >& rxStorage, const Reference< css::io::XInputStream >& xSignInStream ) throw (RuntimeException) { OSL_ENSURE(m_sODFVersion.getLength(),"DocumentDigitalSignatures: ODF Version not set, assuming minimum 1.2"); ImplViewSignatures( rxStorage, xSignInStream, SignatureModeDocumentContent, true ); } -::rtl::OUString DocumentDigitalSignatures::getDocumentContentSignatureDefaultStreamName() +::rtl::OUString DocumentDigitalSignatures::getDocumentContentSignatureDefaultStreamName() throw (css::uno::RuntimeException) { return DocumentSignatureHelper::GetDocumentContentSignatureDefaultStreamName(); } -sal_Bool DocumentDigitalSignatures::signScriptingContent( - const Reference< css::embed::XStorage >& rxStorage, +sal_Bool DocumentDigitalSignatures::signScriptingContent( + const Reference< css::embed::XStorage >& rxStorage, const Reference< css::io::XStream >& xSignStream ) throw (RuntimeException) { OSL_ENSURE(m_sODFVersion.getLength(),"DocumentDigitalSignatures: ODF Version not set, assuming minimum 1.2"); @@ -149,65 +149,65 @@ sal_Bool DocumentDigitalSignatures::signScriptingContent( return ImplViewSignatures( rxStorage, xSignStream, SignatureModeMacros, false ); } -Sequence< css::security::DocumentSignatureInformation > -DocumentDigitalSignatures::verifyScriptingContentSignatures( - const Reference< css::embed::XStorage >& rxStorage, +Sequence< css::security::DocumentSignatureInformation > +DocumentDigitalSignatures::verifyScriptingContentSignatures( + const Reference< css::embed::XStorage >& rxStorage, const Reference< css::io::XInputStream >& xSignInStream ) throw (RuntimeException) { OSL_ENSURE(m_sODFVersion.getLength(),"DocumentDigitalSignatures: ODF Version not set, assuming minimum 1.2"); return ImplVerifySignatures( rxStorage, xSignInStream, SignatureModeMacros ); } -void DocumentDigitalSignatures::showScriptingContentSignatures( - const Reference< css::embed::XStorage >& rxStorage, +void DocumentDigitalSignatures::showScriptingContentSignatures( + const Reference< css::embed::XStorage >& rxStorage, const Reference< css::io::XInputStream >& xSignInStream ) throw (RuntimeException) { OSL_ENSURE(m_sODFVersion.getLength(),"DocumentDigitalSignatures: ODF Version not set, assuming minimum 1.2"); ImplViewSignatures( rxStorage, xSignInStream, SignatureModeMacros, true ); } -::rtl::OUString DocumentDigitalSignatures::getScriptingContentSignatureDefaultStreamName() +::rtl::OUString DocumentDigitalSignatures::getScriptingContentSignatureDefaultStreamName() throw (css::uno::RuntimeException) { return DocumentSignatureHelper::GetScriptingContentSignatureDefaultStreamName(); } -sal_Bool DocumentDigitalSignatures::signPackage( - const Reference< css::embed::XStorage >& rxStorage, +sal_Bool DocumentDigitalSignatures::signPackage( + const Reference< css::embed::XStorage >& rxStorage, const Reference< css::io::XStream >& xSignStream ) throw (RuntimeException) { OSL_ENSURE(m_sODFVersion.getLength(),"DocumentDigitalSignatures: ODF Version not set, assuming minimum 1.2"); return ImplViewSignatures( rxStorage, xSignStream, SignatureModePackage, false ); } -Sequence< css::security::DocumentSignatureInformation > -DocumentDigitalSignatures::verifyPackageSignatures( - const Reference< css::embed::XStorage >& rxStorage, +Sequence< css::security::DocumentSignatureInformation > +DocumentDigitalSignatures::verifyPackageSignatures( + const Reference< css::embed::XStorage >& rxStorage, const Reference< css::io::XInputStream >& xSignInStream ) throw (RuntimeException) { OSL_ENSURE(m_sODFVersion.getLength(),"DocumentDigitalSignatures: ODF Version not set, assuming minimum 1.2"); return ImplVerifySignatures( rxStorage, xSignInStream, SignatureModePackage ); } -void DocumentDigitalSignatures::showPackageSignatures( - const Reference< css::embed::XStorage >& rxStorage, +void DocumentDigitalSignatures::showPackageSignatures( + const Reference< css::embed::XStorage >& rxStorage, const Reference< css::io::XInputStream >& xSignInStream ) throw (RuntimeException) { OSL_ENSURE(m_sODFVersion.getLength(),"DocumentDigitalSignatures: ODF Version not set, assuming minimum 1.2"); ImplViewSignatures( rxStorage, xSignInStream, SignatureModePackage, true ); } -::rtl::OUString DocumentDigitalSignatures::getPackageSignatureDefaultStreamName( ) +::rtl::OUString DocumentDigitalSignatures::getPackageSignatureDefaultStreamName( ) throw (::com::sun::star::uno::RuntimeException) { return DocumentSignatureHelper::GetPackageSignatureDefaultStreamName(); } -sal_Bool DocumentDigitalSignatures::ImplViewSignatures( - const Reference< css::embed::XStorage >& rxStorage, - const Reference< css::io::XInputStream >& xSignStream, +sal_Bool DocumentDigitalSignatures::ImplViewSignatures( + const Reference< css::embed::XStorage >& rxStorage, + const Reference< css::io::XInputStream >& xSignStream, DocumentSignatureMode eMode, bool bReadOnly ) throw (RuntimeException) { Reference< io::XStream > xStream; @@ -216,12 +216,12 @@ sal_Bool DocumentDigitalSignatures::ImplViewSignatures( return ImplViewSignatures( rxStorage, xStream, eMode, bReadOnly ); } -sal_Bool DocumentDigitalSignatures::ImplViewSignatures( - const Reference< css::embed::XStorage >& rxStorage, const Reference< css::io::XStream >& xSignStream, +sal_Bool DocumentDigitalSignatures::ImplViewSignatures( + const Reference< css::embed::XStorage >& rxStorage, const Reference< css::io::XStream >& xSignStream, DocumentSignatureMode eMode, bool bReadOnly ) throw (RuntimeException) { sal_Bool bChanges = sal_False; - DigitalSignaturesDialog aSignaturesDialog( + DigitalSignaturesDialog aSignaturesDialog( NULL, mxCtx, eMode, bReadOnly, m_sODFVersion, m_bHasDocumentSignature); bool bInit = aSignaturesDialog.Init( rtl::OUString() ); DBG_ASSERT( bInit, "Error initializing security context!" ); @@ -252,9 +252,9 @@ sal_Bool DocumentDigitalSignatures::ImplViewSignatures( return bChanges; } -Sequence< css::security::DocumentSignatureInformation > -DocumentDigitalSignatures::ImplVerifySignatures( - const Reference< css::embed::XStorage >& rxStorage, +Sequence< css::security::DocumentSignatureInformation > +DocumentDigitalSignatures::ImplVerifySignatures( + const Reference< css::embed::XStorage >& rxStorage, const Reference< css::io::XInputStream >& xSignStream, DocumentSignatureMode eMode ) throw (RuntimeException) { if (!rxStorage.is()) @@ -276,7 +276,7 @@ DocumentDigitalSignatures::ImplVerifySignatures( if ( !xInputStream.is() ) return Sequence< ::com::sun::star::security::DocumentSignatureInformation >(0); - + XMLSignatureHelper aSignatureHelper( mxCtx ); bool bInit = aSignatureHelper.Init( rtl::OUString() ); @@ -303,32 +303,32 @@ DocumentDigitalSignatures::ImplVerifySignatures( if ( nInfos ) { - Reference<security::XSerialNumberAdapter> xSerialNumberAdapter = + Reference<security::XSerialNumberAdapter> xSerialNumberAdapter = ::com::sun::star::security::SerialNumberAdapter::create(mxCtx); for( int n = 0; n < nInfos; ++n ) { DocumentSignatureAlgorithm mode = DocumentSignatureHelper::getDocumentAlgorithm( m_sODFVersion, aSignInfos[n]); - const std::vector< rtl::OUString > aElementsToBeVerified = - DocumentSignatureHelper::CreateElementList( + const std::vector< rtl::OUString > aElementsToBeVerified = + DocumentSignatureHelper::CreateElementList( rxStorage, ::rtl::OUString(), eMode, mode); const SignatureInformation& rInfo = aSignInfos[n]; css::security::DocumentSignatureInformation& rSigInfo = arInfos[n]; - + if (rInfo.ouX509Certificate.getLength()) rSigInfo.Signer = xSecEnv->createCertificateFromAscii( rInfo.ouX509Certificate ) ; if (!rSigInfo.Signer.is()) rSigInfo.Signer = xSecEnv->getCertificate( rInfo.ouX509IssuerName, xSerialNumberAdapter->toSequence( rInfo.ouX509SerialNumber ) ); - + // --> PB 2004-12-14 #i38744# time support again Date aDate( rInfo.stDateTime.Day, rInfo.stDateTime.Month, rInfo.stDateTime.Year ); Time aTime( rInfo.stDateTime.Hours, rInfo.stDateTime.Minutes, rInfo.stDateTime.Seconds, rInfo.stDateTime.HundredthSeconds ); rSigInfo.SignatureDate = aDate.GetDate(); rSigInfo.SignatureTime = aTime.GetTime(); - + // Verify certificate //We have patched our version of libxmlsec, so that it does not verify the certificates. This has two //reasons. First we want two separate status for signature and certificate. Second libxmlsec calls @@ -358,12 +358,12 @@ DocumentDigitalSignatures::ImplVerifySignatures( if ( rSigInfo.SignatureIsValid ) { - rSigInfo.SignatureIsValid = + rSigInfo.SignatureIsValid = DocumentSignatureHelper::checkIfAllFilesAreSigned( aElementsToBeVerified, rInfo, mode); } if (eMode == SignatureModeDocumentContent) - rSigInfo.PartialDocumentSignature = + rSigInfo.PartialDocumentSignature = ! DocumentSignatureHelper::isOOo3_2_Signature(aSignInfos[n]); } @@ -378,18 +378,18 @@ void DocumentDigitalSignatures::manageTrustedSources( ) throw (RuntimeException // SecEnv is only needed to display certificate information from trusted sources. // Macro Security also has some options where no security environment is needed, so raise dialog anyway. // Later I should change the code so the Dialog creates the SecEnv on demand... - + Reference< dcss::xml::crypto::XSecurityEnvironment > xSecEnv; XMLSignatureHelper aSignatureHelper( mxCtx ); if ( aSignatureHelper.Init( rtl::OUString() ) ) xSecEnv = aSignatureHelper.GetSecurityEnvironment(); - + MacroSecurity aDlg( NULL, mxCtx, xSecEnv ); aDlg.Execute(); } -void DocumentDigitalSignatures::showCertificate( +void DocumentDigitalSignatures::showCertificate( const Reference< css::security::XCertificate >& _Certificate ) throw (RuntimeException) { XMLSignatureHelper aSignatureHelper( mxCtx ); @@ -406,12 +406,12 @@ void DocumentDigitalSignatures::showCertificate( } -::sal_Bool DocumentDigitalSignatures::isAuthorTrusted( +::sal_Bool DocumentDigitalSignatures::isAuthorTrusted( const Reference< css::security::XCertificate >& Author ) throw (RuntimeException) { sal_Bool bFound = sal_False; - Reference<security::XSerialNumberAdapter> xSerialNumberAdapter = + Reference<security::XSerialNumberAdapter> xSerialNumberAdapter = ::com::sun::star::security::SerialNumberAdapter::create(mxCtx); ::rtl::OUString sSerialNum = xSerialNumberAdapter->toString( Author->getSerialNumber() ); @@ -450,7 +450,7 @@ void DocumentDigitalSignatures::showCertificate( if (pBroker) xContentProvider = pBroker->getContentProviderInterface(); } - + Sequence< ::rtl::OUString > aSecURLs = SvtSecurityOptions().GetSecureURLs(); const ::rtl::OUString* pSecURLs = aSecURLs.getConstArray(); const ::rtl::OUString* pSecURLsEnd = pSecURLs + aSecURLs.getLength(); @@ -460,12 +460,12 @@ void DocumentDigitalSignatures::showCertificate( return bFound; } -void DocumentDigitalSignatures::addAuthorToTrustedSources( +void DocumentDigitalSignatures::addAuthorToTrustedSources( const Reference< css::security::XCertificate >& Author ) throw (RuntimeException) { SvtSecurityOptions aSecOpts; - Reference<security::XSerialNumberAdapter> xSerialNumberAdapter = + Reference<security::XSerialNumberAdapter> xSerialNumberAdapter = ::com::sun::star::security::SerialNumberAdapter::create(mxCtx); SvtSecurityOptions::Certificate aNewCert( 3 ); |