bump product version to 6.3.0.0.beta1
[LibreOffice.git] / include / unotools / securityoptions.hxx
blob36f43ed0c50526e8da7fafa6596dee2c2efe90d6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_UNOTOOLS_SECURITYOPTIONS_HXX
20 #define INCLUDED_UNOTOOLS_SECURITYOPTIONS_HXX
22 #include <unotools/unotoolsdllapi.h>
23 #include <sal/types.h>
24 #include <com/sun/star/uno/Sequence.h>
25 #include <rtl/ustring.hxx>
26 #include <unotools/options.hxx>
27 #include <memory>
29 namespace osl { class Mutex; }
31 /*-************************************************************************************************************
32 @short forward declaration to our private date container implementation
33 @descr We use these class as internal member to support small memory requirements.
34 You can create the container if it is necessary. The class which use these mechanism
35 is faster and smaller then a complete implementation!
36 *//*-*************************************************************************************************************/
38 class SvtSecurityOptions_Impl;
40 /*-************************************************************************************************************
41 @descr These values present modes to handle StarOffice basic scripts.
42 see GetBasicMode/SetBasicMode() for further information
43 *//*-*************************************************************************************************************/
45 enum EBasicSecurityMode
47 eNEVER_EXECUTE = 0,
48 eFROM_LIST = 1,
49 eALWAYS_EXECUTE = 2
52 /*-************************************************************************************************************
53 @short collect information about security features
54 @ATTENTION This class is partially threadsafe.
56 @devstatus ready to use
57 *//*-*************************************************************************************************************/
59 class SAL_WARN_UNUSED UNOTOOLS_DLLPUBLIC SvtSecurityOptions : public utl::detail::Options
61 public:
63 enum class EOption
65 SecureUrls,
66 BasicMode, // xmlsec05 deprecated
67 ExecutePlugins, // xmlsec05 deprecated
68 Warning, // xmlsec05 deprecated
69 Confirmation, // xmlsec05 deprecated
70 DocWarnSaveOrSend,
71 DocWarnSigning,
72 DocWarnPrint,
73 DocWarnCreatePdf,
74 DocWarnRemovePersonalInfo,
75 DocWarnRecommendPassword,
76 MacroSecLevel,
77 MacroTrustedAuthors,
78 CtrlClickHyperlink,
79 BlockUntrustedRefererLinks
82 typedef css::uno::Sequence< OUString > Certificate;
85 // MT: Doesn't work for sequence...
86 struct Certificate
88 OUString SubjectName;
89 OUString SerialNumber;
90 OUString RawData;
94 public:
95 SvtSecurityOptions();
96 virtual ~SvtSecurityOptions() override;
98 /*-****************************************************************************************************
99 @short returns readonly state
100 @descr It can be called to get information about the readonly state of a provided item.
101 @param "eOption", specify, which item is queried
102 @return <TRUE/> if item is readonly; <FALSE/> otherwise
104 @onerror No error should occur!
105 *//*-*****************************************************************************************************/
107 bool IsReadOnly( EOption eOption ) const;
109 /*-****************************************************************************************************
110 @short interface methods to get and set value of config key "org.openoffice.Office.Common/Security/Scripting/SecureURL"
111 @descr These value displays the list of all trustworthy URLs.
112 zB.: file:/ => All scripts from the local file system including a LAN;
113 private:explorer => Scripts from the Explorer;
114 private:help => Scripts in the help system;
115 private:newmenu => Scripts that are executed by the commands File-New and AutoPilot;
116 private:schedule => Scripts of the scheduler;
117 private:searchfolder => Scripts of the searchfolder;
118 private:user => Scripts that are entered in the URL field.
119 @param "seqURLList", new values to set it in configuration.
120 @return The values which represent current state of internal variable.
122 @onerror No error should occur!
123 *//*-*****************************************************************************************************/
125 css::uno::Sequence< OUString > GetSecureURLs( ) const;
126 void SetSecureURLs( const css::uno::Sequence< OUString >& seqURLList );
128 /*-****************************************************************************************************
129 @short interface methods to get and set value of config key "org.openoffice.Office.Common/Security/Scripting/StarOfficeBasic"
130 @descr These value determines how StarOffice Basic scripts should be handled.
131 It exist 3 different modes:
132 0 = never execute
133 1 = from list
134 2 = always execute
136 @ATTENTION These methods don't check for valid or invalid values!
137 Our configuration server can do it ... but these implementation don't get any notifications
138 about wrong commits ...!
139 => If you set an invalid value - nothing will be changed. The information will lost.
141 @seealso enum EBasicSecurityMode
143 @param "eMode" to set new mode ... Value must defined as an enum of type EBasicSecurityMode!
144 @return An enum value, which present current mode.
146 @onerror No error should occur!
147 *//*-*****************************************************************************************************/
149 sal_Int32 GetMacroSecurityLevel ( ) const;
150 void SetMacroSecurityLevel ( sal_Int32 _nLevel );
152 bool IsMacroDisabled ( ) const;
155 Check whether the given uri is either no dangerous macro-execution
156 URI at all or else the given referer is a trusted source.
158 bool isSecureMacroUri(OUString const & uri, OUString const & referer)
159 const;
162 Check whether the given referer URI is untrusted, and links
163 originating from it should not be accessed.
165 bool isUntrustedReferer(OUString const & referer) const;
168 Check whether the given uri is a trusted location.
170 bool isTrustedLocationUri(OUString const & uri) const;
172 bool isTrustedLocationUriForUpdatingLinks(OUString const & uri) const;
174 css::uno::Sequence< Certificate > GetTrustedAuthors ( ) const;
175 void SetTrustedAuthors ( const css::uno::Sequence< Certificate >& rAuthors );
177 // for bool options only!
178 bool IsOptionSet ( EOption eOption ) const;
179 void SetOption ( EOption eOption, bool bValue );
180 bool IsOptionEnabled ( EOption eOption ) const;
182 // xmlsec05 deprecated methods
183 bool IsExecutePlugins() const;
184 void SetExecutePlugins( bool bSet );
185 EBasicSecurityMode GetBasicMode( ) const;
186 void SetBasicMode( EBasicSecurityMode eMode );
187 bool IsWarningEnabled() const;
188 void SetWarningEnabled( bool bSet );
189 bool IsConfirmationEnabled() const;
190 void SetConfirmationEnabled( bool bSet );
192 // private methods
194 private:
196 /*-****************************************************************************************************
197 @short return a reference to a static mutex
198 @descr These class is partially threadsafe (for de-/initialization only).
199 All access methods aren't safe!
200 We create a static mutex only for one ime and use at different times.
201 @return A reference to a static mutex member.
202 *//*-*****************************************************************************************************/
204 UNOTOOLS_DLLPRIVATE static ::osl::Mutex& GetInitMutex();
206 // private member
208 private:
209 std::shared_ptr<SvtSecurityOptions_Impl> m_pImpl;
211 }; // class SvtSecurityOptions
213 #endif // INCLUDED_UNOTOOLS_SECURITYOPTIONS_HXX
215 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */