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