1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <osl/mutex.hxx>
25 #include <com/sun/star/uno/Sequence.h>
26 #include <rtl/ustring.hxx>
27 #include <unotools/options.hxx>
29 /*-************************************************************************************************************//**
30 @short forward declaration to our private date container implementation
31 @descr We use these class as internal member to support small memory requirements.
32 You can create the container if it is neccessary. The class which use these mechanism
33 is faster and smaller then a complete implementation!
34 *//*-*************************************************************************************************************/
36 class SvtSecurityOptions_Impl
;
38 /*-************************************************************************************************************//**
39 @descr These values present modes to handle StarOffice basic scripts.
40 see GetBasicMode/SetBasicMode() for further information
41 *//*-*************************************************************************************************************/
43 enum EBasicSecurityMode
50 /*-************************************************************************************************************//**
51 @short collect information about security features
57 @ATTENTION This class is partially threadsafe.
59 @devstatus ready to use
60 *//*-*************************************************************************************************************/
62 class UNOTOOLS_DLLPUBLIC SAL_WARN_UNUSED SvtSecurityOptions
: public utl::detail::Options
69 E_BASICMODE
, // xmlsec05 depricated
70 E_EXECUTEPLUGINS
, // xmlsec05 depricated
71 E_WARNING
, // xmlsec05 depricated
72 E_CONFIRMATION
, // xmlsec05 depricated
77 E_DOCWARN_REMOVEPERSONALINFO
,
78 E_DOCWARN_RECOMMENDPASSWORD
,
80 E_MACRO_TRUSTEDAUTHORS
,
92 typedef ::com::sun::star::uno::Sequence
< OUString
> Certificate
;
95 // MT: Doesn't work for sequence...
99 OUString SerialNumber;
105 /*-****************************************************************************************************//**
106 @short standard constructor and destructor
107 @descr This will initialize an instance with default values.
108 We implement these class with a refcount mechanism! Every instance of this class increase it
109 at create and decrease it at delete time - but all instances use the same data container!
110 He is implemented as a static member ...
112 @seealso member m_nRefCount
113 @seealso member m_pDataContainer
119 *//*-*****************************************************************************************************/
121 SvtSecurityOptions();
122 virtual ~SvtSecurityOptions();
124 /*-****************************************************************************************************//**
125 @short returns readonly state
126 @descr It can be called to get information about the readonly state of a provided item.
129 @param "eOption", specify, which item is queried
130 @return <TRUE/> if item is readonly; <FALSE/> otherwise
132 @onerror No error should occurre!
133 *//*-*****************************************************************************************************/
135 sal_Bool
IsReadOnly( EOption eOption
) const ;
137 /*-****************************************************************************************************//**
138 @short interface methods to get and set value of config key "org.openoffice.Office.Common/Security/Scripting/SecureURL"
139 @descr These value displays the list of all trustworthy URLs.
140 zB.: file:/ => All scripts from the local file system including a LAN;
141 private:explorer => Scripts from the Explorer;
142 private:help => Scripts in the help system;
143 private:newmenu => Scripts that are executed by the commands File-New and AutoPilot;
144 private:schedule => Scripts of the scheduler;
145 private:searchfolder => Scripts of the searchfolder;
146 private:user => Scripts that are entered in the URL field.
149 @param "seqURLList", new values to set it in configuration.
150 @return The values which represent current state of internal variable.
152 @onerror No error should occurre!
153 *//*-*****************************************************************************************************/
155 ::com::sun::star::uno::Sequence
< OUString
> GetSecureURLs( ) const ;
156 void SetSecureURLs( const ::com::sun::star::uno::Sequence
< OUString
>& seqURLList
) ;
158 /*-****************************************************************************************************//**
159 @short interface methods to get and set value of config key "org.openoffice.Office.Common/Security/Scripting/StarOfficeBasic"
160 @descr These value determines how StarOffice Basic scripts should be handled.
161 It exist 3 different modes:
166 @ATTENTION These methods don't check for valid or invalid values!
167 Our configuration server can do it ... but these implementation don't get any notifications
168 about wrong commits ...!
169 => If you set an invalid value - nothing will be changed. The information will lost.
171 @seealso enum EBasicSecurityMode
173 @param "eMode" to set new mode ... Value must defined as an enum of type EBasicSecurityMode!
174 @return An enum value, which present current mode.
176 @onerror No error should occurre!
177 *//*-*****************************************************************************************************/
179 sal_Int32
GetMacroSecurityLevel ( ) const ;
180 void SetMacroSecurityLevel ( sal_Int32 _nLevel
) ;
182 sal_Bool
IsMacroDisabled ( ) const ;
184 /*-****************************************************************************************************//**
185 @short special method to check an URL and his referer corresponding to ouer internal security cessation
186 @descr Give us an URL and his referer and we will say you if these url can be scripted or not!
190 @param "sURL" reference to URL for checking
191 @param "sReferer" reference to referer which whish to run script by given URL
192 @return sal_True if URL is secure or security is obsolete(!) or sal_False otherwise.
194 @onerror No error should occurre!
195 *//*-*****************************************************************************************************/
197 sal_Bool
IsSecureURL( const OUString
& sURL
,
198 const OUString
& sReferer
) const ;
200 ::com::sun::star::uno::Sequence
< Certificate
> GetTrustedAuthors ( ) const ;
201 void SetTrustedAuthors ( const ::com::sun::star::uno::Sequence
< Certificate
>& rAuthors
) ;
203 // for bool options only!
204 bool IsOptionSet ( EOption eOption
) const ;
205 bool SetOption ( EOption eOption
, bool bValue
) ;
206 bool IsOptionEnabled ( EOption eOption
) const ;
208 // xmlsec05 depricated methods
209 sal_Bool
IsExecutePlugins() const;
210 void SetExecutePlugins( sal_Bool bSet
);
211 EBasicSecurityMode
GetBasicMode( ) const ;
212 void SetBasicMode( EBasicSecurityMode eMode
) ;
213 sal_Bool
IsWarningEnabled() const;
214 void SetWarningEnabled( sal_Bool bSet
);
215 sal_Bool
IsConfirmationEnabled() const;
216 void SetConfirmationEnabled( sal_Bool bSet
);
218 //-------------------------------------------------------------------------------------------------------------
220 //-------------------------------------------------------------------------------------------------------------
224 /*-****************************************************************************************************//**
225 @short return a reference to a static mutex
226 @descr These class is partially threadsafe (for de-/initialization only).
227 All access methods are'nt safe!
228 We create a static mutex only for one ime and use at different times.
233 @return A reference to a static mutex member.
236 *//*-*****************************************************************************************************/
238 UNOTOOLS_DLLPRIVATE
static ::osl::Mutex
& GetInitMutex();
240 //-------------------------------------------------------------------------------------------------------------
242 //-------------------------------------------------------------------------------------------------------------
248 Don't initialize these static member in these header!
249 a) Double dfined symbols will be detected ...
250 b) and unresolved externals exist at linking time.
251 Do it in your source only.
254 static SvtSecurityOptions_Impl
* m_pDataContainer
; /// impl. data container as dynamic pointer for smaller memory requirements!
255 static sal_Int32 m_nRefCount
; /// internal ref count mechanism
257 }; // class SvtSecurityOptions
259 #endif // #ifndef INCLUDED_unotools_SECURITYOPTIONS_HXX
261 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */