1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _XMLSECURITY_DOCUMENTSIGNATUREHELPER_HXX 29 #define _XMLSECURITY_DOCUMENTSIGNATUREHELPER_HXX 30 31 #include <com/sun/star/uno/Reference.h> 32 #include <rtl/ustring.hxx> 33 #include "xmlsecurity/sigstruct.hxx" 34 35 #ifndef _STLP_VECTOR 36 #include <vector> 37 #endif 38 39 40 namespace com { 41 namespace sun { 42 namespace star { 43 namespace io { 44 class XStream; } 45 namespace embed { 46 class XStorage; } 47 }}} 48 49 namespace css = com::sun::star; 50 51 52 /********************************************************** 53 DocumentSignatureHelper 54 55 Helper class for signing and verifieng document signatures 56 57 Functions: 58 1. help to create a list of content to be signed/verified 59 60 **********************************************************/ 61 62 enum DocumentSignatureMode { SignatureModeDocumentContent, SignatureModeMacros, SignatureModePackage }; 63 64 enum DocumentSignatureAlgorithm 65 { 66 OOo2Document, 67 OOo3_0Document, 68 OOo3_2Document 69 }; 70 71 struct SignatureStreamHelper 72 { 73 css::uno::Reference < css::embed::XStorage > xSignatureStorage; 74 css::uno::Reference < css::io::XStream > xSignatureStream; 75 }; 76 77 78 class DocumentSignatureHelper 79 { 80 public: 81 82 static SignatureStreamHelper OpenSignatureStream( 83 const css::uno::Reference < css::embed::XStorage >& rxStore, sal_Int32 nOpenMode, 84 DocumentSignatureMode eDocSigMode ); 85 static std::vector< rtl::OUString > CreateElementList( 86 const css::uno::Reference < css::embed::XStorage >& rxStore, 87 const ::rtl::OUString rRootStorageName, DocumentSignatureMode eMode, 88 const DocumentSignatureAlgorithm mode); 89 static bool isODFPre_1_2(const ::rtl::OUString & sODFVersion); 90 static bool isOOo3_2_Signature(const SignatureInformation & sigInfo); 91 static DocumentSignatureAlgorithm getDocumentAlgorithm( 92 const ::rtl::OUString & sODFVersion, const SignatureInformation & sigInfo); 93 static bool checkIfAllFilesAreSigned( const ::std::vector< ::rtl::OUString > & sElementList, 94 const SignatureInformation & sigInfo, const DocumentSignatureAlgorithm alg); 95 static bool equalsReferenceUriManifestPath( 96 const ::rtl::OUString & rUri, const ::rtl::OUString & rPath); 97 static ::rtl::OUString GetDocumentContentSignatureDefaultStreamName(); 98 static ::rtl::OUString GetScriptingContentSignatureDefaultStreamName(); 99 static ::rtl::OUString GetPackageSignatureDefaultStreamName(); 100 101 }; 102 103 #endif // _XMLSECURITY_XMLSIGNATUREHELPER_HXX 104