Line data Source code
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 :
20 :
21 : #include <unotools/securityoptions.hxx>
22 : #include <unotools/configmgr.hxx>
23 : #include <unotools/configitem.hxx>
24 : #include <tools/debug.hxx>
25 : #include <com/sun/star/uno/Any.hxx>
26 : #include <com/sun/star/uno/Sequence.hxx>
27 :
28 : #include <com/sun/star/beans/PropertyValue.hpp>
29 : #include <comphelper/sequenceasvector.hxx>
30 : #include <tools/urlobj.hxx>
31 : #include <tools/wldcrd.hxx>
32 :
33 : #include <unotools/pathoptions.hxx>
34 :
35 : #include <rtl/logfile.hxx>
36 : #include "itemholder1.hxx"
37 :
38 : //_________________________________________________________________________________________________________________
39 : // namespaces
40 : //_________________________________________________________________________________________________________________
41 :
42 : using namespace ::utl ;
43 : using namespace ::rtl ;
44 : using namespace ::osl ;
45 : using namespace ::com::sun::star::uno ;
46 :
47 : #define ROOTNODE_SECURITY OUString("Office.Common/Security/Scripting")
48 : #define DEFAULT_SECUREURL Sequence< OUString >()
49 : #define DEFAULT_TRUSTEDAUTHORS Sequence< SvtSecurityOptions::Certificate >()
50 :
51 : // xmlsec05 deprecated
52 : #define DEFAULT_STAROFFICEBASIC eALWAYS_EXECUTE
53 :
54 : #define CSTR_SECUREURL "SecureURL"
55 : #define CSTR_DOCWARN_SAVEORSEND "WarnSaveOrSendDoc"
56 : #define CSTR_DOCWARN_SIGNING "WarnSignDoc"
57 : #define CSTR_DOCWARN_PRINT "WarnPrintDoc"
58 : #define CSTR_DOCWARN_CREATEPDF "WarnCreatePDF"
59 : #define CSTR_DOCWARN_REMOVEPERSONALINFO "RemovePersonalInfoOnSaving"
60 : #define CSTR_DOCWARN_RECOMMENDPASSWORD "RecommendPasswordProtection"
61 : #define CSTR_CTRLCLICK_HYPERLINK "HyperlinksWithCtrlClick"
62 : #define CSTR_MACRO_SECLEVEL "MacroSecurityLevel"
63 : #define CSTR_MACRO_TRUSTEDAUTHORS "TrustedAuthors"
64 : #define CSTR_MACRO_DISABLE "DisableMacrosExecution"
65 : #define CSTR_TRUSTEDAUTHOR_SUBJECTNAME "SubjectName"
66 : #define CSTR_TRUSTEDAUTHOR_SERIALNUMBER "SerialNumber"
67 : #define CSTR_TRUSTEDAUTHOR_RAWDATA "RawData"
68 :
69 : #define PROPERTYNAME_SECUREURL OUString(CSTR_SECUREURL)
70 : #define PROPERTYNAME_DOCWARN_SAVEORSEND OUString(CSTR_DOCWARN_SAVEORSEND)
71 : #define PROPERTYNAME_DOCWARN_SIGNING OUString(CSTR_DOCWARN_SIGNING)
72 : #define PROPERTYNAME_DOCWARN_PRINT OUString(CSTR_DOCWARN_PRINT)
73 : #define PROPERTYNAME_DOCWARN_CREATEPDF OUString(CSTR_DOCWARN_CREATEPDF)
74 : #define PROPERTYNAME_DOCWARN_REMOVEPERSONALINFO OUString(CSTR_DOCWARN_REMOVEPERSONALINFO)
75 : #define PROPERTYNAME_DOCWARN_RECOMMENDPASSWORD OUString(CSTR_DOCWARN_RECOMMENDPASSWORD)
76 : #define PROPERTYNAME_CTRLCLICK_HYPERLINK OUString(CSTR_CTRLCLICK_HYPERLINK)
77 : #define PROPERTYNAME_MACRO_SECLEVEL OUString(CSTR_MACRO_SECLEVEL)
78 : #define PROPERTYNAME_MACRO_TRUSTEDAUTHORS OUString(CSTR_MACRO_TRUSTEDAUTHORS)
79 : #define PROPERTYNAME_MACRO_DISABLE OUString(CSTR_MACRO_DISABLE)
80 : #define PROPERTYNAME_TRUSTEDAUTHOR_SUBJECTNAME OUString(CSTR_TRUSTEDAUTHOR_SUBJECTNAME)
81 : #define PROPERTYNAME_TRUSTEDAUTHOR_SERIALNUMBER OUString(CSTR_TRUSTEDAUTHOR_SERIALNUMBER)
82 : #define PROPERTYNAME_TRUSTEDAUTHOR_RAWDATA OUString(CSTR_TRUSTEDAUTHOR_RAWDATA)
83 :
84 : // xmlsec05 deprecated
85 : #define PROPERTYNAME_STAROFFICEBASIC OUString("OfficeBasic")
86 : #define PROPERTYNAME_EXECUTEPLUGINS OUString("ExecutePlugins")
87 : #define PROPERTYNAME_WARNINGENABLED OUString("Warning")
88 : #define PROPERTYNAME_CONFIRMATIONENABLED OUString("Confirmation")
89 : // xmlsec05 deprecated
90 :
91 :
92 : #define PROPERTYHANDLE_SECUREURL 0
93 :
94 : // xmlsec05 deprecated
95 : #define PROPERTYHANDLE_STAROFFICEBASIC 1
96 : #define PROPERTYHANDLE_EXECUTEPLUGINS 2
97 : #define PROPERTYHANDLE_WARNINGENABLED 3
98 : #define PROPERTYHANDLE_CONFIRMATIONENABLED 4
99 : // xmlsec05 deprecated
100 :
101 : #define PROPERTYHANDLE_DOCWARN_SAVEORSEND 5
102 : #define PROPERTYHANDLE_DOCWARN_SIGNING 6
103 : #define PROPERTYHANDLE_DOCWARN_PRINT 7
104 : #define PROPERTYHANDLE_DOCWARN_CREATEPDF 8
105 : #define PROPERTYHANDLE_DOCWARN_REMOVEPERSONALINFO 9
106 : #define PROPERTYHANDLE_DOCWARN_RECOMMENDPASSWORD 10
107 : #define PROPERTYHANDLE_CTRLCLICK_HYPERLINK 11
108 : #define PROPERTYHANDLE_MACRO_SECLEVEL 12
109 : #define PROPERTYHANDLE_MACRO_TRUSTEDAUTHORS 13
110 : #define PROPERTYHANDLE_MACRO_DISABLE 14
111 :
112 : #define PROPERTYCOUNT 15
113 : #define PROPERTYHANDLE_INVALID -1
114 :
115 : #define CFG_READONLY_DEFAULT sal_False
116 :
117 : //_________________________________________________________________________________________________________________
118 : // private declarations!
119 : //_________________________________________________________________________________________________________________
120 :
121 : class SvtSecurityOptions_Impl : public ConfigItem
122 : {
123 : //-------------------------------------------------------------------------------------------------------------
124 : // public methods
125 : //-------------------------------------------------------------------------------------------------------------
126 :
127 : public:
128 :
129 : //---------------------------------------------------------------------------------------------------------
130 : // constructor / destructor
131 : //---------------------------------------------------------------------------------------------------------
132 :
133 : SvtSecurityOptions_Impl();
134 : ~SvtSecurityOptions_Impl();
135 :
136 : //---------------------------------------------------------------------------------------------------------
137 : // overloaded methods of baseclass
138 : //---------------------------------------------------------------------------------------------------------
139 :
140 : /*-****************************************************************************************************//**
141 : @short called for notify of configmanager
142 : @descr These method is called from the ConfigManager before application ends or from the
143 : PropertyChangeListener if the sub tree broadcasts changes. You must update your
144 : internal values.
145 :
146 : @seealso baseclass ConfigItem
147 :
148 : @param "seqPropertyNames" is the list of properties which should be updated.
149 : @return -
150 :
151 : @onerror -
152 : *//*-*****************************************************************************************************/
153 :
154 : virtual void Notify( const Sequence< OUString >& seqPropertyNames );
155 :
156 : /*-****************************************************************************************************//**
157 : @short write changes to configuration
158 : @descr These method writes the changed values into the sub tree
159 : and should always called in our destructor to guarantee consistency of config data.
160 :
161 : @seealso baseclass ConfigItem
162 :
163 : @param -
164 : @return -
165 :
166 : @onerror -
167 : *//*-*****************************************************************************************************/
168 :
169 : virtual void Commit();
170 :
171 : //---------------------------------------------------------------------------------------------------------
172 : // public interface
173 : //---------------------------------------------------------------------------------------------------------
174 :
175 : sal_Bool IsReadOnly ( SvtSecurityOptions::EOption eOption ) const ;
176 :
177 : Sequence< OUString > GetSecureURLs ( ) const ;
178 : void SetSecureURLs ( const Sequence< OUString >& seqURLList ) ;
179 : sal_Bool IsSecureURL ( const OUString& sURL,
180 : const OUString& sReferer ) const ;
181 : inline sal_Int32 GetMacroSecurityLevel ( ) const ;
182 : void SetMacroSecurityLevel ( sal_Int32 _nLevel ) ;
183 :
184 : inline sal_Bool IsMacroDisabled ( ) const ;
185 :
186 : Sequence< SvtSecurityOptions::Certificate > GetTrustedAuthors ( ) const ;
187 : void SetTrustedAuthors ( const Sequence< SvtSecurityOptions::Certificate >& rAuthors ) ;
188 :
189 : sal_Bool IsOptionSet ( SvtSecurityOptions::EOption eOption ) const ;
190 : sal_Bool SetOption ( SvtSecurityOptions::EOption eOption, sal_Bool bValue ) ;
191 : sal_Bool IsOptionEnabled ( SvtSecurityOptions::EOption eOption ) const ;
192 : private:
193 :
194 : /*-****************************************************************************************************//**
195 : @short return list of key names of ouer configuration management which represent our module tree
196 : @descr These methods return a static const list of key names. We need it to get needed values from our
197 : configuration management.
198 :
199 : @seealso -
200 :
201 : @param -
202 : @return A list of needed configuration keys is returned.
203 :
204 : @onerror -
205 : *//*-*****************************************************************************************************/
206 :
207 : void SetProperty( sal_Int32 nHandle, const Any& rValue, sal_Bool bReadOnly );
208 : void LoadAuthors( void );
209 : static sal_Int32 GetHandle( const OUString& rPropertyName );
210 : bool GetOption( SvtSecurityOptions::EOption eOption, sal_Bool*& rpValue, sal_Bool*& rpRO );
211 :
212 : static Sequence< OUString > GetPropertyNames();
213 :
214 : Sequence< OUString > m_seqSecureURLs;
215 : sal_Bool m_bSaveOrSend;
216 : sal_Bool m_bSigning;
217 : sal_Bool m_bPrint;
218 : sal_Bool m_bCreatePDF;
219 : sal_Bool m_bRemoveInfo;
220 : sal_Bool m_bRecommendPwd;
221 : sal_Bool m_bCtrlClickHyperlink;
222 : sal_Int32 m_nSecLevel;
223 : Sequence< SvtSecurityOptions::Certificate > m_seqTrustedAuthors;
224 : sal_Bool m_bDisableMacros;
225 :
226 : sal_Bool m_bROSecureURLs;
227 : sal_Bool m_bROSaveOrSend;
228 : sal_Bool m_bROSigning;
229 : sal_Bool m_bROPrint;
230 : sal_Bool m_bROCreatePDF;
231 : sal_Bool m_bRORemoveInfo;
232 : sal_Bool m_bRORecommendPwd;
233 : sal_Bool m_bROCtrlClickHyperlink;
234 : sal_Bool m_bROSecLevel;
235 : sal_Bool m_bROTrustedAuthors;
236 : sal_Bool m_bRODisableMacros;
237 :
238 :
239 : // xmlsec05 deprecated
240 : EBasicSecurityMode m_eBasicMode;
241 : sal_Bool m_bExecutePlugins;
242 : sal_Bool m_bWarning;
243 : sal_Bool m_bConfirmation;
244 :
245 : sal_Bool m_bROConfirmation;
246 : sal_Bool m_bROWarning;
247 : sal_Bool m_bROExecutePlugins;
248 : sal_Bool m_bROBasicMode;
249 : public:
250 : sal_Bool IsWarningEnabled() const;
251 : void SetWarningEnabled( sal_Bool bSet );
252 : sal_Bool IsConfirmationEnabled() const;
253 : void SetConfirmationEnabled( sal_Bool bSet );
254 : sal_Bool IsExecutePlugins() const;
255 : void SetExecutePlugins( sal_Bool bSet );
256 : EBasicSecurityMode GetBasicMode ( ) const ;
257 : void SetBasicMode ( EBasicSecurityMode eMode ) ;
258 : };
259 :
260 : //*****************************************************************************************************************
261 : // constructor
262 : //*****************************************************************************************************************
263 66 : SvtSecurityOptions_Impl::SvtSecurityOptions_Impl()
264 : :ConfigItem ( ROOTNODE_SECURITY )
265 : ,m_seqSecureURLs ( DEFAULT_SECUREURL )
266 : ,m_bSaveOrSend ( sal_True )
267 : ,m_bSigning ( sal_True )
268 : ,m_bPrint ( sal_True )
269 : ,m_bCreatePDF ( sal_True )
270 : ,m_bRemoveInfo ( sal_True )
271 : ,m_nSecLevel ( sal_True )
272 : ,m_seqTrustedAuthors ( DEFAULT_TRUSTEDAUTHORS )
273 : ,m_bDisableMacros ( sal_False )
274 : ,m_bROSecureURLs ( CFG_READONLY_DEFAULT )
275 : ,m_bROSaveOrSend ( CFG_READONLY_DEFAULT )
276 : ,m_bROSigning ( CFG_READONLY_DEFAULT )
277 : ,m_bROPrint ( CFG_READONLY_DEFAULT )
278 : ,m_bROCreatePDF ( CFG_READONLY_DEFAULT )
279 : ,m_bRORemoveInfo ( CFG_READONLY_DEFAULT )
280 : ,m_bROSecLevel ( CFG_READONLY_DEFAULT )
281 : ,m_bROTrustedAuthors ( CFG_READONLY_DEFAULT )
282 : ,m_bRODisableMacros ( sal_True ) // currently is not intended to be changed
283 :
284 : // xmlsec05 deprecated
285 : , m_eBasicMode ( DEFAULT_STAROFFICEBASIC )
286 : , m_bExecutePlugins ( sal_True )
287 : , m_bWarning ( sal_True )
288 : , m_bConfirmation ( sal_True )
289 : , m_bROConfirmation ( CFG_READONLY_DEFAULT )
290 : , m_bROWarning ( CFG_READONLY_DEFAULT )
291 : , m_bROExecutePlugins ( CFG_READONLY_DEFAULT )
292 66 : , m_bROBasicMode ( CFG_READONLY_DEFAULT )
293 : // xmlsec05 deprecated
294 :
295 : {
296 66 : Sequence< OUString > seqNames = GetPropertyNames ( );
297 132 : Sequence< Any > seqValues = GetProperties ( seqNames );
298 132 : Sequence< sal_Bool > seqRO = GetReadOnlyStates ( seqNames );
299 :
300 : // Safe impossible cases.
301 : // We need values from ALL configuration keys.
302 : // Follow assignment use order of values in relation to our list of key names!
303 : DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtSecurityOptions_Impl::SvtSecurityOptions_Impl()\nI miss some values of configuration keys!\n" );
304 :
305 : // Copy values from list in right order to our internal member.
306 66 : sal_Int32 nPropertyCount = seqValues.getLength();
307 1056 : for( sal_Int32 nProperty = 0 ; nProperty < nPropertyCount ; ++nProperty )
308 990 : SetProperty( nProperty, seqValues[ nProperty ], seqRO[ nProperty ] );
309 :
310 66 : LoadAuthors();
311 :
312 : // Enable notification mechanism of our baseclass.
313 : // We need it to get information about changes outside these class on our used configuration keys!*/
314 :
315 132 : EnableNotification( seqNames );
316 66 : }
317 :
318 : //*****************************************************************************************************************
319 : // destructor
320 : //*****************************************************************************************************************
321 195 : SvtSecurityOptions_Impl::~SvtSecurityOptions_Impl()
322 : {
323 65 : if( IsModified() )
324 0 : Commit();
325 130 : }
326 :
327 990 : void SvtSecurityOptions_Impl::SetProperty( sal_Int32 nProperty, const Any& rValue, sal_Bool bRO )
328 : {
329 990 : switch( nProperty )
330 : {
331 : case PROPERTYHANDLE_SECUREURL:
332 : {
333 66 : m_seqSecureURLs.realloc( 0 );
334 66 : rValue >>= m_seqSecureURLs;
335 66 : SvtPathOptions aOpt;
336 66 : sal_uInt32 nCount = m_seqSecureURLs.getLength();
337 66 : for( sal_uInt32 nItem = 0 ; nItem < nCount ; ++nItem )
338 0 : m_seqSecureURLs[ nItem ] = aOpt.SubstituteVariable( m_seqSecureURLs[ nItem ] );
339 66 : m_bROSecureURLs = bRO;
340 : }
341 66 : break;
342 :
343 : case PROPERTYHANDLE_DOCWARN_SAVEORSEND:
344 : {
345 66 : rValue >>= m_bSaveOrSend;
346 66 : m_bROSaveOrSend = bRO;
347 : }
348 66 : break;
349 :
350 : case PROPERTYHANDLE_DOCWARN_SIGNING:
351 : {
352 66 : rValue >>= m_bSigning;
353 66 : m_bROSigning = bRO;
354 : }
355 66 : break;
356 :
357 : case PROPERTYHANDLE_DOCWARN_PRINT:
358 : {
359 66 : rValue >>= m_bPrint;
360 66 : m_bROPrint = bRO;
361 : }
362 66 : break;
363 :
364 : case PROPERTYHANDLE_DOCWARN_CREATEPDF:
365 : {
366 66 : rValue >>= m_bCreatePDF;
367 66 : m_bROCreatePDF = bRO;
368 : }
369 66 : break;
370 :
371 : case PROPERTYHANDLE_DOCWARN_REMOVEPERSONALINFO:
372 : {
373 66 : rValue >>= m_bRemoveInfo;
374 66 : m_bRORemoveInfo = bRO;
375 : }
376 66 : break;
377 :
378 : case PROPERTYHANDLE_DOCWARN_RECOMMENDPASSWORD:
379 : {
380 66 : rValue >>= m_bRecommendPwd;
381 66 : m_bRORecommendPwd = bRO;
382 : }
383 66 : break;
384 :
385 : case PROPERTYHANDLE_CTRLCLICK_HYPERLINK:
386 : {
387 66 : rValue >>= m_bCtrlClickHyperlink;
388 66 : m_bROCtrlClickHyperlink = bRO;
389 : }
390 66 : break;
391 :
392 : case PROPERTYHANDLE_MACRO_SECLEVEL:
393 : {
394 66 : rValue >>= m_nSecLevel;
395 66 : m_bROSecLevel = bRO;
396 : }
397 66 : break;
398 :
399 : case PROPERTYHANDLE_MACRO_TRUSTEDAUTHORS:
400 : {
401 : // don't care about value here...
402 66 : m_bROTrustedAuthors = bRO;
403 : }
404 66 : break;
405 :
406 : case PROPERTYHANDLE_MACRO_DISABLE:
407 : {
408 66 : rValue >>= m_bDisableMacros;
409 66 : m_bRODisableMacros = bRO;
410 : }
411 66 : break;
412 :
413 :
414 : // xmlsec05 deprecated
415 : case PROPERTYHANDLE_STAROFFICEBASIC:
416 : {
417 66 : sal_Int32 nMode = 0;
418 66 : rValue >>= nMode;
419 66 : m_eBasicMode = (EBasicSecurityMode)nMode;
420 66 : m_bROBasicMode = bRO;
421 : }
422 66 : break;
423 : case PROPERTYHANDLE_EXECUTEPLUGINS:
424 : {
425 66 : rValue >>= m_bExecutePlugins;
426 66 : m_bROExecutePlugins = bRO;
427 : }
428 66 : break;
429 : case PROPERTYHANDLE_WARNINGENABLED:
430 : {
431 66 : rValue >>= m_bWarning;
432 66 : m_bROWarning = bRO;
433 : }
434 66 : break;
435 : case PROPERTYHANDLE_CONFIRMATIONENABLED:
436 : {
437 66 : rValue >>= m_bConfirmation;
438 66 : m_bROConfirmation = bRO;
439 : }
440 66 : break;
441 : // xmlsec05 deprecated
442 :
443 :
444 : #if OSL_DEBUG_LEVEL > 1
445 : default:
446 : DBG_ASSERT( false, "SvtSecurityOptions_Impl::SetProperty()\nUnknown property!\n" );
447 : #endif
448 : }
449 990 : }
450 :
451 66 : void SvtSecurityOptions_Impl::LoadAuthors( void )
452 : {
453 66 : m_seqTrustedAuthors.realloc( 0 ); // first clear
454 66 : Sequence< OUString > lAuthors = GetNodeNames( PROPERTYNAME_MACRO_TRUSTEDAUTHORS );
455 66 : sal_Int32 c1 = lAuthors.getLength();
456 66 : if( c1 )
457 : {
458 0 : sal_Int32 c2 = c1 * 3; // 3 Properties inside Struct TrustedAuthor
459 0 : Sequence< OUString > lAllAuthors( c2 );
460 :
461 : sal_Int32 i1;
462 : sal_Int32 i2;
463 0 : OUString aSep( "/" );
464 0 : for( i1 = 0, i2 = 0 ; i1 < c1 ; ++i1 )
465 : {
466 0 : lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + lAuthors[ i1 ] + aSep + PROPERTYNAME_TRUSTEDAUTHOR_SUBJECTNAME;
467 0 : ++i2;
468 0 : lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + lAuthors[ i1 ] + aSep + PROPERTYNAME_TRUSTEDAUTHOR_SERIALNUMBER;
469 0 : ++i2;
470 0 : lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + lAuthors[ i1 ] + aSep + PROPERTYNAME_TRUSTEDAUTHOR_RAWDATA;
471 0 : ++i2;
472 : }
473 :
474 0 : Sequence< Any > lValues = GetProperties( lAllAuthors );
475 0 : if( lValues.getLength() == c2 )
476 : {
477 0 : comphelper::SequenceAsVector< SvtSecurityOptions::Certificate > v;
478 0 : SvtSecurityOptions::Certificate aCert( 3 );
479 0 : for( i1 = 0, i2 = 0 ; i1 < c1 ; ++i1 )
480 : {
481 0 : lValues[ i2 ] >>= aCert[ 0 ];
482 0 : ++i2;
483 0 : lValues[ i2 ] >>= aCert[ 1 ];
484 0 : ++i2;
485 0 : lValues[ i2 ] >>= aCert[ 2 ];
486 0 : ++i2;
487 : // Filter out TrustedAuthor entries with empty RawData, which
488 : // would cause an unexpected std::bad_alloc in
489 : // SecurityEnvironment_NssImpl::createCertificateFromAscii and
490 : // have been observed in the wild (fdo#55019):
491 0 : if( !aCert[ 2 ].isEmpty() )
492 : {
493 0 : v.push_back( aCert );
494 : }
495 : }
496 0 : m_seqTrustedAuthors = v.getAsConstList();
497 0 : }
498 66 : }
499 66 : }
500 :
501 0 : sal_Int32 SvtSecurityOptions_Impl::GetHandle( const OUString& rName )
502 : {
503 : sal_Int32 nHandle;
504 :
505 0 : if( rName.compareToAscii( CSTR_SECUREURL ) == 0 )
506 0 : nHandle = PROPERTYHANDLE_SECUREURL;
507 0 : else if( rName.compareToAscii( CSTR_DOCWARN_SAVEORSEND ) == 0 )
508 0 : nHandle = PROPERTYHANDLE_DOCWARN_SAVEORSEND;
509 0 : else if( rName.compareToAscii( CSTR_DOCWARN_SIGNING ) == 0 )
510 0 : nHandle = PROPERTYHANDLE_DOCWARN_SIGNING;
511 0 : else if( rName.compareToAscii( CSTR_DOCWARN_PRINT ) == 0 )
512 0 : nHandle = PROPERTYHANDLE_DOCWARN_PRINT;
513 0 : else if( rName.compareToAscii( CSTR_DOCWARN_CREATEPDF ) == 0 )
514 0 : nHandle = PROPERTYHANDLE_DOCWARN_CREATEPDF;
515 0 : else if( rName.compareToAscii( CSTR_DOCWARN_REMOVEPERSONALINFO ) == 0 )
516 0 : nHandle = PROPERTYHANDLE_DOCWARN_REMOVEPERSONALINFO;
517 0 : else if( rName.compareToAscii( CSTR_DOCWARN_RECOMMENDPASSWORD ) == 0 )
518 0 : nHandle = PROPERTYHANDLE_DOCWARN_RECOMMENDPASSWORD;
519 0 : else if( rName.compareToAscii( CSTR_CTRLCLICK_HYPERLINK ) == 0 )
520 0 : nHandle = PROPERTYHANDLE_CTRLCLICK_HYPERLINK;
521 0 : else if( rName.compareToAscii( CSTR_MACRO_SECLEVEL ) == 0 )
522 0 : nHandle = PROPERTYHANDLE_MACRO_SECLEVEL;
523 0 : else if( rName.compareToAscii( CSTR_MACRO_TRUSTEDAUTHORS ) == 0 )
524 0 : nHandle = PROPERTYHANDLE_MACRO_TRUSTEDAUTHORS;
525 0 : else if( rName.compareToAscii( CSTR_MACRO_DISABLE ) == 0 )
526 0 : nHandle = PROPERTYHANDLE_MACRO_DISABLE;
527 :
528 : // xmlsec05 deprecated
529 0 : else if( rName == PROPERTYNAME_STAROFFICEBASIC )
530 0 : nHandle = PROPERTYHANDLE_STAROFFICEBASIC;
531 0 : else if( rName == PROPERTYNAME_EXECUTEPLUGINS )
532 0 : nHandle = PROPERTYHANDLE_EXECUTEPLUGINS;
533 0 : else if( rName == PROPERTYNAME_WARNINGENABLED )
534 0 : nHandle = PROPERTYHANDLE_WARNINGENABLED;
535 0 : else if( rName == PROPERTYNAME_CONFIRMATIONENABLED )
536 0 : nHandle = PROPERTYHANDLE_CONFIRMATIONENABLED;
537 : // xmlsec05 deprecated
538 :
539 : else
540 0 : nHandle = PROPERTYHANDLE_INVALID;
541 :
542 0 : return nHandle;
543 : }
544 :
545 280 : bool SvtSecurityOptions_Impl::GetOption( SvtSecurityOptions::EOption eOption, sal_Bool*& rpValue, sal_Bool*& rpRO )
546 : {
547 280 : switch( eOption )
548 : {
549 : case SvtSecurityOptions::E_DOCWARN_SAVEORSEND:
550 0 : rpValue = &m_bSaveOrSend;
551 0 : rpRO = &m_bROSaveOrSend;
552 0 : break;
553 : case SvtSecurityOptions::E_DOCWARN_SIGNING:
554 0 : rpValue = &m_bSigning;
555 0 : rpRO = &m_bROSigning;
556 0 : break;
557 : case SvtSecurityOptions::E_DOCWARN_PRINT:
558 0 : rpValue = &m_bPrint;
559 0 : rpRO = &m_bROPrint;
560 0 : break;
561 : case SvtSecurityOptions::E_DOCWARN_CREATEPDF:
562 0 : rpValue = &m_bCreatePDF;
563 0 : rpRO = &m_bROCreatePDF;
564 0 : break;
565 : case SvtSecurityOptions::E_DOCWARN_REMOVEPERSONALINFO:
566 32 : rpValue = &m_bRemoveInfo;
567 32 : rpRO = &m_bRORemoveInfo;
568 32 : break;
569 : case SvtSecurityOptions::E_DOCWARN_RECOMMENDPASSWORD:
570 0 : rpValue = &m_bRecommendPwd;
571 0 : rpRO = &m_bRORecommendPwd;
572 0 : break;
573 : case SvtSecurityOptions::E_CTRLCLICK_HYPERLINK:
574 248 : rpValue = &m_bCtrlClickHyperlink;
575 248 : rpRO = &m_bROCtrlClickHyperlink;
576 248 : break;
577 : default:
578 0 : rpValue = NULL;
579 0 : rpRO = NULL;
580 0 : break;
581 : }
582 :
583 280 : return rpValue != NULL;
584 : }
585 :
586 0 : void SvtSecurityOptions_Impl::Notify( const Sequence< OUString >& seqPropertyNames )
587 : {
588 : // Use given list of updated properties to get his values from configuration directly!
589 0 : Sequence< Any > seqValues = GetProperties( seqPropertyNames );
590 0 : Sequence< sal_Bool > seqRO = GetReadOnlyStates( seqPropertyNames );
591 : // Safe impossible cases.
592 : // We need values from ALL notified configuration keys.
593 : DBG_ASSERT( !(seqPropertyNames.getLength()!=seqValues.getLength()), "SvtSecurityOptions_Impl::Notify()\nI miss some values of configuration keys!\n" );
594 : // Step over list of property names and get right value from coreesponding value list to set it on internal members!
595 0 : sal_Int32 nCount = seqPropertyNames.getLength();
596 0 : for( sal_Int32 nProperty = 0 ; nProperty < nCount ; ++nProperty )
597 0 : SetProperty( GetHandle( seqPropertyNames[ nProperty ] ), seqValues[ nProperty ], seqRO[ nProperty ] );
598 :
599 : // read set of trusted authors separately
600 0 : LoadAuthors();
601 0 : }
602 :
603 0 : void SvtSecurityOptions_Impl::Commit()
604 : {
605 : // Get names of supported properties, create a list for values and copy current values to it.
606 0 : Sequence< OUString > lOrgNames = GetPropertyNames();
607 0 : sal_Int32 nOrgCount = lOrgNames.getLength();
608 :
609 0 : Sequence< OUString > lNames(nOrgCount);
610 0 : Sequence< Any > lValues(nOrgCount);
611 0 : sal_Int32 nRealCount = 0;
612 : bool bDone;
613 :
614 0 : ClearNodeSet( PROPERTYNAME_MACRO_TRUSTEDAUTHORS );
615 :
616 0 : for( sal_Int32 nProperty = 0 ; nProperty < nOrgCount ; ++nProperty )
617 : {
618 0 : switch( nProperty )
619 : {
620 : case PROPERTYHANDLE_SECUREURL:
621 : {
622 0 : bDone = !m_bROSecureURLs;
623 0 : if( bDone )
624 : {
625 0 : Sequence< OUString > lURLs( m_seqSecureURLs );
626 0 : SvtPathOptions aOpt;
627 0 : sal_Int32 nURLsCnt = lURLs.getLength();
628 0 : for( sal_Int32 nItem = 0 ; nItem < nURLsCnt ; ++nItem )
629 0 : lURLs[ nItem ] = aOpt.UseVariable( lURLs[ nItem ] );
630 0 : lValues[ nRealCount ] <<= lURLs;
631 : }
632 : }
633 0 : break;
634 :
635 : case PROPERTYHANDLE_DOCWARN_SAVEORSEND:
636 : {
637 0 : bDone = !m_bROSaveOrSend;
638 0 : if( bDone )
639 0 : lValues[ nRealCount ] <<= m_bSaveOrSend;
640 : }
641 0 : break;
642 :
643 : case PROPERTYHANDLE_DOCWARN_SIGNING:
644 : {
645 0 : bDone = !m_bROSigning;
646 0 : if( bDone )
647 0 : lValues[ nRealCount ] <<= m_bSigning;
648 : }
649 0 : break;
650 :
651 : case PROPERTYHANDLE_DOCWARN_PRINT:
652 : {
653 0 : bDone = !m_bROPrint;
654 0 : if( bDone )
655 0 : lValues[ nRealCount ] <<= m_bPrint;
656 : }
657 0 : break;
658 :
659 : case PROPERTYHANDLE_DOCWARN_CREATEPDF:
660 : {
661 0 : bDone = !m_bROCreatePDF;
662 0 : if( bDone )
663 0 : lValues[ nRealCount ] <<= m_bCreatePDF;
664 : }
665 0 : break;
666 :
667 : case PROPERTYHANDLE_DOCWARN_REMOVEPERSONALINFO:
668 : {
669 0 : bDone = !m_bRORemoveInfo;
670 0 : if( bDone )
671 0 : lValues[ nRealCount ] <<= m_bRemoveInfo;
672 : }
673 0 : break;
674 :
675 : case PROPERTYHANDLE_DOCWARN_RECOMMENDPASSWORD:
676 : {
677 0 : bDone = !m_bRORecommendPwd;
678 0 : if( bDone )
679 0 : lValues[ nRealCount ] <<= m_bRecommendPwd;
680 : }
681 0 : break;
682 :
683 : case PROPERTYHANDLE_CTRLCLICK_HYPERLINK:
684 : {
685 0 : bDone = !m_bROCtrlClickHyperlink;
686 0 : if( bDone )
687 0 : lValues[ nRealCount ] <<= m_bCtrlClickHyperlink;
688 : }
689 0 : break;
690 :
691 : case PROPERTYHANDLE_MACRO_SECLEVEL:
692 : {
693 0 : bDone = !m_bROSecLevel;
694 0 : if( bDone )
695 0 : lValues[ nRealCount ] <<= m_nSecLevel;
696 : }
697 0 : break;
698 :
699 : case PROPERTYHANDLE_MACRO_TRUSTEDAUTHORS:
700 : {
701 0 : bDone = !m_bROTrustedAuthors;
702 0 : if( bDone )
703 : {
704 0 : sal_Int32 nCnt = m_seqTrustedAuthors.getLength();
705 0 : if( nCnt )
706 : {
707 0 : OUString s(CSTR_MACRO_TRUSTEDAUTHORS);
708 0 : s += "/a";
709 :
710 0 : Sequence< Sequence< com::sun::star::beans::PropertyValue > > lPropertyValuesSeq( nCnt );
711 0 : for( sal_Int32 i = 0 ; i < nCnt ; ++i )
712 : {
713 0 : OUString aPrefix = OUStringBuffer(s).append(i).append('/').makeStringAndClear();
714 0 : Sequence< com::sun::star::beans::PropertyValue > lPropertyValues( 3 );
715 0 : lPropertyValues[ 0 ].Name = aPrefix + PROPERTYNAME_TRUSTEDAUTHOR_SUBJECTNAME;
716 0 : lPropertyValues[ 0 ].Value <<= m_seqTrustedAuthors[ i ][0];
717 0 : lPropertyValues[ 1 ].Name = aPrefix + PROPERTYNAME_TRUSTEDAUTHOR_SERIALNUMBER;
718 0 : lPropertyValues[ 1 ].Value <<= m_seqTrustedAuthors[ i ][1];
719 0 : lPropertyValues[ 2 ].Name = aPrefix + PROPERTYNAME_TRUSTEDAUTHOR_RAWDATA;
720 0 : lPropertyValues[ 2 ].Value <<= m_seqTrustedAuthors[ i ][2];
721 :
722 :
723 0 : SetSetProperties( PROPERTYNAME_MACRO_TRUSTEDAUTHORS, lPropertyValues );
724 0 : }
725 :
726 0 : bDone = false; // because we save in loop above!
727 : }
728 : else
729 0 : bDone = false;
730 : }
731 : }
732 0 : break;
733 :
734 : case PROPERTYHANDLE_MACRO_DISABLE:
735 : {
736 0 : bDone = !m_bRODisableMacros;
737 0 : if( bDone )
738 0 : lValues[ nRealCount ] <<= (sal_Bool)m_bDisableMacros;
739 : }
740 0 : break;
741 :
742 :
743 : // xmlsec05 deprecated
744 : case PROPERTYHANDLE_STAROFFICEBASIC:
745 : {
746 0 : bDone = !m_bROBasicMode;
747 0 : if( bDone )
748 0 : lValues[ nRealCount ] <<= (sal_Int32)m_eBasicMode;
749 : }
750 0 : break;
751 : case PROPERTYHANDLE_EXECUTEPLUGINS:
752 : {
753 0 : bDone = !m_bROExecutePlugins;
754 0 : if( bDone )
755 0 : lValues[ nRealCount ] <<= m_bExecutePlugins;
756 : }
757 0 : break;
758 : case PROPERTYHANDLE_WARNINGENABLED:
759 : {
760 0 : bDone = !m_bROWarning;
761 0 : if( bDone )
762 0 : lValues[ nRealCount ] <<= m_bWarning;
763 : }
764 0 : break;
765 : case PROPERTYHANDLE_CONFIRMATIONENABLED:
766 : {
767 0 : bDone = !m_bROConfirmation;
768 0 : if( bDone )
769 0 : lValues[ nRealCount ] <<= m_bConfirmation;
770 : }
771 0 : break;
772 : // xmlsec05 deprecated
773 :
774 :
775 : default:
776 0 : bDone = false;
777 : }
778 :
779 0 : if( bDone )
780 : {
781 0 : lNames[ nRealCount ] = lOrgNames[ nProperty ];
782 0 : ++nRealCount;
783 : }
784 : }
785 : // Set properties in configuration.
786 0 : lNames.realloc(nRealCount);
787 0 : lValues.realloc(nRealCount);
788 0 : PutProperties( lNames, lValues );
789 0 : }
790 :
791 0 : sal_Bool SvtSecurityOptions_Impl::IsReadOnly( SvtSecurityOptions::EOption eOption ) const
792 : {
793 : sal_Bool bReadonly;
794 0 : switch(eOption)
795 : {
796 : case SvtSecurityOptions::E_SECUREURLS :
797 0 : bReadonly = m_bROSecureURLs;
798 0 : break;
799 : case SvtSecurityOptions::E_DOCWARN_SAVEORSEND:
800 0 : bReadonly = m_bROSaveOrSend;
801 0 : break;
802 : case SvtSecurityOptions::E_DOCWARN_SIGNING:
803 0 : bReadonly = m_bROSigning;
804 0 : break;
805 : case SvtSecurityOptions::E_DOCWARN_PRINT:
806 0 : bReadonly = m_bROPrint;
807 0 : break;
808 : case SvtSecurityOptions::E_DOCWARN_CREATEPDF:
809 0 : bReadonly = m_bROCreatePDF;
810 0 : break;
811 : case SvtSecurityOptions::E_DOCWARN_REMOVEPERSONALINFO:
812 0 : bReadonly = m_bRORemoveInfo;
813 0 : break;
814 : case SvtSecurityOptions::E_DOCWARN_RECOMMENDPASSWORD:
815 0 : bReadonly = m_bRORecommendPwd;
816 0 : break;
817 : case SvtSecurityOptions::E_MACRO_SECLEVEL:
818 0 : bReadonly = m_bROSecLevel;
819 0 : break;
820 : case SvtSecurityOptions::E_MACRO_TRUSTEDAUTHORS:
821 0 : bReadonly = m_bROTrustedAuthors;
822 0 : break;
823 : case SvtSecurityOptions::E_MACRO_DISABLE:
824 0 : bReadonly = m_bRODisableMacros;
825 0 : break;
826 : case SvtSecurityOptions::E_CTRLCLICK_HYPERLINK:
827 0 : bReadonly = m_bROCtrlClickHyperlink;
828 0 : break;
829 :
830 :
831 : // xmlsec05 deprecated
832 : case SvtSecurityOptions::E_BASICMODE:
833 0 : bReadonly = m_bROBasicMode;
834 0 : break;
835 : case SvtSecurityOptions::E_EXECUTEPLUGINS:
836 0 : bReadonly = m_bROExecutePlugins;
837 0 : break;
838 : case SvtSecurityOptions::E_WARNING:
839 0 : bReadonly = m_bROWarning;
840 0 : break;
841 : case SvtSecurityOptions::E_CONFIRMATION:
842 0 : bReadonly = m_bROConfirmation;
843 0 : break;
844 : // xmlsec05 deprecated
845 :
846 :
847 : default:
848 0 : bReadonly = sal_True;
849 : }
850 :
851 0 : return bReadonly;
852 : }
853 :
854 0 : Sequence< OUString > SvtSecurityOptions_Impl::GetSecureURLs() const
855 : {
856 0 : return m_seqSecureURLs;
857 : }
858 :
859 0 : void SvtSecurityOptions_Impl::SetSecureURLs( const Sequence< OUString >& seqURLList )
860 : {
861 : DBG_ASSERT(!m_bROSecureURLs, "SvtSecurityOptions_Impl::SetSecureURLs()\nYou tried to write on a readonly value!\n");
862 0 : if (!m_bROSecureURLs && m_seqSecureURLs!=seqURLList)
863 : {
864 0 : m_seqSecureURLs = seqURLList;
865 0 : SetModified();
866 : }
867 0 : }
868 :
869 0 : sal_Bool SvtSecurityOptions_Impl::IsSecureURL( const OUString& sURL ,
870 : const OUString& sReferer) const
871 : {
872 0 : sal_Bool bState = sal_False;
873 :
874 : // Check for uncritical protocols first
875 : // All protocols different from "macro..." and "slot..." are secure per definition and must not be checked.
876 : // "macro://#..." means AppBasic macros that are considered safe
877 0 : INetURLObject aURL ( sURL );
878 0 : INetProtocol aProtocol = aURL.GetProtocol();
879 :
880 : // All other URLs must checked in combination with referer and internal information about security
881 0 : if ( (aProtocol != INET_PROT_MACRO && aProtocol != INET_PROT_SLOT) ||
882 0 : aURL.GetMainURL( INetURLObject::NO_DECODE ).matchIgnoreAsciiCaseAsciiL( "macro:///", 9 ) == 0)
883 : {
884 : // security check only for "macro" ( without app basic ) or "slot" protocols
885 0 : bState = sal_True;
886 : }
887 : else
888 : {
889 : // check list of allowed URL patterns
890 : // Trusted referer given?
891 : // NO => bState will be false per default
892 : // YES => search for it in our internal url list
893 0 : if( !sReferer.isEmpty() )
894 : {
895 : // Search in internal list
896 0 : OUString sRef = sReferer.toAsciiLowerCase();
897 0 : sal_uInt32 nCount = m_seqSecureURLs.getLength();
898 0 : for( sal_uInt32 nItem=0; nItem<nCount; ++nItem )
899 : {
900 0 : OUString sCheckURL = m_seqSecureURLs[nItem].toAsciiLowerCase();
901 0 : sCheckURL += "*";
902 0 : if( WildCard( sCheckURL ).Matches( sRef ) == sal_True )
903 : {
904 0 : bState = sal_True;
905 0 : break;
906 : }
907 0 : }
908 :
909 0 : if ( !bState )
910 0 : bState = sRef.compareToAscii("private:user") == 0;
911 : }
912 : }
913 :
914 : // Return result of operation.
915 0 : return bState;
916 : }
917 :
918 0 : inline sal_Int32 SvtSecurityOptions_Impl::GetMacroSecurityLevel() const
919 : {
920 0 : return m_nSecLevel;
921 : }
922 :
923 1840 : inline sal_Bool SvtSecurityOptions_Impl::IsMacroDisabled() const
924 : {
925 1840 : return m_bDisableMacros;
926 : }
927 :
928 0 : void SvtSecurityOptions_Impl::SetMacroSecurityLevel( sal_Int32 _nLevel )
929 : {
930 0 : if( !m_bROSecLevel )
931 : {
932 0 : if( _nLevel > 3 || _nLevel < 0 )
933 0 : _nLevel = 3;
934 :
935 0 : if( m_nSecLevel != _nLevel )
936 : {
937 0 : m_nSecLevel = _nLevel;
938 0 : SetModified();
939 : }
940 : }
941 0 : }
942 :
943 0 : Sequence< SvtSecurityOptions::Certificate > SvtSecurityOptions_Impl::GetTrustedAuthors() const
944 : {
945 0 : return m_seqTrustedAuthors;
946 : }
947 :
948 0 : void SvtSecurityOptions_Impl::SetTrustedAuthors( const Sequence< SvtSecurityOptions::Certificate >& rAuthors )
949 : {
950 : DBG_ASSERT(!m_bROTrustedAuthors, "SvtSecurityOptions_Impl::SetTrustedAuthors()\nYou tried to write on a readonly value!\n");
951 0 : if( !m_bROTrustedAuthors && rAuthors != m_seqTrustedAuthors )
952 : {
953 0 : m_seqTrustedAuthors = rAuthors;
954 0 : SetModified();
955 : }
956 0 : }
957 :
958 280 : sal_Bool SvtSecurityOptions_Impl::IsOptionSet( SvtSecurityOptions::EOption eOption ) const
959 : {
960 : sal_Bool* pValue;
961 : sal_Bool* pRO;
962 280 : sal_Bool bRet = sal_False;
963 :
964 280 : if( ( const_cast< SvtSecurityOptions_Impl* >( this ) )->GetOption( eOption, pValue, pRO ) )
965 280 : bRet = *pValue;
966 :
967 280 : return bRet;
968 : }
969 :
970 0 : sal_Bool SvtSecurityOptions_Impl::SetOption( SvtSecurityOptions::EOption eOption, sal_Bool bValue )
971 : {
972 : sal_Bool* pValue;
973 : sal_Bool* pRO;
974 0 : sal_Bool bRet = sal_False;
975 :
976 0 : if( GetOption( eOption, pValue, pRO ) )
977 : {
978 0 : if( !*pRO )
979 : {
980 0 : bRet = sal_True;
981 0 : if( *pValue != bValue )
982 : {
983 0 : *pValue = bValue;
984 0 : SetModified();
985 : }
986 : }
987 : }
988 :
989 0 : return bRet;
990 : }
991 :
992 0 : sal_Bool SvtSecurityOptions_Impl::IsOptionEnabled( SvtSecurityOptions::EOption eOption ) const
993 : {
994 : sal_Bool* pValue;
995 : sal_Bool* pRO;
996 0 : sal_Bool bRet = sal_False;
997 :
998 0 : if( ( const_cast< SvtSecurityOptions_Impl* >( this ) )->GetOption( eOption, pValue, pRO ) )
999 0 : bRet = !*pRO;
1000 :
1001 0 : return bRet;
1002 : }
1003 :
1004 66 : Sequence< OUString > SvtSecurityOptions_Impl::GetPropertyNames()
1005 : {
1006 : // Build static list of configuration key names.
1007 : const OUString pProperties[] =
1008 : {
1009 : PROPERTYNAME_SECUREURL,
1010 : PROPERTYNAME_STAROFFICEBASIC,
1011 : PROPERTYNAME_EXECUTEPLUGINS,
1012 : PROPERTYNAME_WARNINGENABLED,
1013 : PROPERTYNAME_CONFIRMATIONENABLED,
1014 : PROPERTYNAME_DOCWARN_SAVEORSEND,
1015 : PROPERTYNAME_DOCWARN_SIGNING,
1016 : PROPERTYNAME_DOCWARN_PRINT,
1017 : PROPERTYNAME_DOCWARN_CREATEPDF,
1018 : PROPERTYNAME_DOCWARN_REMOVEPERSONALINFO,
1019 : PROPERTYNAME_DOCWARN_RECOMMENDPASSWORD,
1020 : PROPERTYNAME_CTRLCLICK_HYPERLINK,
1021 : PROPERTYNAME_MACRO_SECLEVEL,
1022 : PROPERTYNAME_MACRO_TRUSTEDAUTHORS,
1023 : PROPERTYNAME_MACRO_DISABLE
1024 1056 : };
1025 : // Initialize return sequence with these list ...
1026 66 : const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT );
1027 : // ... and return it.
1028 1056 : return seqPropertyNames;
1029 : }
1030 :
1031 : //*****************************************************************************************************************
1032 : // initialize static member
1033 : // DON'T DO IT IN YOUR HEADER!
1034 : // see definition for further information
1035 : //*****************************************************************************************************************
1036 : SvtSecurityOptions_Impl* SvtSecurityOptions::m_pDataContainer = NULL ;
1037 : sal_Int32 SvtSecurityOptions::m_nRefCount = 0 ;
1038 :
1039 2186 : SvtSecurityOptions::SvtSecurityOptions()
1040 : {
1041 : // Global access, must be guarded (multithreading!).
1042 2186 : MutexGuard aGuard( GetInitMutex() );
1043 : // Increase ouer refcount ...
1044 2186 : ++m_nRefCount;
1045 : // ... and initialize ouer data container only if it not already exist!
1046 2186 : if( m_pDataContainer == NULL )
1047 : {
1048 : RTL_LOGFILE_CONTEXT(aLog, "unotools ( ??? ) ::SvtSecurityOptions_Impl::ctor()");
1049 66 : m_pDataContainer = new SvtSecurityOptions_Impl;
1050 :
1051 66 : ItemHolder1::holdConfigItem(E_SECURITYOPTIONS);
1052 2186 : }
1053 2186 : }
1054 :
1055 4435 : SvtSecurityOptions::~SvtSecurityOptions()
1056 : {
1057 : // Global access, must be guarded (multithreading!)
1058 2185 : MutexGuard aGuard( GetInitMutex() );
1059 : // Decrease ouer refcount.
1060 2185 : --m_nRefCount;
1061 : // If last instance was deleted ...
1062 : // we must destroy ouer static data container!
1063 2185 : if( m_nRefCount <= 0 )
1064 : {
1065 65 : delete m_pDataContainer;
1066 65 : m_pDataContainer = NULL;
1067 2185 : }
1068 2250 : }
1069 :
1070 0 : sal_Bool SvtSecurityOptions::IsReadOnly( EOption eOption ) const
1071 : {
1072 0 : MutexGuard aGuard( GetInitMutex() );
1073 0 : return m_pDataContainer->IsReadOnly(eOption);
1074 : }
1075 :
1076 0 : Sequence< OUString > SvtSecurityOptions::GetSecureURLs() const
1077 : {
1078 0 : MutexGuard aGuard( GetInitMutex() );
1079 0 : return m_pDataContainer->GetSecureURLs();
1080 : }
1081 :
1082 0 : void SvtSecurityOptions::SetSecureURLs( const Sequence< OUString >& seqURLList )
1083 : {
1084 0 : MutexGuard aGuard( GetInitMutex() );
1085 0 : m_pDataContainer->SetSecureURLs( seqURLList );
1086 0 : }
1087 :
1088 0 : sal_Bool SvtSecurityOptions::IsSecureURL( const OUString& sURL ,
1089 : const OUString& sReferer ) const
1090 : {
1091 0 : MutexGuard aGuard( GetInitMutex() );
1092 0 : return m_pDataContainer->IsSecureURL( sURL, sReferer );
1093 : }
1094 :
1095 0 : sal_Int32 SvtSecurityOptions::GetMacroSecurityLevel() const
1096 : {
1097 0 : MutexGuard aGuard( GetInitMutex() );
1098 0 : return m_pDataContainer->GetMacroSecurityLevel();
1099 : }
1100 :
1101 0 : void SvtSecurityOptions::SetMacroSecurityLevel( sal_Int32 _nLevel )
1102 : {
1103 0 : MutexGuard aGuard( GetInitMutex() );
1104 0 : m_pDataContainer->SetMacroSecurityLevel( _nLevel );
1105 0 : }
1106 :
1107 1840 : sal_Bool SvtSecurityOptions::IsMacroDisabled() const
1108 : {
1109 1840 : MutexGuard aGuard( GetInitMutex() );
1110 1840 : return m_pDataContainer->IsMacroDisabled();
1111 : }
1112 :
1113 0 : Sequence< SvtSecurityOptions::Certificate > SvtSecurityOptions::GetTrustedAuthors() const
1114 : {
1115 0 : MutexGuard aGuard( GetInitMutex() );
1116 0 : return m_pDataContainer->GetTrustedAuthors();
1117 : }
1118 :
1119 0 : void SvtSecurityOptions::SetTrustedAuthors( const Sequence< Certificate >& rAuthors )
1120 : {
1121 0 : MutexGuard aGuard( GetInitMutex() );
1122 0 : m_pDataContainer->SetTrustedAuthors( rAuthors );
1123 0 : }
1124 :
1125 280 : bool SvtSecurityOptions::IsOptionSet( EOption eOption ) const
1126 : {
1127 280 : MutexGuard aGuard( GetInitMutex() );
1128 280 : return m_pDataContainer->IsOptionSet( eOption );
1129 : }
1130 :
1131 0 : bool SvtSecurityOptions::SetOption( EOption eOption, bool bValue )
1132 : {
1133 0 : MutexGuard aGuard( GetInitMutex() );
1134 0 : return m_pDataContainer->SetOption( eOption, bValue );
1135 : }
1136 :
1137 0 : bool SvtSecurityOptions::IsOptionEnabled( EOption eOption ) const
1138 : {
1139 0 : MutexGuard aGuard( GetInitMutex() );
1140 0 : return m_pDataContainer->IsOptionEnabled( eOption );
1141 : }
1142 :
1143 : namespace
1144 : {
1145 : class theSecurityOptionsMutex : public rtl::Static<osl::Mutex, theSecurityOptionsMutex>{};
1146 : }
1147 :
1148 6491 : Mutex& SvtSecurityOptions::GetInitMutex()
1149 : {
1150 6491 : return theSecurityOptionsMutex::get();
1151 : }
1152 :
1153 :
1154 :
1155 :
1156 : // xmlsec05 deprecated
1157 :
1158 0 : EBasicSecurityMode SvtSecurityOptions_Impl::GetBasicMode() const
1159 : {
1160 0 : return m_eBasicMode;
1161 : }
1162 :
1163 0 : void SvtSecurityOptions_Impl::SetBasicMode( EBasicSecurityMode eMode )
1164 : {
1165 : DBG_ASSERT(!m_bROBasicMode, "SvtSecurityOptions_Impl::SetBasicMode()\nYou tried to write on a readonly value!\n");
1166 0 : if (!m_bROBasicMode && m_eBasicMode!=eMode)
1167 : {
1168 0 : m_eBasicMode = eMode;
1169 0 : SetModified();
1170 : }
1171 0 : }
1172 :
1173 0 : sal_Bool SvtSecurityOptions_Impl::IsExecutePlugins() const
1174 : {
1175 0 : return m_bExecutePlugins;
1176 : }
1177 :
1178 0 : void SvtSecurityOptions_Impl::SetExecutePlugins( sal_Bool bSet )
1179 : {
1180 : DBG_ASSERT(!m_bROExecutePlugins, "SvtSecurityOptions_Impl::SetExecutePlugins()\nYou tried to write on a readonly value!\n");
1181 0 : if (!m_bROExecutePlugins && m_bExecutePlugins!=bSet)
1182 : {
1183 0 : m_bExecutePlugins = bSet;
1184 0 : SetModified();
1185 : }
1186 0 : }
1187 :
1188 0 : sal_Bool SvtSecurityOptions_Impl::IsWarningEnabled() const
1189 : {
1190 0 : return m_bWarning;
1191 : }
1192 :
1193 0 : void SvtSecurityOptions_Impl::SetWarningEnabled( sal_Bool bSet )
1194 : {
1195 : DBG_ASSERT(!m_bROWarning, "SvtSecurityOptions_Impl::SetWarningEnabled()\nYou tried to write on a readonly value!\n");
1196 0 : if (!m_bROWarning && m_bWarning!=bSet)
1197 : {
1198 0 : m_bWarning = bSet;
1199 0 : SetModified();
1200 : }
1201 0 : }
1202 :
1203 0 : sal_Bool SvtSecurityOptions_Impl::IsConfirmationEnabled() const
1204 : {
1205 0 : return m_bConfirmation;
1206 : }
1207 :
1208 0 : void SvtSecurityOptions_Impl::SetConfirmationEnabled( sal_Bool bSet )
1209 : {
1210 : DBG_ASSERT(!m_bROConfirmation, "SvtSecurityOptions_Impl::SetConfirmationEnabled()\nYou tried to write on a readonly value!\n");
1211 0 : if (!m_bROConfirmation && m_bConfirmation!=bSet)
1212 : {
1213 0 : m_bConfirmation = bSet;
1214 0 : SetModified();
1215 : }
1216 0 : }
1217 :
1218 :
1219 0 : sal_Bool SvtSecurityOptions::IsExecutePlugins() const
1220 : {
1221 0 : MutexGuard aGuard( GetInitMutex() );
1222 0 : return m_pDataContainer->IsExecutePlugins();
1223 : }
1224 :
1225 0 : void SvtSecurityOptions::SetExecutePlugins( sal_Bool bSet )
1226 : {
1227 0 : MutexGuard aGuard( GetInitMutex() );
1228 0 : m_pDataContainer->SetExecutePlugins( bSet );
1229 0 : }
1230 :
1231 0 : sal_Bool SvtSecurityOptions::IsWarningEnabled() const
1232 : {
1233 0 : MutexGuard aGuard( GetInitMutex() );
1234 0 : return m_pDataContainer->IsWarningEnabled();
1235 : }
1236 :
1237 0 : void SvtSecurityOptions::SetWarningEnabled( sal_Bool bSet )
1238 : {
1239 0 : MutexGuard aGuard( GetInitMutex() );
1240 0 : m_pDataContainer->SetWarningEnabled( bSet );
1241 0 : }
1242 :
1243 0 : sal_Bool SvtSecurityOptions::IsConfirmationEnabled() const
1244 : {
1245 0 : MutexGuard aGuard( GetInitMutex() );
1246 0 : return m_pDataContainer->IsConfirmationEnabled();
1247 : }
1248 :
1249 0 : void SvtSecurityOptions::SetConfirmationEnabled( sal_Bool bSet )
1250 : {
1251 0 : MutexGuard aGuard( GetInitMutex() );
1252 0 : m_pDataContainer->SetConfirmationEnabled( bSet );
1253 0 : }
1254 :
1255 0 : void SvtSecurityOptions::SetBasicMode( EBasicSecurityMode eMode )
1256 : {
1257 0 : MutexGuard aGuard( GetInitMutex() );
1258 0 : m_pDataContainer->SetBasicMode( eMode );
1259 0 : }
1260 :
1261 0 : EBasicSecurityMode SvtSecurityOptions::GetBasicMode() const
1262 : {
1263 0 : MutexGuard aGuard( GetInitMutex() );
1264 0 : return m_pDataContainer->GetBasicMode();
1265 : }
1266 :
1267 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|