summaryrefslogtreecommitdiff
path: root/sfx2/source
diff options
context:
space:
mode:
Diffstat (limited to 'sfx2/source')
-rw-r--r--sfx2/source/dialog/dinfdlg.cxx35
-rw-r--r--sfx2/source/doc/docfile.cxx168
-rw-r--r--sfx2/source/doc/docmacromode.cxx23
-rw-r--r--sfx2/source/doc/objmisc.cxx6
-rw-r--r--sfx2/source/doc/objserv.cxx9
-rw-r--r--sfx2/source/doc/objstor.cxx14
6 files changed, 116 insertions, 139 deletions
diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx
index a8cf492f7e5f..78dbfe341121 100644
--- a/sfx2/source/dialog/dinfdlg.cxx
+++ b/sfx2/source/dialog/dinfdlg.cxx
@@ -33,7 +33,7 @@
#include <comphelper/string.hxx>
#include <com/sun/star/security/DocumentSignatureInformation.hpp>
-#include <com/sun/star/security/XDocumentDigitalSignatures.hpp>
+#include <com/sun/star/security/DocumentDigitalSignatures.hpp>
#include <unotools/syslocale.hxx>
#include <rtl/math.hxx>
#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
@@ -938,26 +938,23 @@ void SfxDocumentPage::ImplUpdateSignatures()
if ( pMedium && !pMedium->GetName().isEmpty() && pMedium->GetStorage().is() )
{
Reference< security::XDocumentDigitalSignatures > xD(
- comphelper::getProcessServiceFactory()->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.security.DocumentDigitalSignatures" ) ) ), uno::UNO_QUERY );
-
- if ( xD.is() )
+ security::DocumentDigitalSignatures::createDefault(comphelper::getProcessComponentContext()) );
+
+ String s;
+ Sequence< security::DocumentSignatureInformation > aInfos;
+ aInfos = xD->verifyDocumentContentSignatures( pMedium->GetZipStorageToSign_Impl(),
+ uno::Reference< io::XInputStream >() );
+ if ( aInfos.getLength() > 1 )
+ s = aMultiSignedStr;
+ else if ( aInfos.getLength() == 1 )
{
- String s;
- Sequence< security::DocumentSignatureInformation > aInfos;
- aInfos = xD->verifyDocumentContentSignatures( pMedium->GetZipStorageToSign_Impl(),
- uno::Reference< io::XInputStream >() );
- if ( aInfos.getLength() > 1 )
- s = aMultiSignedStr;
- else if ( aInfos.getLength() == 1 )
- {
- rtl::OUString aCN_Id("CN");
- const security::DocumentSignatureInformation& rInfo = aInfos[ 0 ];
- s = GetDateTimeString( rInfo.SignatureDate, rInfo.SignatureTime );
- s.AppendAscii( ", " );
- s += GetContentPart( rInfo.Signer->getSubjectName(), aCN_Id );
- }
- aSignedValFt.SetText( s );
+ rtl::OUString aCN_Id("CN");
+ const security::DocumentSignatureInformation& rInfo = aInfos[ 0 ];
+ s = GetDateTimeString( rInfo.SignatureDate, rInfo.SignatureTime );
+ s.AppendAscii( ", " );
+ s += GetContentPart( rInfo.Signer->getSubjectName(), aCN_Id );
}
+ aSignedValFt.SetText( s );
}
}
}
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index 09966767cf86..1a8c61976cc3 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -62,7 +62,7 @@
#include <cppuhelper/implbase1.hxx>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/security/DocumentSignatureInformation.hpp>
-#include <com/sun/star/security/XDocumentDigitalSignatures.hpp>
+#include <com/sun/star/security/DocumentDigitalSignatures.hpp>
#include <tools/urlobj.hxx>
#include <unotools/tempfile.hxx>
#include <comphelper/processfactory.hxx>
@@ -3371,105 +3371,97 @@ sal_Bool SfxMedium::SignContents_Impl( sal_Bool bScriptingContent, const ::rtl::
{
// The component should know if there was a valid document signature, since
// it should show a warning in this case
- uno::Sequence< uno::Any > aArgs( 2 );
- aArgs[0] <<= aODFVersion;
- aArgs[1] <<= bHasValidDocumentSignature;
- ::com::sun::star::uno::Reference< ::com::sun::star::security::XDocumentDigitalSignatures > xSigner(
- comphelper::getProcessServiceFactory()->createInstanceWithArguments(
- rtl::OUString( "com.sun.star.security.DocumentDigitalSignatures" ),
- aArgs ),
- ::com::sun::star::uno::UNO_QUERY );
-
- if ( xSigner.is() )
- {
- uno::Reference< embed::XStorage > xWriteableZipStor;
- if ( !IsReadOnly() )
- {
- // we can reuse the temporary file if there is one already
- CreateTempFile( false );
- GetMedium_Impl();
+ uno::Reference< security::XDocumentDigitalSignatures > xSigner(
+ security::DocumentDigitalSignatures::createWithVersionAndValidSignature(
+ comphelper::getProcessComponentContext(), aODFVersion, bHasValidDocumentSignature ) );
- try
- {
- if ( !pImp->xStream.is() )
- throw uno::RuntimeException();
+ uno::Reference< embed::XStorage > xWriteableZipStor;
+ if ( !IsReadOnly() )
+ {
+ // we can reuse the temporary file if there is one already
+ CreateTempFile( false );
+ GetMedium_Impl();
- xWriteableZipStor = ::comphelper::OStorageHelper::GetStorageOfFormatFromStream( ZIP_STORAGE_FORMAT_STRING, pImp->xStream );
- if ( !xWriteableZipStor.is() )
- throw uno::RuntimeException();
+ try
+ {
+ if ( !pImp->xStream.is() )
+ throw uno::RuntimeException();
- uno::Reference< embed::XStorage > xMetaInf = xWriteableZipStor->openStorageElement(
- ::rtl::OUString( "META-INF" ),
- embed::ElementModes::READWRITE );
- if ( !xMetaInf.is() )
- throw uno::RuntimeException();
+ xWriteableZipStor = ::comphelper::OStorageHelper::GetStorageOfFormatFromStream( ZIP_STORAGE_FORMAT_STRING, pImp->xStream );
+ if ( !xWriteableZipStor.is() )
+ throw uno::RuntimeException();
- if ( bScriptingContent )
- {
- // If the signature has already the document signature it will be removed
- // after the scripting signature is inserted.
- uno::Reference< io::XStream > xStream(
- xMetaInf->openStreamElement( xSigner->getScriptingContentSignatureDefaultStreamName(),
- embed::ElementModes::READWRITE ),
- uno::UNO_SET_THROW );
-
- if ( xSigner->signScriptingContent( GetZipStorageToSign_Impl(), xStream ) )
- {
- // remove the document signature if any
- ::rtl::OUString aDocSigName = xSigner->getDocumentContentSignatureDefaultStreamName();
- if ( !aDocSigName.isEmpty() && xMetaInf->hasByName( aDocSigName ) )
- xMetaInf->removeElement( aDocSigName );
-
- uno::Reference< embed::XTransactedObject > xTransact( xMetaInf, uno::UNO_QUERY_THROW );
- xTransact->commit();
- xTransact.set( xWriteableZipStor, uno::UNO_QUERY_THROW );
- xTransact->commit();
-
- // the temporary file has been written, commit it to the original file
- Commit();
- bChanges = true;
- }
- }
- else
- {
- uno::Reference< io::XStream > xStream(
- xMetaInf->openStreamElement( xSigner->getDocumentContentSignatureDefaultStreamName(),
- embed::ElementModes::READWRITE ),
- uno::UNO_SET_THROW );
+ uno::Reference< embed::XStorage > xMetaInf = xWriteableZipStor->openStorageElement(
+ ::rtl::OUString( "META-INF" ),
+ embed::ElementModes::READWRITE );
+ if ( !xMetaInf.is() )
+ throw uno::RuntimeException();
- if ( xSigner->signDocumentContent( GetZipStorageToSign_Impl(), xStream ) )
- {
- uno::Reference< embed::XTransactedObject > xTransact( xMetaInf, uno::UNO_QUERY_THROW );
- xTransact->commit();
- xTransact.set( xWriteableZipStor, uno::UNO_QUERY_THROW );
- xTransact->commit();
-
- // the temporary file has been written, commit it to the original file
- Commit();
- bChanges = true;
- }
+ if ( bScriptingContent )
+ {
+ // If the signature has already the document signature it will be removed
+ // after the scripting signature is inserted.
+ uno::Reference< io::XStream > xStream(
+ xMetaInf->openStreamElement( xSigner->getScriptingContentSignatureDefaultStreamName(),
+ embed::ElementModes::READWRITE ),
+ uno::UNO_SET_THROW );
+
+ if ( xSigner->signScriptingContent( GetZipStorageToSign_Impl(), xStream ) )
+ {
+ // remove the document signature if any
+ ::rtl::OUString aDocSigName = xSigner->getDocumentContentSignatureDefaultStreamName();
+ if ( !aDocSigName.isEmpty() && xMetaInf->hasByName( aDocSigName ) )
+ xMetaInf->removeElement( aDocSigName );
+
+ uno::Reference< embed::XTransactedObject > xTransact( xMetaInf, uno::UNO_QUERY_THROW );
+ xTransact->commit();
+ xTransact.set( xWriteableZipStor, uno::UNO_QUERY_THROW );
+ xTransact->commit();
+
+ // the temporary file has been written, commit it to the original file
+ Commit();
+ bChanges = true;
}
}
- catch ( const uno::Exception& )
+ else
{
- OSL_FAIL( "Couldn't use signing functionality!\n" );
+ uno::Reference< io::XStream > xStream(
+ xMetaInf->openStreamElement( xSigner->getDocumentContentSignatureDefaultStreamName(),
+ embed::ElementModes::READWRITE ),
+ uno::UNO_SET_THROW );
+
+ if ( xSigner->signDocumentContent( GetZipStorageToSign_Impl(), xStream ) )
+ {
+ uno::Reference< embed::XTransactedObject > xTransact( xMetaInf, uno::UNO_QUERY_THROW );
+ xTransact->commit();
+ xTransact.set( xWriteableZipStor, uno::UNO_QUERY_THROW );
+ xTransact->commit();
+
+ // the temporary file has been written, commit it to the original file
+ Commit();
+ bChanges = true;
+ }
}
+ }
+ catch ( const uno::Exception& )
+ {
+ OSL_FAIL( "Couldn't use signing functionality!\n" );
+ }
- CloseAndRelease();
+ CloseAndRelease();
+ }
+ else
+ {
+ try
+ {
+ if ( bScriptingContent )
+ xSigner->showScriptingContentSignatures( GetZipStorageToSign_Impl(), uno::Reference< io::XInputStream >() );
+ else
+ xSigner->showDocumentContentSignatures( GetZipStorageToSign_Impl(), uno::Reference< io::XInputStream >() );
}
- else
+ catch( const uno::Exception& )
{
- try
- {
- if ( bScriptingContent )
- xSigner->showScriptingContentSignatures( GetZipStorageToSign_Impl(), uno::Reference< io::XInputStream >() );
- else
- xSigner->showDocumentContentSignatures( GetZipStorageToSign_Impl(), uno::Reference< io::XInputStream >() );
- }
- catch( const uno::Exception& )
- {
- OSL_FAIL( "Couldn't use signing functionality!\n" );
- }
+ OSL_FAIL( "Couldn't use signing functionality!\n" );
}
}
diff --git a/sfx2/source/doc/docmacromode.cxx b/sfx2/source/doc/docmacromode.cxx
index dc6395ef294a..47547569f58b 100644
--- a/sfx2/source/doc/docmacromode.cxx
+++ b/sfx2/source/doc/docmacromode.cxx
@@ -26,7 +26,7 @@
#include <com/sun/star/task/ErrorCodeRequest.hpp>
#include <com/sun/star/task/DocumentMacroConfirmationRequest.hpp>
#include <com/sun/star/task/InteractionClassification.hpp>
-#include <com/sun/star/security/XDocumentDigitalSignatures.hpp>
+#include <com/sun/star/security/DocumentDigitalSignatures.hpp>
#include <com/sun/star/script/XLibraryQueryExecutable.hpp>
#include <com/sun/star/script/vba/XVBACompatibility.hpp>
@@ -56,6 +56,7 @@ namespace sfx2
using ::com::sun::star::task::DocumentMacroConfirmationRequest;
using ::com::sun::star::task::ErrorCodeRequest;
using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::security::DocumentDigitalSignatures;
using ::com::sun::star::security::XDocumentDigitalSignatures;
using ::com::sun::star::security::DocumentSignatureInformation;
using ::com::sun::star::embed::XStorage;
@@ -224,20 +225,16 @@ namespace sfx2
// get document location from medium name and check whether it is a trusted one
// the service is created ohne document version, since it is not of interest here
- ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
- Reference< XDocumentDigitalSignatures > xSignatures;
- if ( aContext.createComponent( "com.sun.star.security.DocumentDigitalSignatures", xSignatures ) )
- {
- INetURLObject aURLReferer( sReferrer );
+ Reference< XDocumentDigitalSignatures > xSignatures(DocumentDigitalSignatures::createDefault(::comphelper::getProcessComponentContext()));
+ INetURLObject aURLReferer( sReferrer );
- ::rtl::OUString aLocation;
- if ( aURLReferer.removeSegment() )
- aLocation = aURLReferer.GetMainURL( INetURLObject::NO_DECODE );
+ ::rtl::OUString aLocation;
+ if ( aURLReferer.removeSegment() )
+ aLocation = aURLReferer.GetMainURL( INetURLObject::NO_DECODE );
- if ( !aLocation.isEmpty() && xSignatures->isLocationTrusted( aLocation ) )
- {
- return allowMacroExecution();
- }
+ if ( !aLocation.isEmpty() && xSignatures->isLocationTrusted( aLocation ) )
+ {
+ return allowMacroExecution();
}
// at this point it is clear that the document is not in the secure location
diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx
index 842d716c2be7..a30765346b15 100644
--- a/sfx2/source/doc/objmisc.cxx
+++ b/sfx2/source/doc/objmisc.cxx
@@ -67,7 +67,7 @@
#include <comphelper/processfactory.hxx>
#include <comphelper/string.hxx>
-#include <com/sun/star/security/XDocumentDigitalSignatures.hpp>
+#include <com/sun/star/security/DocumentDigitalSignatures.hpp>
#include <com/sun/star/task/DocumentMacroConfirmationRequest.hpp>
#include <com/sun/star/task/InteractionClassification.hpp>
#include <com/sun/star/frame/XModel.hpp>
@@ -1967,10 +1967,8 @@ sal_Bool SfxObjectShell_Impl::hasTrustedScriptingSignature( sal_Bool bAllowUIToA
catch( uno::Exception& )
{
}
- uno::Sequence< uno::Any > aArgs( 1 );
- aArgs[0] <<= aVersion;
- uno::Reference< security::XDocumentDigitalSignatures > xSigner( comphelper::getProcessServiceFactory()->createInstanceWithArguments( rtl::OUString( "com.sun.star.security.DocumentDigitalSignatures" ), aArgs ), uno::UNO_QUERY_THROW );
+ uno::Reference< security::XDocumentDigitalSignatures > xSigner( security::DocumentDigitalSignatures::createWithVersion(comphelper::getProcessComponentContext(), aVersion) );
if ( nScriptingSignatureState == SIGNATURESTATE_UNKNOWN
|| nScriptingSignatureState == SIGNATURESTATE_SIGNATURES_OK
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index 1bd9c9cd8a89..5046eca0c865 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -40,7 +40,7 @@
#include <com/sun/star/security/CertificateValidity.hpp>
#include <com/sun/star/security/DocumentSignatureInformation.hpp>
-#include <com/sun/star/security/XDocumentDigitalSignatures.hpp>
+#include <com/sun/star/security/DocumentDigitalSignatures.hpp>
#include <tools/urlobj.hxx>
#include <svl/whiter.hxx>
#include <vcl/msgbox.hxx>
@@ -1261,18 +1261,17 @@ uno::Sequence< security::DocumentSignatureInformation > SfxObjectShell::ImplAnal
{
if ( !xLocSigner.is() )
{
- uno::Sequence< uno::Any > aArgs( 1 );
- aArgs[0] <<= ::rtl::OUString();
+ ::rtl::OUString aVersion;
try
{
uno::Reference < beans::XPropertySet > xPropSet( GetStorage(), uno::UNO_QUERY_THROW );
- aArgs[0] = xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Version" ) ) );
+ xPropSet->getPropertyValue( ::rtl::OUString( "Version" ) ) >>= aVersion;
}
catch( uno::Exception& )
{
}
- xLocSigner.set( comphelper::getProcessServiceFactory()->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.security.DocumentDigitalSignatures" ) ), aArgs ), uno::UNO_QUERY_THROW );
+ xLocSigner.set( security::DocumentDigitalSignatures::createWithVersion(comphelper::getProcessComponentContext(), aVersion) );
}
diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx
index 64eadd5bb67e..0534f9c4547f 100644
--- a/sfx2/source/doc/objstor.cxx
+++ b/sfx2/source/doc/objstor.cxx
@@ -60,7 +60,7 @@
#include <com/sun/star/embed/XEncryptionProtectedStorage.hpp>
#include <com/sun/star/io/XTruncate.hpp>
#include <com/sun/star/util/XModifiable.hpp>
-#include <com/sun/star/security/XDocumentDigitalSignatures.hpp>
+#include <com/sun/star/security/DocumentDigitalSignatures.hpp>
#include <com/sun/star/xml/crypto/CipherID.hpp>
#include <com/sun/star/xml/crypto/DigestID.hpp>
@@ -1538,23 +1538,17 @@ sal_Bool SfxObjectShell::SaveTo_Impl
try
{
// get the ODF version of the new medium
- uno::Sequence< uno::Any > aArgs( 1 );
- aArgs[0] <<= ::rtl::OUString();
+ ::rtl::OUString aVersion;
try
{
uno::Reference < beans::XPropertySet > xPropSet( rMedium.GetStorage(), uno::UNO_QUERY_THROW );
- aArgs[0] = xPropSet->getPropertyValue( ::rtl::OUString( "Version" ) );
+ xPropSet->getPropertyValue( ::rtl::OUString( "Version" ) ) >>= aVersion;
}
catch( uno::Exception& )
{
}
- xDDSigns = uno::Reference< security::XDocumentDigitalSignatures >(
- comphelper::getProcessServiceFactory()->createInstanceWithArguments(
- rtl::OUString(
- "com.sun.star.security.DocumentDigitalSignatures" ),
- aArgs ),
- uno::UNO_QUERY_THROW );
+ xDDSigns = security::DocumentDigitalSignatures::createWithVersion(comphelper::getProcessComponentContext(), aVersion);
::rtl::OUString aScriptSignName = xDDSigns->getScriptingContentSignatureDefaultStreamName();