2010-10-27 12:45:03 +01:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-21 14:30:25 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2004-07-14 10:06:31 +00:00
|
|
|
|
2016-05-27 10:56:17 +03:00
|
|
|
#ifndef INCLUDED_XMLSECURITY_INC_DOCUMENTSIGNATUREHELPER_HXX
|
|
|
|
#define INCLUDED_XMLSECURITY_INC_DOCUMENTSIGNATUREHELPER_HXX
|
2004-07-14 10:06:31 +00:00
|
|
|
|
|
|
|
#include <com/sun/star/uno/Reference.h>
|
2016-11-09 15:14:03 +02:00
|
|
|
#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
|
2004-07-14 10:06:31 +00:00
|
|
|
#include <rtl/ustring.hxx>
|
2017-07-09 09:42:01 -04:00
|
|
|
#include <svl/sigstruct.hxx>
|
2017-09-05 22:57:54 +02:00
|
|
|
#include "xmlsecuritydllapi.h"
|
2004-07-14 10:06:31 +00:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace com {
|
|
|
|
namespace sun {
|
|
|
|
namespace star {
|
|
|
|
namespace io {
|
|
|
|
class XStream; }
|
|
|
|
namespace embed {
|
|
|
|
class XStorage; }
|
|
|
|
}}}
|
|
|
|
|
2016-11-01 14:49:56 +02:00
|
|
|
enum class DocumentSignatureMode
|
|
|
|
{
|
|
|
|
Content,
|
|
|
|
Macros,
|
|
|
|
Package
|
|
|
|
};
|
2004-07-14 10:06:31 +00:00
|
|
|
|
2016-11-01 14:49:56 +02:00
|
|
|
enum class DocumentSignatureAlgorithm
|
2009-09-17 13:53:54 +00:00
|
|
|
{
|
2016-11-01 14:49:56 +02:00
|
|
|
OOo2,
|
|
|
|
OOo3_0,
|
|
|
|
OOo3_2
|
2009-09-17 13:53:54 +00:00
|
|
|
};
|
|
|
|
|
2004-07-14 10:06:31 +00:00
|
|
|
struct SignatureStreamHelper
|
|
|
|
{
|
|
|
|
css::uno::Reference < css::embed::XStorage > xSignatureStorage;
|
|
|
|
css::uno::Reference < css::io::XStream > xSignatureStream;
|
2016-01-13 09:34:01 +01:00
|
|
|
/// If this is embed::StorageFormats::OFOPXML, then it's expected that xSignatureStream is an empty reference.
|
|
|
|
sal_Int32 nStorageFormat;
|
|
|
|
|
|
|
|
SignatureStreamHelper()
|
|
|
|
: nStorageFormat(0)
|
|
|
|
{
|
|
|
|
}
|
2004-07-14 10:06:31 +00:00
|
|
|
};
|
|
|
|
|
2016-11-09 18:48:14 +02:00
|
|
|
namespace DocumentSignatureHelper
|
2004-07-14 10:06:31 +00:00
|
|
|
{
|
2016-11-09 21:18:00 +02:00
|
|
|
SignatureStreamHelper OpenSignatureStream(
|
2009-09-17 13:53:54 +00:00
|
|
|
const css::uno::Reference < css::embed::XStorage >& rxStore, sal_Int32 nOpenMode,
|
|
|
|
DocumentSignatureMode eDocSigMode );
|
2016-11-09 18:48:14 +02:00
|
|
|
|
2016-11-09 21:18:00 +02:00
|
|
|
std::vector< OUString > CreateElementList(
|
2009-09-17 13:53:54 +00:00
|
|
|
const css::uno::Reference < css::embed::XStorage >& rxStore,
|
2014-03-17 09:18:44 +02:00
|
|
|
DocumentSignatureMode eMode,
|
2009-09-17 13:53:54 +00:00
|
|
|
const DocumentSignatureAlgorithm mode);
|
2016-11-09 18:48:14 +02:00
|
|
|
|
2016-11-09 21:18:00 +02:00
|
|
|
bool isODFPre_1_2(const OUString & sODFVersion);
|
|
|
|
bool isOOo3_2_Signature(const SignatureInformation & sigInfo);
|
2016-11-09 18:48:14 +02:00
|
|
|
|
2016-11-09 21:18:00 +02:00
|
|
|
DocumentSignatureAlgorithm getDocumentAlgorithm(
|
2013-04-07 12:06:47 +02:00
|
|
|
const OUString & sODFVersion, const SignatureInformation & sigInfo);
|
2016-11-09 18:48:14 +02:00
|
|
|
|
2017-06-26 12:32:48 +02:00
|
|
|
bool CanSignWithGPG(const css::uno::Reference < css::embed::XStorage >& rxStore,
|
|
|
|
const OUString& sOdfVersion);
|
|
|
|
|
2016-11-09 21:18:00 +02:00
|
|
|
bool checkIfAllFilesAreSigned( const ::std::vector< OUString > & sElementList,
|
2009-09-17 13:53:54 +00:00
|
|
|
const SignatureInformation & sigInfo, const DocumentSignatureAlgorithm alg);
|
2016-11-09 18:48:14 +02:00
|
|
|
|
2016-11-09 21:18:00 +02:00
|
|
|
bool equalsReferenceUriManifestPath(
|
2013-04-07 12:06:47 +02:00
|
|
|
const OUString & rUri, const OUString & rPath);
|
2008-05-14 09:20:38 +00:00
|
|
|
|
2016-11-09 21:18:00 +02:00
|
|
|
OUString GetDocumentContentSignatureDefaultStreamName();
|
|
|
|
OUString GetScriptingContentSignatureDefaultStreamName();
|
|
|
|
OUString GetPackageSignatureDefaultStreamName();
|
2016-11-09 18:48:14 +02:00
|
|
|
|
|
|
|
/// In case the storage is OOXML, prepend a leading '/' and append content type to the element URIs.
|
2016-11-09 21:18:00 +02:00
|
|
|
void AppendContentTypes(const css::uno::Reference<css::embed::XStorage>& xStorage, std::vector<OUString>& rElements);
|
2016-11-09 15:14:03 +02:00
|
|
|
|
|
|
|
void writeDigestMethod(
|
|
|
|
const css::uno::Reference<css::xml::sax::XDocumentHandler>& xDocumentHandler);
|
|
|
|
void writeSignedProperties(
|
|
|
|
const css::uno::Reference<css::xml::sax::XDocumentHandler>& xDocumentHandler,
|
|
|
|
const SignatureInformation& signatureInfo,
|
2018-09-18 09:59:08 +02:00
|
|
|
const OUString& sDate,
|
|
|
|
const bool bWriteSignatureLineData);
|
2004-07-14 10:06:31 +00:00
|
|
|
};
|
|
|
|
|
2016-05-27 10:56:17 +03:00
|
|
|
#endif // INCLUDED_XMLSECURITY_INC_DOCUMENTSIGNATUREHELPER_HXX
|
2010-10-27 12:45:03 +01:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|