Turn on clang-format for these files
I (tried to) keep these files consistent locally with astyle in the past, switching to clang-format makes sure that the recent problem with introducing inconsistencies with automatic loplugin rewrites doesn't happen again. Change-Id: If49c96b6e9e6ed50beb69c70e37125dff5607f76 Reviewed-on: https://gerrit.libreoffice.org/47332 Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org>
This commit is contained in:
@@ -15947,7 +15947,6 @@ sw/source/filter/ww8/docxexportfilter.cxx
|
|||||||
sw/source/filter/ww8/docxexportfilter.hxx
|
sw/source/filter/ww8/docxexportfilter.hxx
|
||||||
sw/source/filter/ww8/docxfootnotes.hxx
|
sw/source/filter/ww8/docxfootnotes.hxx
|
||||||
sw/source/filter/ww8/docxhelper.hxx
|
sw/source/filter/ww8/docxhelper.hxx
|
||||||
sw/source/filter/ww8/docxsdrexport.cxx
|
|
||||||
sw/source/filter/ww8/docxsdrexport.hxx
|
sw/source/filter/ww8/docxsdrexport.hxx
|
||||||
sw/source/filter/ww8/docxtablestyleexport.cxx
|
sw/source/filter/ww8/docxtablestyleexport.cxx
|
||||||
sw/source/filter/ww8/docxtablestyleexport.hxx
|
sw/source/filter/ww8/docxtablestyleexport.hxx
|
||||||
@@ -19710,7 +19709,6 @@ xmlsecurity/inc/certificatechooser.hxx
|
|||||||
xmlsecurity/inc/certificateviewer.hxx
|
xmlsecurity/inc/certificateviewer.hxx
|
||||||
xmlsecurity/inc/digitalsignaturesdialog.hxx
|
xmlsecurity/inc/digitalsignaturesdialog.hxx
|
||||||
xmlsecurity/inc/documentsignaturehelper.hxx
|
xmlsecurity/inc/documentsignaturehelper.hxx
|
||||||
xmlsecurity/inc/documentsignaturemanager.hxx
|
|
||||||
xmlsecurity/inc/framework/saxeventkeeperimpl.hxx
|
xmlsecurity/inc/framework/saxeventkeeperimpl.hxx
|
||||||
xmlsecurity/inc/framework/securityengine.hxx
|
xmlsecurity/inc/framework/securityengine.hxx
|
||||||
xmlsecurity/inc/framework/signaturecreatorimpl.hxx
|
xmlsecurity/inc/framework/signaturecreatorimpl.hxx
|
||||||
@@ -19729,7 +19727,6 @@ xmlsecurity/inc/pch/precompiled_xsec_gpg.hxx
|
|||||||
xmlsecurity/inc/pch/precompiled_xsec_xmlsec.cxx
|
xmlsecurity/inc/pch/precompiled_xsec_xmlsec.cxx
|
||||||
xmlsecurity/inc/pch/precompiled_xsec_xmlsec.hxx
|
xmlsecurity/inc/pch/precompiled_xsec_xmlsec.hxx
|
||||||
xmlsecurity/inc/pdfio/pdfdocument.hxx
|
xmlsecurity/inc/pdfio/pdfdocument.hxx
|
||||||
xmlsecurity/inc/pdfsignaturehelper.hxx
|
|
||||||
xmlsecurity/inc/resourcemanager.hxx
|
xmlsecurity/inc/resourcemanager.hxx
|
||||||
xmlsecurity/inc/xmlsec-wrapper.h
|
xmlsecurity/inc/xmlsec-wrapper.h
|
||||||
xmlsecurity/inc/xmlsec/errorcallback.hxx
|
xmlsecurity/inc/xmlsec/errorcallback.hxx
|
||||||
@@ -19787,12 +19784,10 @@ xmlsecurity/source/gpg/XMLSecurityContext.cxx
|
|||||||
xmlsecurity/source/gpg/XMLSecurityContext.hxx
|
xmlsecurity/source/gpg/XMLSecurityContext.hxx
|
||||||
xmlsecurity/source/gpg/xmlsignature_gpgimpl.cxx
|
xmlsecurity/source/gpg/xmlsignature_gpgimpl.cxx
|
||||||
xmlsecurity/source/helper/documentsignaturehelper.cxx
|
xmlsecurity/source/helper/documentsignaturehelper.cxx
|
||||||
xmlsecurity/source/helper/documentsignaturemanager.cxx
|
|
||||||
xmlsecurity/source/helper/ooxmlsecexporter.cxx
|
xmlsecurity/source/helper/ooxmlsecexporter.cxx
|
||||||
xmlsecurity/source/helper/ooxmlsecexporter.hxx
|
xmlsecurity/source/helper/ooxmlsecexporter.hxx
|
||||||
xmlsecurity/source/helper/ooxmlsecparser.cxx
|
xmlsecurity/source/helper/ooxmlsecparser.cxx
|
||||||
xmlsecurity/source/helper/ooxmlsecparser.hxx
|
xmlsecurity/source/helper/ooxmlsecparser.hxx
|
||||||
xmlsecurity/source/helper/pdfsignaturehelper.cxx
|
|
||||||
xmlsecurity/source/helper/xmlsignaturehelper.cxx
|
xmlsecurity/source/helper/xmlsignaturehelper.cxx
|
||||||
xmlsecurity/source/helper/xmlsignaturehelper2.cxx
|
xmlsecurity/source/helper/xmlsignaturehelper2.cxx
|
||||||
xmlsecurity/source/helper/xsecctl.cxx
|
xmlsecurity/source/helper/xsecctl.cxx
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -42,7 +42,7 @@ public:
|
|||||||
std::unique_ptr<PDFSignatureHelper> mpPDFSignatureHelper;
|
std::unique_ptr<PDFSignatureHelper> mpPDFSignatureHelper;
|
||||||
SignatureInformations maCurrentSignatureInformations;
|
SignatureInformations maCurrentSignatureInformations;
|
||||||
DocumentSignatureMode meSignatureMode;
|
DocumentSignatureMode meSignatureMode;
|
||||||
css::uno::Sequence< css::uno::Sequence<css::beans::PropertyValue> > m_manifest;
|
css::uno::Sequence<css::uno::Sequence<css::beans::PropertyValue>> m_manifest;
|
||||||
css::uno::Reference<css::io::XStream> mxSignatureStream;
|
css::uno::Reference<css::io::XStream> mxSignatureStream;
|
||||||
css::uno::Reference<css::io::XStream> mxTempSignatureStream;
|
css::uno::Reference<css::io::XStream> mxTempSignatureStream;
|
||||||
/// Storage containing all OOXML signatures, unused for ODF.
|
/// Storage containing all OOXML signatures, unused for ODF.
|
||||||
@@ -52,7 +52,8 @@ public:
|
|||||||
css::uno::Reference<css::xml::crypto::XSEInitializer> mxGpgSEInitializer;
|
css::uno::Reference<css::xml::crypto::XSEInitializer> mxGpgSEInitializer;
|
||||||
css::uno::Reference<css::xml::crypto::XXMLSecurityContext> mxGpgSecurityContext;
|
css::uno::Reference<css::xml::crypto::XXMLSecurityContext> mxGpgSecurityContext;
|
||||||
|
|
||||||
DocumentSignatureManager(const css::uno::Reference<css::uno::XComponentContext>& xContext, DocumentSignatureMode eMode);
|
DocumentSignatureManager(const css::uno::Reference<css::uno::XComponentContext>& xContext,
|
||||||
|
DocumentSignatureMode eMode);
|
||||||
~DocumentSignatureManager();
|
~DocumentSignatureManager();
|
||||||
/**
|
/**
|
||||||
* Checks if a particular stream is a valid xml stream. Those are treated
|
* Checks if a particular stream is a valid xml stream. Those are treated
|
||||||
@@ -81,8 +82,8 @@ public:
|
|||||||
/// Get the security environment.
|
/// Get the security environment.
|
||||||
css::uno::Reference<css::xml::crypto::XSecurityEnvironment> getSecurityEnvironment();
|
css::uno::Reference<css::xml::crypto::XSecurityEnvironment> getSecurityEnvironment();
|
||||||
css::uno::Reference<css::xml::crypto::XSecurityEnvironment> getGpgSecurityEnvironment();
|
css::uno::Reference<css::xml::crypto::XSecurityEnvironment> getGpgSecurityEnvironment();
|
||||||
css::uno::Reference<css::xml::crypto::XXMLSecurityContext> const & getSecurityContext();
|
css::uno::Reference<css::xml::crypto::XXMLSecurityContext> const& getSecurityContext();
|
||||||
css::uno::Reference<css::xml::crypto::XXMLSecurityContext> const & getGpgSecurityContext();
|
css::uno::Reference<css::xml::crypto::XXMLSecurityContext> const& getGpgSecurityContext();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INCLUDED_XMLSECURITY_INC_DOCUMENTSIGNATUREMANAGER_HXX
|
#endif // INCLUDED_XMLSECURITY_INC_DOCUMENTSIGNATUREMANAGER_HXX
|
||||||
|
@@ -32,8 +32,10 @@ class XMLSECURITY_DLLPUBLIC PDFSignatureHelper
|
|||||||
public:
|
public:
|
||||||
PDFSignatureHelper();
|
PDFSignatureHelper();
|
||||||
bool ReadAndVerifySignature(const css::uno::Reference<css::io::XInputStream>& xInputStream);
|
bool ReadAndVerifySignature(const css::uno::Reference<css::io::XInputStream>& xInputStream);
|
||||||
css::uno::Sequence<css::security::DocumentSignatureInformation> GetDocumentSignatureInformations(const css::uno::Reference<css::xml::crypto::XSecurityEnvironment>& xSecEnv) const;
|
css::uno::Sequence<css::security::DocumentSignatureInformation>
|
||||||
SignatureInformations const & GetSignatureInformations() const;
|
GetDocumentSignatureInformations(
|
||||||
|
const css::uno::Reference<css::xml::crypto::XSecurityEnvironment>& xSecEnv) const;
|
||||||
|
SignatureInformations const& GetSignatureInformations() const;
|
||||||
|
|
||||||
/// Return the ID of the next created signature.
|
/// Return the ID of the next created signature.
|
||||||
sal_Int32 GetNewSecurityId() const;
|
sal_Int32 GetNewSecurityId() const;
|
||||||
@@ -44,7 +46,8 @@ public:
|
|||||||
/// Append a new signature at the end of xInputStream.
|
/// Append a new signature at the end of xInputStream.
|
||||||
bool Sign(const css::uno::Reference<css::io::XInputStream>& xInputStream, bool bAdES);
|
bool Sign(const css::uno::Reference<css::io::XInputStream>& xInputStream, bool bAdES);
|
||||||
/// Remove the signature at nPosition (and all dependent signatures) from xInputStream.
|
/// Remove the signature at nPosition (and all dependent signatures) from xInputStream.
|
||||||
static bool RemoveSignature(const css::uno::Reference<css::io::XInputStream>& xInputStream, sal_uInt16 nPosition);
|
static bool RemoveSignature(const css::uno::Reference<css::io::XInputStream>& xInputStream,
|
||||||
|
sal_uInt16 nPosition);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INCLUDED_XMLSECURITY_INC_PDFSIGNATUREHELPER_HXX
|
#endif // INCLUDED_XMLSECURITY_INC_PDFSIGNATUREHELPER_HXX
|
||||||
|
@@ -44,23 +44,24 @@
|
|||||||
|
|
||||||
using namespace css;
|
using namespace css;
|
||||||
|
|
||||||
DocumentSignatureManager::DocumentSignatureManager(const uno::Reference<uno::XComponentContext>& xContext, DocumentSignatureMode eMode)
|
DocumentSignatureManager::DocumentSignatureManager(
|
||||||
: mxContext(xContext),
|
const uno::Reference<uno::XComponentContext>& xContext, DocumentSignatureMode eMode)
|
||||||
maSignatureHelper(xContext),
|
: mxContext(xContext)
|
||||||
meSignatureMode(eMode)
|
, maSignatureHelper(xContext)
|
||||||
|
, meSignatureMode(eMode)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
DocumentSignatureManager::~DocumentSignatureManager()
|
DocumentSignatureManager::~DocumentSignatureManager() { deInitXmlSec(); }
|
||||||
{
|
|
||||||
deInitXmlSec();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DocumentSignatureManager::init()
|
bool DocumentSignatureManager::init()
|
||||||
{
|
{
|
||||||
SAL_WARN_IF(mxSEInitializer.is(), "xmlsecurity.helper", "DocumentSignatureManager::Init - mxSEInitializer already set!");
|
SAL_WARN_IF(mxSEInitializer.is(), "xmlsecurity.helper",
|
||||||
SAL_WARN_IF(mxSecurityContext.is(), "xmlsecurity.helper", "DocumentSignatureManager::Init - mxSecurityContext already set!");
|
"DocumentSignatureManager::Init - mxSEInitializer already set!");
|
||||||
SAL_WARN_IF(mxGpgSEInitializer.is(), "xmlsecurity.helper", "DocumentSignatureManager::Init - mxGpgSEInitializer already set!");
|
SAL_WARN_IF(mxSecurityContext.is(), "xmlsecurity.helper",
|
||||||
|
"DocumentSignatureManager::Init - mxSecurityContext already set!");
|
||||||
|
SAL_WARN_IF(mxGpgSEInitializer.is(), "xmlsecurity.helper",
|
||||||
|
"DocumentSignatureManager::Init - mxGpgSEInitializer already set!");
|
||||||
|
|
||||||
// xmlsec is needed by both services, so init before those
|
// xmlsec is needed by both services, so init before those
|
||||||
initXmlSec();
|
initXmlSec();
|
||||||
@@ -152,7 +153,7 @@ bool DocumentSignatureManager::isXML(const OUString& rURI)
|
|||||||
}
|
}
|
||||||
if (DocumentSignatureHelper::equalsReferenceUriManifestPath(rURI, sPath))
|
if (DocumentSignatureHelper::equalsReferenceUriManifestPath(rURI, sPath))
|
||||||
{
|
{
|
||||||
bIsXML = sMediaType == "text/xml" && ! bEncrypted;
|
bIsXML = sMediaType == "text/xml" && !bEncrypted;
|
||||||
bPropsAvailable = true;
|
bPropsAvailable = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -167,7 +168,7 @@ bool DocumentSignatureManager::isXML(const OUString& rURI)
|
|||||||
sal_Int32 nSep = rURI.lastIndexOf('.');
|
sal_Int32 nSep = rURI.lastIndexOf('.');
|
||||||
if (nSep != -1)
|
if (nSep != -1)
|
||||||
{
|
{
|
||||||
OUString aExt = rURI.copy(nSep+1);
|
OUString aExt = rURI.copy(nSep + 1);
|
||||||
if (aExt.equalsIgnoreAsciiCase("XML"))
|
if (aExt.equalsIgnoreAsciiCase("XML"))
|
||||||
bIsXML = true;
|
bIsXML = true;
|
||||||
}
|
}
|
||||||
@@ -181,7 +182,8 @@ bool DocumentSignatureManager::isXML(const OUString& rURI)
|
|||||||
//We keep the temporary stream as member because ImplGetSignatureInformations
|
//We keep the temporary stream as member because ImplGetSignatureInformations
|
||||||
//will later access the stream to create DocumentSignatureInformation objects
|
//will later access the stream to create DocumentSignatureInformation objects
|
||||||
//which are stored in maCurrentSignatureInformations.
|
//which are stored in maCurrentSignatureInformations.
|
||||||
SignatureStreamHelper DocumentSignatureManager::ImplOpenSignatureStream(sal_Int32 nStreamOpenMode, bool bTempStream)
|
SignatureStreamHelper DocumentSignatureManager::ImplOpenSignatureStream(sal_Int32 nStreamOpenMode,
|
||||||
|
bool bTempStream)
|
||||||
{
|
{
|
||||||
SignatureStreamHelper aHelper;
|
SignatureStreamHelper aHelper;
|
||||||
if (mxStore.is())
|
if (mxStore.is())
|
||||||
@@ -201,7 +203,8 @@ SignatureStreamHelper DocumentSignatureManager::ImplOpenSignatureStream(sal_Int3
|
|||||||
aHelper.xSignatureStream = mxTempSignatureStream;
|
aHelper.xSignatureStream = mxTempSignatureStream;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mxTempSignatureStorage = comphelper::OStorageHelper::GetStorageOfFormatFromStream(ZIP_STORAGE_FORMAT_STRING, mxTempSignatureStream);
|
mxTempSignatureStorage = comphelper::OStorageHelper::GetStorageOfFormatFromStream(
|
||||||
|
ZIP_STORAGE_FORMAT_STRING, mxTempSignatureStream);
|
||||||
aHelper.xSignatureStorage = mxTempSignatureStorage;
|
aHelper.xSignatureStorage = mxTempSignatureStorage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -209,7 +212,8 @@ SignatureStreamHelper DocumentSignatureManager::ImplOpenSignatureStream(sal_Int3
|
|||||||
{
|
{
|
||||||
//When we read from the temp stream, then we must have previously
|
//When we read from the temp stream, then we must have previously
|
||||||
//created one.
|
//created one.
|
||||||
SAL_WARN_IF(!mxTempSignatureStream.is(), "xmlsecurity.helper", "empty temp. signature stream reference");
|
SAL_WARN_IF(!mxTempSignatureStream.is(), "xmlsecurity.helper",
|
||||||
|
"empty temp. signature stream reference");
|
||||||
}
|
}
|
||||||
aHelper.xSignatureStream = mxTempSignatureStream;
|
aHelper.xSignatureStream = mxTempSignatureStream;
|
||||||
if (aHelper.nStorageFormat == embed::StorageFormats::OFOPXML)
|
if (aHelper.nStorageFormat == embed::StorageFormats::OFOPXML)
|
||||||
@@ -225,7 +229,8 @@ SignatureStreamHelper DocumentSignatureManager::ImplOpenSignatureStream(sal_Int3
|
|||||||
//Or DocumentDigitalSignatures::showDocumentContentSignatures was called,
|
//Or DocumentDigitalSignatures::showDocumentContentSignatures was called,
|
||||||
//in which case Add/Remove is not allowed. This is done, for example, if the
|
//in which case Add/Remove is not allowed. This is done, for example, if the
|
||||||
//document is readonly
|
//document is readonly
|
||||||
aHelper = DocumentSignatureHelper::OpenSignatureStream(mxStore, nStreamOpenMode, meSignatureMode);
|
aHelper = DocumentSignatureHelper::OpenSignatureStream(mxStore, nStreamOpenMode,
|
||||||
|
meSignatureMode);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -235,7 +240,8 @@ SignatureStreamHelper DocumentSignatureManager::ImplOpenSignatureStream(sal_Int3
|
|||||||
|
|
||||||
if (nStreamOpenMode & embed::ElementModes::TRUNCATE)
|
if (nStreamOpenMode & embed::ElementModes::TRUNCATE)
|
||||||
{
|
{
|
||||||
if (aHelper.xSignatureStream.is() && aHelper.nStorageFormat != embed::StorageFormats::OFOPXML)
|
if (aHelper.xSignatureStream.is()
|
||||||
|
&& aHelper.nStorageFormat != embed::StorageFormats::OFOPXML)
|
||||||
{
|
{
|
||||||
uno::Reference<io::XTruncate> xTruncate(aHelper.xSignatureStream, uno::UNO_QUERY_THROW);
|
uno::Reference<io::XTruncate> xTruncate(aHelper.xSignatureStream, uno::UNO_QUERY_THROW);
|
||||||
xTruncate->truncate();
|
xTruncate->truncate();
|
||||||
@@ -253,11 +259,10 @@ SignatureStreamHelper DocumentSignatureManager::ImplOpenSignatureStream(sal_Int3
|
|||||||
return aHelper;
|
return aHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DocumentSignatureManager::add(const uno::Reference<security::XCertificate>& xCert,
|
bool DocumentSignatureManager::add(
|
||||||
const uno::Reference<xml::crypto::XXMLSecurityContext>& xSecurityContext,
|
const uno::Reference<security::XCertificate>& xCert,
|
||||||
const OUString& rDescription,
|
const uno::Reference<xml::crypto::XXMLSecurityContext>& xSecurityContext,
|
||||||
sal_Int32& nSecurityId,
|
const OUString& rDescription, sal_Int32& nSecurityId, bool bAdESCompliant)
|
||||||
bool bAdESCompliant)
|
|
||||||
{
|
{
|
||||||
if (!xCert.is())
|
if (!xCert.is())
|
||||||
{
|
{
|
||||||
@@ -266,8 +271,9 @@ bool DocumentSignatureManager::add(const uno::Reference<security::XCertificate>&
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GPG or X509 key?
|
// GPG or X509 key?
|
||||||
uno::Reference< lang::XServiceInfo > xServiceInfo(xSecurityContext, uno::UNO_QUERY);
|
uno::Reference<lang::XServiceInfo> xServiceInfo(xSecurityContext, uno::UNO_QUERY);
|
||||||
if (xServiceInfo->getImplementationName() == "com.sun.star.xml.security.gpg.XMLSecurityContext_GpgImpl")
|
if (xServiceInfo->getImplementationName()
|
||||||
|
== "com.sun.star.xml.security.gpg.XMLSecurityContext_GpgImpl")
|
||||||
{
|
{
|
||||||
// GPG keys only really have PGPKeyId and PGPKeyPacket
|
// GPG keys only really have PGPKeyId and PGPKeyPacket
|
||||||
if (!mxStore.is())
|
if (!mxStore.is())
|
||||||
@@ -291,9 +297,11 @@ bool DocumentSignatureManager::add(const uno::Reference<security::XCertificate>&
|
|||||||
aKeyId = aBuffer.makeStringAndClear();
|
aKeyId = aBuffer.makeStringAndClear();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
SAL_WARN("xmlsecurity.helper", "XCertificate implementation without an xmlsecurity::Certificate one");
|
SAL_WARN("xmlsecurity.helper",
|
||||||
|
"XCertificate implementation without an xmlsecurity::Certificate one");
|
||||||
|
|
||||||
maSignatureHelper.SetGpgCertificate(nSecurityId, aKeyId, aStrBuffer.makeStringAndClear(), xCert->getIssuerName());
|
maSignatureHelper.SetGpgCertificate(nSecurityId, aKeyId, aStrBuffer.makeStringAndClear(),
|
||||||
|
xCert->getIssuerName());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -334,14 +342,16 @@ bool DocumentSignatureManager::add(const uno::Reference<security::XCertificate>&
|
|||||||
aCertDigest = aBuffer.makeStringAndClear();
|
aCertDigest = aBuffer.makeStringAndClear();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
SAL_WARN("xmlsecurity.helper", "XCertificate implementation without an xmlsecurity::Certificate one");
|
SAL_WARN("xmlsecurity.helper",
|
||||||
|
"XCertificate implementation without an xmlsecurity::Certificate one");
|
||||||
maSignatureHelper.SetX509Certificate(nSecurityId, xCert->getIssuerName(), aCertSerial, aStrBuffer.makeStringAndClear(), aCertDigest);
|
|
||||||
|
|
||||||
|
maSignatureHelper.SetX509Certificate(nSecurityId, xCert->getIssuerName(), aCertSerial,
|
||||||
|
aStrBuffer.makeStringAndClear(), aCertDigest);
|
||||||
}
|
}
|
||||||
|
|
||||||
uno::Sequence< uno::Reference< security::XCertificate > > aCertPath = xSecurityContext->getSecurityEnvironment()->buildCertificatePath(xCert);
|
uno::Sequence<uno::Reference<security::XCertificate>> aCertPath
|
||||||
const uno::Reference< security::XCertificate >* pCertPath = aCertPath.getConstArray();
|
= xSecurityContext->getSecurityEnvironment()->buildCertificatePath(xCert);
|
||||||
|
const uno::Reference<security::XCertificate>* pCertPath = aCertPath.getConstArray();
|
||||||
sal_Int32 nCnt = aCertPath.getLength();
|
sal_Int32 nCnt = aCertPath.getLength();
|
||||||
|
|
||||||
OUStringBuffer aStrBuffer;
|
OUStringBuffer aStrBuffer;
|
||||||
@@ -351,8 +361,8 @@ bool DocumentSignatureManager::add(const uno::Reference<security::XCertificate>&
|
|||||||
maSignatureHelper.AddEncapsulatedX509Certificate(aStrBuffer.makeStringAndClear());
|
maSignatureHelper.AddEncapsulatedX509Certificate(aStrBuffer.makeStringAndClear());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<OUString> aElements = DocumentSignatureHelper::CreateElementList(
|
||||||
std::vector< OUString > aElements = DocumentSignatureHelper::CreateElementList(mxStore, meSignatureMode, DocumentSignatureAlgorithm::OOo3_2);
|
mxStore, meSignatureMode, DocumentSignatureAlgorithm::OOo3_2);
|
||||||
DocumentSignatureHelper::AppendContentTypes(mxStore, aElements);
|
DocumentSignatureHelper::AppendContentTypes(mxStore, aElements);
|
||||||
|
|
||||||
sal_Int32 nElements = aElements.size();
|
sal_Int32 nElements = aElements.size();
|
||||||
@@ -362,7 +372,8 @@ bool DocumentSignatureManager::add(const uno::Reference<security::XCertificate>&
|
|||||||
maSignatureHelper.AddForSigning(nSecurityId, aElements[n], bBinaryMode, bAdESCompliant);
|
maSignatureHelper.AddForSigning(nSecurityId, aElements[n], bBinaryMode, bAdESCompliant);
|
||||||
}
|
}
|
||||||
|
|
||||||
maSignatureHelper.SetDateTime(nSecurityId, Date(Date::SYSTEM), tools::Time(tools::Time::SYSTEM));
|
maSignatureHelper.SetDateTime(nSecurityId, Date(Date::SYSTEM),
|
||||||
|
tools::Time(tools::Time::SYSTEM));
|
||||||
maSignatureHelper.SetDescription(nSecurityId, rDescription);
|
maSignatureHelper.SetDescription(nSecurityId, rDescription);
|
||||||
|
|
||||||
// We open a signature stream in which the existing and the new
|
// We open a signature stream in which the existing and the new
|
||||||
@@ -370,18 +381,23 @@ bool DocumentSignatureManager::add(const uno::Reference<security::XCertificate>&
|
|||||||
//then read the stream an will fill maCurrentSignatureInformations. The final signature
|
//then read the stream an will fill maCurrentSignatureInformations. The final signature
|
||||||
//is written when the user presses OK. Then only maCurrentSignatureInformation and
|
//is written when the user presses OK. Then only maCurrentSignatureInformation and
|
||||||
//a sax writer are used to write the information.
|
//a sax writer are used to write the information.
|
||||||
SignatureStreamHelper aStreamHelper = ImplOpenSignatureStream(embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE, true);
|
SignatureStreamHelper aStreamHelper
|
||||||
|
= ImplOpenSignatureStream(embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE, true);
|
||||||
|
|
||||||
if (aStreamHelper.nStorageFormat != embed::StorageFormats::OFOPXML)
|
if (aStreamHelper.nStorageFormat != embed::StorageFormats::OFOPXML)
|
||||||
{
|
{
|
||||||
uno::Reference<io::XOutputStream> xOutputStream(aStreamHelper.xSignatureStream, uno::UNO_QUERY_THROW);
|
uno::Reference<io::XOutputStream> xOutputStream(aStreamHelper.xSignatureStream,
|
||||||
uno::Reference<xml::sax::XWriter> xSaxWriter = maSignatureHelper.CreateDocumentHandlerWithHeader(xOutputStream);
|
uno::UNO_QUERY_THROW);
|
||||||
|
uno::Reference<xml::sax::XWriter> xSaxWriter
|
||||||
|
= maSignatureHelper.CreateDocumentHandlerWithHeader(xOutputStream);
|
||||||
|
|
||||||
// Export old signatures...
|
// Export old signatures...
|
||||||
uno::Reference<xml::sax::XDocumentHandler> xDocumentHandler(xSaxWriter, uno::UNO_QUERY_THROW);
|
uno::Reference<xml::sax::XDocumentHandler> xDocumentHandler(xSaxWriter,
|
||||||
|
uno::UNO_QUERY_THROW);
|
||||||
std::size_t nInfos = maCurrentSignatureInformations.size();
|
std::size_t nInfos = maCurrentSignatureInformations.size();
|
||||||
for (std::size_t n = 0; n < nInfos; n++)
|
for (std::size_t n = 0; n < nInfos; n++)
|
||||||
XMLSignatureHelper::ExportSignature(xDocumentHandler, maCurrentSignatureInformations[n], bAdESCompliant);
|
XMLSignatureHelper::ExportSignature(xDocumentHandler, maCurrentSignatureInformations[n],
|
||||||
|
bAdESCompliant);
|
||||||
|
|
||||||
// Create a new one...
|
// Create a new one...
|
||||||
maSignatureHelper.CreateAndWriteSignature(xDocumentHandler, bAdESCompliant);
|
maSignatureHelper.CreateAndWriteSignature(xDocumentHandler, bAdESCompliant);
|
||||||
@@ -397,23 +413,29 @@ bool DocumentSignatureManager::add(const uno::Reference<security::XCertificate>&
|
|||||||
maSignatureHelper.EnsureSignaturesRelation(mxStore, /*bAdd=*/true);
|
maSignatureHelper.EnsureSignaturesRelation(mxStore, /*bAdd=*/true);
|
||||||
// Old signatures + the new one.
|
// Old signatures + the new one.
|
||||||
int nSignatureCount = maCurrentSignatureInformations.size() + 1;
|
int nSignatureCount = maCurrentSignatureInformations.size() + 1;
|
||||||
maSignatureHelper.ExportSignatureRelations(aStreamHelper.xSignatureStorage, nSignatureCount);
|
maSignatureHelper.ExportSignatureRelations(aStreamHelper.xSignatureStorage,
|
||||||
|
nSignatureCount);
|
||||||
|
|
||||||
// Export old signatures.
|
// Export old signatures.
|
||||||
for (std::size_t i = 0; i < maCurrentSignatureInformations.size(); ++i)
|
for (std::size_t i = 0; i < maCurrentSignatureInformations.size(); ++i)
|
||||||
maSignatureHelper.ExportOOXMLSignature(mxStore, aStreamHelper.xSignatureStorage, maCurrentSignatureInformations[i], i + 1);
|
maSignatureHelper.ExportOOXMLSignature(mxStore, aStreamHelper.xSignatureStorage,
|
||||||
|
maCurrentSignatureInformations[i], i + 1);
|
||||||
|
|
||||||
// Create a new signature.
|
// Create a new signature.
|
||||||
maSignatureHelper.CreateAndWriteOOXMLSignature(mxStore, aStreamHelper.xSignatureStorage, nSignatureCount);
|
maSignatureHelper.CreateAndWriteOOXMLSignature(mxStore, aStreamHelper.xSignatureStorage,
|
||||||
|
nSignatureCount);
|
||||||
|
|
||||||
// Flush objects.
|
// Flush objects.
|
||||||
uno::Reference<embed::XTransactedObject> xTransact(aStreamHelper.xSignatureStorage, uno::UNO_QUERY);
|
uno::Reference<embed::XTransactedObject> xTransact(aStreamHelper.xSignatureStorage,
|
||||||
|
uno::UNO_QUERY);
|
||||||
xTransact->commit();
|
xTransact->commit();
|
||||||
uno::Reference<io::XOutputStream> xOutputStream(aStreamHelper.xSignatureStream, uno::UNO_QUERY);
|
uno::Reference<io::XOutputStream> xOutputStream(aStreamHelper.xSignatureStream,
|
||||||
|
uno::UNO_QUERY);
|
||||||
xOutputStream->closeOutput();
|
xOutputStream->closeOutput();
|
||||||
|
|
||||||
uno::Reference<io::XTempFile> xTempFile(aStreamHelper.xSignatureStream, uno::UNO_QUERY);
|
uno::Reference<io::XTempFile> xTempFile(aStreamHelper.xSignatureStream, uno::UNO_QUERY);
|
||||||
SAL_INFO("xmlsecurity.helper", "DocumentSignatureManager::add temporary storage at " << xTempFile->getUri());
|
SAL_INFO("xmlsecurity.helper",
|
||||||
|
"DocumentSignatureManager::add temporary storage at " << xTempFile->getUri());
|
||||||
}
|
}
|
||||||
|
|
||||||
maSignatureHelper.EndMission();
|
maSignatureHelper.EndMission();
|
||||||
@@ -434,24 +456,30 @@ void DocumentSignatureManager::remove(sal_uInt16 nPosition)
|
|||||||
|
|
||||||
// Only erase when the removal was successful, it may fail for PDF.
|
// Only erase when the removal was successful, it may fail for PDF.
|
||||||
// Also, erase the requested and all following signatures, as PDF signatures are always chained.
|
// Also, erase the requested and all following signatures, as PDF signatures are always chained.
|
||||||
maCurrentSignatureInformations.erase(maCurrentSignatureInformations.begin() + nPosition, maCurrentSignatureInformations.end());
|
maCurrentSignatureInformations.erase(maCurrentSignatureInformations.begin() + nPosition,
|
||||||
|
maCurrentSignatureInformations.end());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
maCurrentSignatureInformations.erase(maCurrentSignatureInformations.begin() + nPosition);
|
maCurrentSignatureInformations.erase(maCurrentSignatureInformations.begin() + nPosition);
|
||||||
|
|
||||||
// Export all other signatures...
|
// Export all other signatures...
|
||||||
SignatureStreamHelper aStreamHelper = ImplOpenSignatureStream(embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE, /*bTempStream=*/true);
|
SignatureStreamHelper aStreamHelper = ImplOpenSignatureStream(
|
||||||
|
embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE, /*bTempStream=*/true);
|
||||||
|
|
||||||
if (aStreamHelper.nStorageFormat != embed::StorageFormats::OFOPXML)
|
if (aStreamHelper.nStorageFormat != embed::StorageFormats::OFOPXML)
|
||||||
{
|
{
|
||||||
uno::Reference<io::XOutputStream> xOutputStream(aStreamHelper.xSignatureStream, uno::UNO_QUERY_THROW);
|
uno::Reference<io::XOutputStream> xOutputStream(aStreamHelper.xSignatureStream,
|
||||||
uno::Reference<xml::sax::XWriter> xSaxWriter = maSignatureHelper.CreateDocumentHandlerWithHeader(xOutputStream);
|
uno::UNO_QUERY_THROW);
|
||||||
|
uno::Reference<xml::sax::XWriter> xSaxWriter
|
||||||
|
= maSignatureHelper.CreateDocumentHandlerWithHeader(xOutputStream);
|
||||||
|
|
||||||
uno::Reference< xml::sax::XDocumentHandler> xDocumentHandler(xSaxWriter, uno::UNO_QUERY_THROW);
|
uno::Reference<xml::sax::XDocumentHandler> xDocumentHandler(xSaxWriter,
|
||||||
|
uno::UNO_QUERY_THROW);
|
||||||
std::size_t nInfos = maCurrentSignatureInformations.size();
|
std::size_t nInfos = maCurrentSignatureInformations.size();
|
||||||
for (std::size_t n = 0 ; n < nInfos ; ++n)
|
for (std::size_t n = 0; n < nInfos; ++n)
|
||||||
XMLSignatureHelper::ExportSignature(xDocumentHandler, maCurrentSignatureInformations[n], false /* ??? */);
|
XMLSignatureHelper::ExportSignature(xDocumentHandler, maCurrentSignatureInformations[n],
|
||||||
|
false /* ??? */);
|
||||||
|
|
||||||
XMLSignatureHelper::CloseDocumentHandler(xDocumentHandler);
|
XMLSignatureHelper::CloseDocumentHandler(xDocumentHandler);
|
||||||
}
|
}
|
||||||
@@ -461,20 +489,25 @@ void DocumentSignatureManager::remove(sal_uInt16 nPosition)
|
|||||||
|
|
||||||
// Handle relations.
|
// Handle relations.
|
||||||
int nSignatureCount = maCurrentSignatureInformations.size();
|
int nSignatureCount = maCurrentSignatureInformations.size();
|
||||||
maSignatureHelper.ExportSignatureRelations(aStreamHelper.xSignatureStorage, nSignatureCount);
|
maSignatureHelper.ExportSignatureRelations(aStreamHelper.xSignatureStorage,
|
||||||
|
nSignatureCount);
|
||||||
|
|
||||||
// Export old signatures.
|
// Export old signatures.
|
||||||
for (std::size_t i = 0; i < maCurrentSignatureInformations.size(); ++i)
|
for (std::size_t i = 0; i < maCurrentSignatureInformations.size(); ++i)
|
||||||
maSignatureHelper.ExportOOXMLSignature(mxStore, aStreamHelper.xSignatureStorage, maCurrentSignatureInformations[i], i + 1);
|
maSignatureHelper.ExportOOXMLSignature(mxStore, aStreamHelper.xSignatureStorage,
|
||||||
|
maCurrentSignatureInformations[i], i + 1);
|
||||||
|
|
||||||
// Flush objects.
|
// Flush objects.
|
||||||
uno::Reference<embed::XTransactedObject> xTransact(aStreamHelper.xSignatureStorage, uno::UNO_QUERY);
|
uno::Reference<embed::XTransactedObject> xTransact(aStreamHelper.xSignatureStorage,
|
||||||
|
uno::UNO_QUERY);
|
||||||
xTransact->commit();
|
xTransact->commit();
|
||||||
uno::Reference<io::XOutputStream> xOutputStream(aStreamHelper.xSignatureStream, uno::UNO_QUERY);
|
uno::Reference<io::XOutputStream> xOutputStream(aStreamHelper.xSignatureStream,
|
||||||
|
uno::UNO_QUERY);
|
||||||
xOutputStream->closeOutput();
|
xOutputStream->closeOutput();
|
||||||
|
|
||||||
uno::Reference<io::XTempFile> xTempFile(aStreamHelper.xSignatureStream, uno::UNO_QUERY);
|
uno::Reference<io::XTempFile> xTempFile(aStreamHelper.xSignatureStream, uno::UNO_QUERY);
|
||||||
SAL_INFO("xmlsecurity.helper", "DocumentSignatureManager::remove: temporary storage is at " << xTempFile->getUri());
|
SAL_INFO("xmlsecurity.helper", "DocumentSignatureManager::remove: temporary storage is at "
|
||||||
|
<< xTempFile->getUri());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -487,14 +520,19 @@ void DocumentSignatureManager::read(bool bUseTempStream, bool bCacheLastSignatur
|
|||||||
// ZIP-based: ODF or OOXML.
|
// ZIP-based: ODF or OOXML.
|
||||||
maSignatureHelper.StartMission(mxSecurityContext);
|
maSignatureHelper.StartMission(mxSecurityContext);
|
||||||
|
|
||||||
SignatureStreamHelper aStreamHelper = ImplOpenSignatureStream(embed::ElementModes::READ, bUseTempStream);
|
SignatureStreamHelper aStreamHelper
|
||||||
if (aStreamHelper.nStorageFormat != embed::StorageFormats::OFOPXML && aStreamHelper.xSignatureStream.is())
|
= ImplOpenSignatureStream(embed::ElementModes::READ, bUseTempStream);
|
||||||
|
if (aStreamHelper.nStorageFormat != embed::StorageFormats::OFOPXML
|
||||||
|
&& aStreamHelper.xSignatureStream.is())
|
||||||
{
|
{
|
||||||
uno::Reference< io::XInputStream > xInputStream(aStreamHelper.xSignatureStream, uno::UNO_QUERY);
|
uno::Reference<io::XInputStream> xInputStream(aStreamHelper.xSignatureStream,
|
||||||
|
uno::UNO_QUERY);
|
||||||
maSignatureHelper.ReadAndVerifySignature(xInputStream);
|
maSignatureHelper.ReadAndVerifySignature(xInputStream);
|
||||||
}
|
}
|
||||||
else if (aStreamHelper.nStorageFormat == embed::StorageFormats::OFOPXML && aStreamHelper.xSignatureStorage.is())
|
else if (aStreamHelper.nStorageFormat == embed::StorageFormats::OFOPXML
|
||||||
maSignatureHelper.ReadAndVerifySignatureStorage(aStreamHelper.xSignatureStorage, bCacheLastSignature);
|
&& aStreamHelper.xSignatureStorage.is())
|
||||||
|
maSignatureHelper.ReadAndVerifySignatureStorage(aStreamHelper.xSignatureStorage,
|
||||||
|
bCacheLastSignature);
|
||||||
maSignatureHelper.EndMission();
|
maSignatureHelper.EndMission();
|
||||||
|
|
||||||
maCurrentSignatureInformations = maSignatureHelper.GetSignatureInformations();
|
maCurrentSignatureInformations = maSignatureHelper.GetSignatureInformations();
|
||||||
@@ -517,29 +555,36 @@ void DocumentSignatureManager::write(bool bXAdESCompliantIfODF)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Export all other signatures...
|
// Export all other signatures...
|
||||||
SignatureStreamHelper aStreamHelper = ImplOpenSignatureStream(embed::ElementModes::WRITE|embed::ElementModes::TRUNCATE, false);
|
SignatureStreamHelper aStreamHelper = ImplOpenSignatureStream(
|
||||||
|
embed::ElementModes::WRITE | embed::ElementModes::TRUNCATE, false);
|
||||||
|
|
||||||
if (aStreamHelper.xSignatureStream.is() && aStreamHelper.nStorageFormat != embed::StorageFormats::OFOPXML)
|
if (aStreamHelper.xSignatureStream.is()
|
||||||
|
&& aStreamHelper.nStorageFormat != embed::StorageFormats::OFOPXML)
|
||||||
{
|
{
|
||||||
// ODF
|
// ODF
|
||||||
uno::Reference< io::XOutputStream > xOutputStream(aStreamHelper.xSignatureStream, uno::UNO_QUERY);
|
uno::Reference<io::XOutputStream> xOutputStream(aStreamHelper.xSignatureStream,
|
||||||
uno::Reference<xml::sax::XWriter> xSaxWriter = maSignatureHelper.CreateDocumentHandlerWithHeader(xOutputStream);
|
uno::UNO_QUERY);
|
||||||
|
uno::Reference<xml::sax::XWriter> xSaxWriter
|
||||||
|
= maSignatureHelper.CreateDocumentHandlerWithHeader(xOutputStream);
|
||||||
|
|
||||||
uno::Reference< xml::sax::XDocumentHandler> xDocumentHandler(xSaxWriter, uno::UNO_QUERY_THROW);
|
uno::Reference<xml::sax::XDocumentHandler> xDocumentHandler(xSaxWriter,
|
||||||
|
uno::UNO_QUERY_THROW);
|
||||||
std::size_t nInfos = maCurrentSignatureInformations.size();
|
std::size_t nInfos = maCurrentSignatureInformations.size();
|
||||||
for (std::size_t n = 0 ; n < nInfos ; ++n)
|
for (std::size_t n = 0; n < nInfos; ++n)
|
||||||
XMLSignatureHelper::ExportSignature(xDocumentHandler, maCurrentSignatureInformations[n], bXAdESCompliantIfODF);
|
XMLSignatureHelper::ExportSignature(xDocumentHandler, maCurrentSignatureInformations[n],
|
||||||
|
bXAdESCompliantIfODF);
|
||||||
|
|
||||||
XMLSignatureHelper::CloseDocumentHandler(xDocumentHandler);
|
XMLSignatureHelper::CloseDocumentHandler(xDocumentHandler);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (aStreamHelper.xSignatureStorage.is() && aStreamHelper.nStorageFormat == embed::StorageFormats::OFOPXML)
|
else if (aStreamHelper.xSignatureStorage.is()
|
||||||
|
&& aStreamHelper.nStorageFormat == embed::StorageFormats::OFOPXML)
|
||||||
{
|
{
|
||||||
// OOXML
|
// OOXML
|
||||||
std::size_t nSignatureCount = maCurrentSignatureInformations.size();
|
std::size_t nSignatureCount = maCurrentSignatureInformations.size();
|
||||||
maSignatureHelper.ExportSignatureContentTypes(mxStore, nSignatureCount);
|
maSignatureHelper.ExportSignatureContentTypes(mxStore, nSignatureCount);
|
||||||
if (nSignatureCount > 0)
|
if (nSignatureCount > 0)
|
||||||
maSignatureHelper.ExportSignatureRelations(aStreamHelper.xSignatureStorage, nSignatureCount);
|
maSignatureHelper.ExportSignatureRelations(aStreamHelper.xSignatureStorage,
|
||||||
|
nSignatureCount);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Removing all signatures: then need to remove the signature relation as well.
|
// Removing all signatures: then need to remove the signature relation as well.
|
||||||
@@ -550,36 +595,42 @@ void DocumentSignatureManager::write(bool bXAdESCompliantIfODF)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (std::size_t i = 0; i < nSignatureCount; ++i)
|
for (std::size_t i = 0; i < nSignatureCount; ++i)
|
||||||
maSignatureHelper.ExportOOXMLSignature(mxStore, aStreamHelper.xSignatureStorage, maCurrentSignatureInformations[i], i + 1);
|
maSignatureHelper.ExportOOXMLSignature(mxStore, aStreamHelper.xSignatureStorage,
|
||||||
|
maCurrentSignatureInformations[i], i + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If stream was not provided, we are responsible for committing it....
|
// If stream was not provided, we are responsible for committing it....
|
||||||
if (!mxSignatureStream.is() && aStreamHelper.xSignatureStorage.is())
|
if (!mxSignatureStream.is() && aStreamHelper.xSignatureStorage.is())
|
||||||
{
|
{
|
||||||
uno::Reference<embed::XTransactedObject> xTrans(aStreamHelper.xSignatureStorage, uno::UNO_QUERY);
|
uno::Reference<embed::XTransactedObject> xTrans(aStreamHelper.xSignatureStorage,
|
||||||
|
uno::UNO_QUERY);
|
||||||
xTrans->commit();
|
xTrans->commit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uno::Reference<xml::crypto::XSecurityEnvironment> DocumentSignatureManager::getSecurityEnvironment()
|
uno::Reference<xml::crypto::XSecurityEnvironment> DocumentSignatureManager::getSecurityEnvironment()
|
||||||
{
|
{
|
||||||
return mxSecurityContext.is() ? mxSecurityContext->getSecurityEnvironment() : uno::Reference<xml::crypto::XSecurityEnvironment>();
|
return mxSecurityContext.is() ? mxSecurityContext->getSecurityEnvironment()
|
||||||
|
: uno::Reference<xml::crypto::XSecurityEnvironment>();
|
||||||
}
|
}
|
||||||
|
|
||||||
uno::Reference<xml::crypto::XSecurityEnvironment> DocumentSignatureManager::getGpgSecurityEnvironment()
|
uno::Reference<xml::crypto::XSecurityEnvironment>
|
||||||
|
DocumentSignatureManager::getGpgSecurityEnvironment()
|
||||||
{
|
{
|
||||||
return mxGpgSecurityContext.is() ? mxGpgSecurityContext->getSecurityEnvironment() : uno::Reference<xml::crypto::XSecurityEnvironment>();
|
return mxGpgSecurityContext.is() ? mxGpgSecurityContext->getSecurityEnvironment()
|
||||||
|
: uno::Reference<xml::crypto::XSecurityEnvironment>();
|
||||||
}
|
}
|
||||||
|
|
||||||
uno::Reference<xml::crypto::XXMLSecurityContext> const & DocumentSignatureManager::getSecurityContext()
|
uno::Reference<xml::crypto::XXMLSecurityContext> const&
|
||||||
|
DocumentSignatureManager::getSecurityContext()
|
||||||
{
|
{
|
||||||
return mxSecurityContext;
|
return mxSecurityContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
uno::Reference<xml::crypto::XXMLSecurityContext> const & DocumentSignatureManager::getGpgSecurityContext()
|
uno::Reference<xml::crypto::XXMLSecurityContext> const&
|
||||||
|
DocumentSignatureManager::getGpgSecurityContext()
|
||||||
{
|
{
|
||||||
return mxGpgSecurityContext;
|
return mxGpgSecurityContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
@@ -26,7 +26,8 @@ using namespace ::com::sun::star;
|
|||||||
|
|
||||||
PDFSignatureHelper::PDFSignatureHelper() = default;
|
PDFSignatureHelper::PDFSignatureHelper() = default;
|
||||||
|
|
||||||
bool PDFSignatureHelper::ReadAndVerifySignature(const uno::Reference<io::XInputStream>& xInputStream)
|
bool PDFSignatureHelper::ReadAndVerifySignature(
|
||||||
|
const uno::Reference<io::XInputStream>& xInputStream)
|
||||||
{
|
{
|
||||||
if (!xInputStream.is())
|
if (!xInputStream.is())
|
||||||
{
|
{
|
||||||
@@ -62,12 +63,14 @@ bool PDFSignatureHelper::ReadAndVerifySignature(const uno::Reference<io::XInputS
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SignatureInformations const & PDFSignatureHelper::GetSignatureInformations() const
|
SignatureInformations const& PDFSignatureHelper::GetSignatureInformations() const
|
||||||
{
|
{
|
||||||
return m_aSignatureInfos;
|
return m_aSignatureInfos;
|
||||||
}
|
}
|
||||||
|
|
||||||
uno::Sequence<security::DocumentSignatureInformation> PDFSignatureHelper::GetDocumentSignatureInformations(const uno::Reference<xml::crypto::XSecurityEnvironment>& xSecEnv) const
|
uno::Sequence<security::DocumentSignatureInformation>
|
||||||
|
PDFSignatureHelper::GetDocumentSignatureInformations(
|
||||||
|
const uno::Reference<xml::crypto::XSecurityEnvironment>& xSecEnv) const
|
||||||
{
|
{
|
||||||
uno::Sequence<security::DocumentSignatureInformation> aRet(m_aSignatureInfos.size());
|
uno::Sequence<security::DocumentSignatureInformation> aRet(m_aSignatureInfos.size());
|
||||||
|
|
||||||
@@ -75,7 +78,8 @@ uno::Sequence<security::DocumentSignatureInformation> PDFSignatureHelper::GetDoc
|
|||||||
{
|
{
|
||||||
const SignatureInformation& rInternal = m_aSignatureInfos[i];
|
const SignatureInformation& rInternal = m_aSignatureInfos[i];
|
||||||
security::DocumentSignatureInformation& rExternal = aRet[i];
|
security::DocumentSignatureInformation& rExternal = aRet[i];
|
||||||
rExternal.SignatureIsValid = rInternal.nStatus == xml::crypto::SecurityOperationStatus_OPERATION_SUCCEEDED;
|
rExternal.SignatureIsValid
|
||||||
|
= rInternal.nStatus == xml::crypto::SecurityOperationStatus_OPERATION_SUCCEEDED;
|
||||||
if (!rInternal.ouX509Certificate.isEmpty())
|
if (!rInternal.ouX509Certificate.isEmpty())
|
||||||
rExternal.Signer = xSecEnv->createCertificateFromAscii(rInternal.ouX509Certificate);
|
rExternal.Signer = xSecEnv->createCertificateFromAscii(rInternal.ouX509Certificate);
|
||||||
rExternal.PartialDocumentSignature = rInternal.bPartialDocumentSignature;
|
rExternal.PartialDocumentSignature = rInternal.bPartialDocumentSignature;
|
||||||
@@ -100,12 +104,10 @@ uno::Sequence<security::DocumentSignatureInformation> PDFSignatureHelper::GetDoc
|
|||||||
return aRet;
|
return aRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
sal_Int32 PDFSignatureHelper::GetNewSecurityId() const
|
sal_Int32 PDFSignatureHelper::GetNewSecurityId() const { return m_aSignatureInfos.size(); }
|
||||||
{
|
|
||||||
return m_aSignatureInfos.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PDFSignatureHelper::SetX509Certificate(const uno::Reference<security::XCertificate>& xCertificate)
|
void PDFSignatureHelper::SetX509Certificate(
|
||||||
|
const uno::Reference<security::XCertificate>& xCertificate)
|
||||||
{
|
{
|
||||||
m_xCertificate = xCertificate;
|
m_xCertificate = xCertificate;
|
||||||
}
|
}
|
||||||
@@ -142,7 +144,8 @@ bool PDFSignatureHelper::Sign(const uno::Reference<io::XInputStream>& xInputStre
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PDFSignatureHelper::RemoveSignature(const uno::Reference<io::XInputStream>& xInputStream, sal_uInt16 nPosition)
|
bool PDFSignatureHelper::RemoveSignature(const uno::Reference<io::XInputStream>& xInputStream,
|
||||||
|
sal_uInt16 nPosition)
|
||||||
{
|
{
|
||||||
std::unique_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(xInputStream, true));
|
std::unique_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(xInputStream, true));
|
||||||
vcl::filter::PDFDocument aDocument;
|
vcl::filter::PDFDocument aDocument;
|
||||||
|
Reference in New Issue
Block a user