LibreOffice Module unotools (master) 1
securityoptions.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19#pragma once
20
22#include <sal/types.h>
23#include <rtl/ustring.hxx>
24#include <vector>
25#include <unordered_map>
26
27/*-************************************************************************************************************
28 @short collect information about security features
29 @ATTENTION This class is partially threadsafe.
30
31 @devstatus ready to use
32*//*-*************************************************************************************************************/
33
34namespace SvtSecurityOptions
35{
36 enum class EOption
37 {
49 };
50
52 {
53 OUString SubjectName;
54 OUString SerialNumber;
55 OUString RawData;
56
57 bool operator==(const Certificate& other) const
58 {
59 return SubjectName == other.SubjectName && SerialNumber == other.SerialNumber && RawData == other.RawData;
60 }
61 };
62
63
64 /*-****************************************************************************************************
65 @short returns readonly state
66 @descr It can be called to get information about the readonly state of a provided item.
67 @param "eOption", specify, which item is queried
68 @return <TRUE/> if item is readonly; <FALSE/> otherwise
69
70 @onerror No error should occur!
71 *//*-*****************************************************************************************************/
72
74
75 /*-****************************************************************************************************
76 @short interface methods to get and set value of config key "org.openoffice.Office.Common/Security/Scripting/SecureURL"
77 @descr These value displays the list of all trustworthy URLs.
78 zB.: file:/ => All scripts from the local file system including a LAN;
79 private:explorer => Scripts from the Explorer;
80 private:help => Scripts in the help system;
81 private:newmenu => Scripts that are executed by the commands File-New and AutoPilot;
82 private:schedule => Scripts of the scheduler;
83 private:searchfolder => Scripts of the searchfolder;
84 private:user => Scripts that are entered in the URL field.
85 @param "seqURLList", new values to set it in configuration.
86 @return The values which represent current state of internal variable.
87
88 @onerror No error should occur!
89 *//*-*****************************************************************************************************/
90
91 UNOTOOLS_DLLPUBLIC std::vector< OUString > GetSecureURLs();
92 UNOTOOLS_DLLPUBLIC void SetSecureURLs( std::vector< OUString >&& seqURLList );
93
94 /*-****************************************************************************************************
95 @short interface methods to get and set value of config key "org.openoffice.Office.Common/Security/Scripting/StarOfficeBasic"
96 @descr These value determines how StarOffice Basic scripts should be handled.
97 It exist 3 different modes:
98 0 = never execute
99 1 = from list
100 2 = always execute
101
102 @ATTENTION These methods don't check for valid or invalid values!
103 Our configuration server can do it ... but these implementation don't get any notifications
104 about wrong commits ...!
105 => If you set an invalid value - nothing will be changed. The information will lost.
106
107 @seealso enum EBasicSecurityMode
108
109 @param "eMode" to set new mode ... Value must defined as an enum of type EBasicSecurityMode!
110 @return An enum value, which present current mode.
111
112 @onerror No error should occur!
113 *//*-*****************************************************************************************************/
114
116 UNOTOOLS_DLLPUBLIC void SetMacroSecurityLevel( sal_Int32 _nLevel );
117
119
124 UNOTOOLS_DLLPUBLIC bool isSecureMacroUri(OUString const & uri, OUString const & referer);
125
130 UNOTOOLS_DLLPUBLIC bool isUntrustedReferer(OUString const & referer);
131
135 UNOTOOLS_DLLPUBLIC bool isTrustedLocationUri(OUString const & uri);
136
138
139 UNOTOOLS_DLLPUBLIC std::vector< Certificate > GetTrustedAuthors();
140 UNOTOOLS_DLLPUBLIC void SetTrustedAuthors( const std::vector< Certificate >& rAuthors );
141
142 // for bool options only!
143 UNOTOOLS_DLLPUBLIC bool IsOptionSet ( EOption eOption );
144 UNOTOOLS_DLLPUBLIC void SetOption ( EOption eOption, bool bValue );
145
146} // namespace SvtSecurityOptions
147
148// map personal info strings, e.g. authors to 1, 2, 3... for removing personal info
149
151{
152 std::unordered_map< OUString, size_t > aInfoIDs;
153public:
154 size_t GetInfoID( const OUString sPersonalInfo );
155};
156
157/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unordered_map< OUString, size_t > aInfoIDs
void SetMacroSecurityLevel(sal_Int32 _nLevel)
bool isTrustedLocationUri(OUString const &uri)
Check whether the given uri is a trusted location.
bool IsReadOnly(EOption eOption)
void SetSecureURLs(std::vector< OUString > &&urlList)
void SetTrustedAuthors(const std::vector< Certificate > &rAuthors)
sal_Int32 GetMacroSecurityLevel()
bool isSecureMacroUri(OUString const &uri, OUString const &referer)
Check whether the given uri is either no dangerous macro-execution URI at all or else the given refer...
bool isTrustedLocationUriForUpdatingLinks(OUString const &uri)
std::vector< SvtSecurityOptions::Certificate > GetTrustedAuthors()
bool isUntrustedReferer(OUString const &referer)
Check whether the given referer URI is untrusted, and links originating from it should not be accesse...
void SetOption(EOption eOption, bool bValue)
std::vector< OUString > GetSecureURLs()
bool IsOptionSet(EOption eOption)
bool operator==(const Certificate &other) const
#define UNOTOOLS_DLLPUBLIC