1b5088357SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3b5088357SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4b5088357SAndrew Rist * or more contributor license agreements. See the NOTICE file 5b5088357SAndrew Rist * distributed with this work for additional information 6b5088357SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7b5088357SAndrew Rist * to you under the Apache License, Version 2.0 (the 8b5088357SAndrew Rist * "License"); you may not use this file except in compliance 9b5088357SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11b5088357SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13b5088357SAndrew Rist * Unless required by applicable law or agreed to in writing, 14b5088357SAndrew Rist * software distributed under the License is distributed on an 15b5088357SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16b5088357SAndrew Rist * KIND, either express or implied. See the License for the 17b5088357SAndrew Rist * specific language governing permissions and limitations 18b5088357SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20b5088357SAndrew Rist *************************************************************/ 21b5088357SAndrew Rist 22b5088357SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_unotools.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 28cdf0e10cSrcweir // includes 29cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <unotools/extendedsecurityoptions.hxx> 32cdf0e10cSrcweir #include <unotools/configmgr.hxx> 33cdf0e10cSrcweir #include <unotools/configitem.hxx> 34cdf0e10cSrcweir #include <tools/debug.hxx> 35cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx> 36cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx> 37cdf0e10cSrcweir #include <tools/urlobj.hxx> 38cdf0e10cSrcweir #include <tools/wldcrd.hxx> 39cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 40cdf0e10cSrcweir 41cdf0e10cSrcweir #include <unotools/pathoptions.hxx> 42cdf0e10cSrcweir 43cdf0e10cSrcweir #include <hash_map> 44cdf0e10cSrcweir 45cdf0e10cSrcweir #include <rtl/logfile.hxx> 46cdf0e10cSrcweir #include "itemholder1.hxx" 47cdf0e10cSrcweir 48cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 49cdf0e10cSrcweir // namespaces 50cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 51cdf0e10cSrcweir 52cdf0e10cSrcweir using namespace ::utl ; 53cdf0e10cSrcweir using namespace ::rtl ; 54cdf0e10cSrcweir using namespace ::osl ; 55cdf0e10cSrcweir using namespace ::com::sun::star::uno ; 56cdf0e10cSrcweir 57cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 58cdf0e10cSrcweir // const 59cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 60cdf0e10cSrcweir 61cdf0e10cSrcweir #define ROOTNODE_SECURITY OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Security")) 62cdf0e10cSrcweir 63cdf0e10cSrcweir #define SECURE_EXTENSIONS_SET OUString(RTL_CONSTASCII_USTRINGPARAM("SecureExtensions")) 64cdf0e10cSrcweir #define EXTENSION_PROPNAME OUString(RTL_CONSTASCII_USTRINGPARAM("/Extension")) 65cdf0e10cSrcweir 66cdf0e10cSrcweir #define PROPERTYNAME_HYPERLINKS_OPEN OUString(RTL_CONSTASCII_USTRINGPARAM("Hyperlinks/Open")) 67cdf0e10cSrcweir 68cdf0e10cSrcweir #define PROPERTYHANDLE_HYPERLINKS_OPEN 0 69cdf0e10cSrcweir 70cdf0e10cSrcweir #define PROPERTYCOUNT 1 71cdf0e10cSrcweir 72cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 73cdf0e10cSrcweir // private declarations! 74cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 75cdf0e10cSrcweir 76cdf0e10cSrcweir struct OUStringHashCode 77cdf0e10cSrcweir { 78cdf0e10cSrcweir size_t operator()( const ::rtl::OUString& sString ) const 79cdf0e10cSrcweir { 80cdf0e10cSrcweir return sString.hashCode(); 81cdf0e10cSrcweir } 82cdf0e10cSrcweir }; 83cdf0e10cSrcweir 84cdf0e10cSrcweir class ExtensionHashMap : public ::std::hash_map< ::rtl::OUString, 85cdf0e10cSrcweir sal_Int32, 86cdf0e10cSrcweir OUStringHashCode, 87cdf0e10cSrcweir ::std::equal_to< ::rtl::OUString > > 88cdf0e10cSrcweir { 89cdf0e10cSrcweir public: 90cdf0e10cSrcweir inline void free() 91cdf0e10cSrcweir { 92cdf0e10cSrcweir ExtensionHashMap().swap( *this ); 93cdf0e10cSrcweir } 94cdf0e10cSrcweir }; 95cdf0e10cSrcweir 96cdf0e10cSrcweir class SvtExtendedSecurityOptions_Impl : public ConfigItem 97cdf0e10cSrcweir { 98cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 99cdf0e10cSrcweir // public methods 100cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 101cdf0e10cSrcweir 102cdf0e10cSrcweir public: 103cdf0e10cSrcweir 104cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 105cdf0e10cSrcweir // constructor / destructor 106cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 107cdf0e10cSrcweir 108cdf0e10cSrcweir SvtExtendedSecurityOptions_Impl(); 109cdf0e10cSrcweir ~SvtExtendedSecurityOptions_Impl(); 110cdf0e10cSrcweir 111cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 112cdf0e10cSrcweir // overloaded methods of baseclass 113cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 114cdf0e10cSrcweir 115cdf0e10cSrcweir /*-****************************************************************************************************//** 116cdf0e10cSrcweir @short called for notify of configmanager 117cdf0e10cSrcweir @descr These method is called from the ConfigManager before application ends or from the 118cdf0e10cSrcweir PropertyChangeListener if the sub tree broadcasts changes. You must update your 119cdf0e10cSrcweir internal values. 120cdf0e10cSrcweir 121cdf0e10cSrcweir @seealso baseclass ConfigItem 122cdf0e10cSrcweir 123cdf0e10cSrcweir @param "seqPropertyNames" is the list of properties which should be updated. 124cdf0e10cSrcweir @return - 125cdf0e10cSrcweir 126cdf0e10cSrcweir @onerror - 127cdf0e10cSrcweir *//*-*****************************************************************************************************/ 128cdf0e10cSrcweir 129cdf0e10cSrcweir virtual void Notify( const Sequence< OUString >& seqPropertyNames ); 130cdf0e10cSrcweir 131cdf0e10cSrcweir /*-****************************************************************************************************//** 132cdf0e10cSrcweir @short write changes to configuration 133cdf0e10cSrcweir @descr These method writes the changed values into the sub tree 134cdf0e10cSrcweir and should always called in our destructor to guarantee consistency of config data. 135cdf0e10cSrcweir 136cdf0e10cSrcweir @seealso baseclass ConfigItem 137cdf0e10cSrcweir 138cdf0e10cSrcweir @param - 139cdf0e10cSrcweir @return - 140cdf0e10cSrcweir 141cdf0e10cSrcweir @onerror - 142cdf0e10cSrcweir *//*-*****************************************************************************************************/ 143cdf0e10cSrcweir 144cdf0e10cSrcweir virtual void Commit(); 145cdf0e10cSrcweir 146cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 147cdf0e10cSrcweir // public interface 148cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 149cdf0e10cSrcweir 150cdf0e10cSrcweir /*-****************************************************************************************************//** 151cdf0e10cSrcweir @short Access method to check for security problems 152cdf0e10cSrcweir @descr Different methods to check for security related problems. 153cdf0e10cSrcweir 154cdf0e10cSrcweir @seealso - 155cdf0e10cSrcweir 156cdf0e10cSrcweir @param - 157cdf0e10cSrcweir @return - 158cdf0e10cSrcweir 159cdf0e10cSrcweir @onerror - 160cdf0e10cSrcweir *//*-*****************************************************************************************************/ 161cdf0e10cSrcweir 162cdf0e10cSrcweir sal_Bool IsSecureHyperlink( const rtl::OUString& aURL ) const; 163cdf0e10cSrcweir Sequence< rtl::OUString > GetSecureExtensionList() const; 164cdf0e10cSrcweir 165cdf0e10cSrcweir SvtExtendedSecurityOptions::OpenHyperlinkMode GetOpenHyperlinkMode(); 166cdf0e10cSrcweir void SetOpenHyperlinkMode( SvtExtendedSecurityOptions::OpenHyperlinkMode aMode ); 167cdf0e10cSrcweir sal_Bool IsOpenHyperlinkModeReadOnly() const; 168cdf0e10cSrcweir 169cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 170cdf0e10cSrcweir // private methods 171cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 172cdf0e10cSrcweir 173cdf0e10cSrcweir private: 174cdf0e10cSrcweir 175cdf0e10cSrcweir /*-****************************************************************************************************//** 176*6b5a962bSmseidel @short return list of key names of our configuration management which represent our module tree 177cdf0e10cSrcweir @descr These methods return a static const list of key names. We need it to get needed values from our 178cdf0e10cSrcweir configuration management. 179cdf0e10cSrcweir 180cdf0e10cSrcweir @seealso - 181cdf0e10cSrcweir 182cdf0e10cSrcweir @param - 183cdf0e10cSrcweir @return A list of needed configuration keys is returned. 184cdf0e10cSrcweir 185cdf0e10cSrcweir @onerror - 186cdf0e10cSrcweir *//*-*****************************************************************************************************/ 187cdf0e10cSrcweir 188cdf0e10cSrcweir static Sequence< OUString > GetPropertyNames(); 189cdf0e10cSrcweir 190cdf0e10cSrcweir /*-****************************************************************************************************//** 191cdf0e10cSrcweir @short Fills the hash map with all extensions known to be secure 192cdf0e10cSrcweir @descr These methods fills the given hash map object with all extensions known to be secure. 193cdf0e10cSrcweir 194cdf0e10cSrcweir @seealso - 195cdf0e10cSrcweir 196cdf0e10cSrcweir @param aHashMap 197cdf0e10cSrcweir A hash map to be filled with secure extension strings. 198cdf0e10cSrcweir @return - 199cdf0e10cSrcweir 200cdf0e10cSrcweir @onerror - 201cdf0e10cSrcweir *//*-*****************************************************************************************************/ 202cdf0e10cSrcweir void FillExtensionHashMap( ExtensionHashMap& aHashMap ); 203cdf0e10cSrcweir 204cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 205cdf0e10cSrcweir // private member 206cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 207cdf0e10cSrcweir 208cdf0e10cSrcweir private: 209cdf0e10cSrcweir OUString m_aSecureExtensionsSetName; 210cdf0e10cSrcweir OUString m_aExtensionPropName; 211cdf0e10cSrcweir 212cdf0e10cSrcweir SvtExtendedSecurityOptions::OpenHyperlinkMode m_eOpenHyperlinkMode; 213cdf0e10cSrcweir sal_Bool m_bROOpenHyperlinkMode; 214cdf0e10cSrcweir ExtensionHashMap m_aExtensionHashMap; 215cdf0e10cSrcweir }; 216cdf0e10cSrcweir 217cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 218cdf0e10cSrcweir // definitions 219cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 220cdf0e10cSrcweir 221cdf0e10cSrcweir //***************************************************************************************************************** 222cdf0e10cSrcweir // constructor 223cdf0e10cSrcweir //***************************************************************************************************************** 224cdf0e10cSrcweir SvtExtendedSecurityOptions_Impl::SvtExtendedSecurityOptions_Impl() 225cdf0e10cSrcweir // Init baseclasses first 226cdf0e10cSrcweir : ConfigItem ( ROOTNODE_SECURITY ), 227cdf0e10cSrcweir m_aSecureExtensionsSetName( SECURE_EXTENSIONS_SET ), 228cdf0e10cSrcweir m_aExtensionPropName( EXTENSION_PROPNAME ), 229cdf0e10cSrcweir m_bROOpenHyperlinkMode(sal_False) 230cdf0e10cSrcweir // Init member then. 231cdf0e10cSrcweir { 232cdf0e10cSrcweir // Fill the extension hash map with all secure extension strings 233cdf0e10cSrcweir FillExtensionHashMap( m_aExtensionHashMap ); 234cdf0e10cSrcweir 235cdf0e10cSrcweir Sequence< OUString > seqNames = GetPropertyNames(); 236cdf0e10cSrcweir Sequence< Any > seqValues = GetProperties( seqNames ); 237cdf0e10cSrcweir Sequence< sal_Bool > seqRO = GetReadOnlyStates ( seqNames ); 238cdf0e10cSrcweir 239cdf0e10cSrcweir sal_Int32 nPropertyCount = seqValues.getLength(); 240cdf0e10cSrcweir for( sal_Int32 nProperty=0; nProperty<nPropertyCount; ++nProperty ) 241cdf0e10cSrcweir { 242cdf0e10cSrcweir // Safe impossible cases. 243cdf0e10cSrcweir // Check any for valid value. 244cdf0e10cSrcweir DBG_ASSERT( !(seqValues[nProperty].hasValue()==sal_False), "SvtExtendedSecurityOptions_Impl::SvtExtendedSecurityOptions_Impl()\nInvalid property value detected!\n" ); 245cdf0e10cSrcweir switch( nProperty ) 246cdf0e10cSrcweir { 247cdf0e10cSrcweir case PROPERTYHANDLE_HYPERLINKS_OPEN: 248cdf0e10cSrcweir { 249cdf0e10cSrcweir DBG_ASSERT( ( seqValues[nProperty].getValueTypeClass() == TypeClass_LONG ), "SvtExtendedSecurityOptions_Impl::SvtExtendedSecurityOptions_Impl()\nWho has changed the value type of 'Hyperlink/Open'?" ); 250cdf0e10cSrcweir 251cdf0e10cSrcweir sal_Int32 nMode = SvtExtendedSecurityOptions::OPEN_WITHSECURITYCHECK; 252cdf0e10cSrcweir if ( seqValues[nProperty] >>= nMode ) 253cdf0e10cSrcweir m_eOpenHyperlinkMode = (SvtExtendedSecurityOptions::OpenHyperlinkMode)nMode; 254cdf0e10cSrcweir else { 255cdf0e10cSrcweir DBG_ERROR("Wrong type for Open mode!"); 256cdf0e10cSrcweir } 257cdf0e10cSrcweir m_bROOpenHyperlinkMode = seqRO[nProperty]; 258cdf0e10cSrcweir } 259cdf0e10cSrcweir break; 260cdf0e10cSrcweir } 261cdf0e10cSrcweir } 262cdf0e10cSrcweir 263cdf0e10cSrcweir // Enable notification mechanism of our baseclass. 264*6b5a962bSmseidel // We need it to get information about changes outside these class on our used configuration keys! 265cdf0e10cSrcweir Sequence< OUString > seqNotifyNames( 1 ); 266cdf0e10cSrcweir seqNotifyNames[0] = m_aSecureExtensionsSetName; 267cdf0e10cSrcweir EnableNotification( seqNotifyNames ); 268cdf0e10cSrcweir } 269cdf0e10cSrcweir 270cdf0e10cSrcweir //***************************************************************************************************************** 271cdf0e10cSrcweir // destructor 272cdf0e10cSrcweir //***************************************************************************************************************** 273cdf0e10cSrcweir SvtExtendedSecurityOptions_Impl::~SvtExtendedSecurityOptions_Impl() 274cdf0e10cSrcweir { 275cdf0e10cSrcweir // We must save our current values .. if user forget it! 276cdf0e10cSrcweir if( IsModified() == sal_True ) 277cdf0e10cSrcweir { 278cdf0e10cSrcweir Commit(); 279cdf0e10cSrcweir } 280cdf0e10cSrcweir } 281cdf0e10cSrcweir 282cdf0e10cSrcweir //***************************************************************************************************************** 283cdf0e10cSrcweir // public method 284cdf0e10cSrcweir //***************************************************************************************************************** 285cdf0e10cSrcweir void SvtExtendedSecurityOptions_Impl::Notify( const Sequence< OUString >& ) 286cdf0e10cSrcweir { 287cdf0e10cSrcweir // Not implemented 288cdf0e10cSrcweir } 289cdf0e10cSrcweir 290cdf0e10cSrcweir //***************************************************************************************************************** 291cdf0e10cSrcweir // public method 292cdf0e10cSrcweir //***************************************************************************************************************** 293cdf0e10cSrcweir void SvtExtendedSecurityOptions_Impl::Commit() 294cdf0e10cSrcweir { 295cdf0e10cSrcweir // Get names of supported properties, create a list for values and copy current values to it. 296cdf0e10cSrcweir Sequence< OUString > seqNames = GetPropertyNames (); 297cdf0e10cSrcweir sal_Int32 nCount = seqNames.getLength(); 298cdf0e10cSrcweir Sequence< Any > seqValues ( nCount ); 299cdf0e10cSrcweir for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty ) 300cdf0e10cSrcweir { 301cdf0e10cSrcweir switch( nProperty ) 302cdf0e10cSrcweir { 303cdf0e10cSrcweir case PROPERTYHANDLE_HYPERLINKS_OPEN: { 304cdf0e10cSrcweir seqValues[nProperty] <<= (sal_Int32)m_eOpenHyperlinkMode; 305cdf0e10cSrcweir } 306cdf0e10cSrcweir break; 307cdf0e10cSrcweir } 308cdf0e10cSrcweir } 309cdf0e10cSrcweir 310cdf0e10cSrcweir // Set properties in configuration. 311cdf0e10cSrcweir PutProperties( seqNames, seqValues ); 312cdf0e10cSrcweir } 313cdf0e10cSrcweir 314cdf0e10cSrcweir //***************************************************************************************************************** 315cdf0e10cSrcweir // public method 316cdf0e10cSrcweir //***************************************************************************************************************** 317cdf0e10cSrcweir sal_Bool SvtExtendedSecurityOptions_Impl::IsSecureHyperlink( const OUString& aURL ) const 318cdf0e10cSrcweir { 319cdf0e10cSrcweir INetURLObject aURLObject( aURL ); 320cdf0e10cSrcweir 321cdf0e10cSrcweir String aExtension = aURLObject.getExtension(); 322cdf0e10cSrcweir aExtension.ToLowerAscii(); 323cdf0e10cSrcweir 324cdf0e10cSrcweir ExtensionHashMap::const_iterator pIter = m_aExtensionHashMap.find( aExtension ); 325cdf0e10cSrcweir if ( pIter != m_aExtensionHashMap.end() ) 326cdf0e10cSrcweir return sal_True; 327cdf0e10cSrcweir else 328cdf0e10cSrcweir return sal_False; 329cdf0e10cSrcweir } 330cdf0e10cSrcweir 331cdf0e10cSrcweir //***************************************************************************************************************** 332cdf0e10cSrcweir // public method 333cdf0e10cSrcweir //***************************************************************************************************************** 334cdf0e10cSrcweir Sequence< OUString > SvtExtendedSecurityOptions_Impl::GetSecureExtensionList() const 335cdf0e10cSrcweir { 336cdf0e10cSrcweir Sequence< OUString > aResult( m_aExtensionHashMap.size() ); 337cdf0e10cSrcweir 338cdf0e10cSrcweir sal_Int32 nIndex = 0; 339cdf0e10cSrcweir for ( ExtensionHashMap::const_iterator pIter = m_aExtensionHashMap.begin(); 340cdf0e10cSrcweir pIter != m_aExtensionHashMap.end(); pIter++ ) 341cdf0e10cSrcweir { 342cdf0e10cSrcweir aResult[nIndex++] = pIter->first; 343cdf0e10cSrcweir } 344cdf0e10cSrcweir 345cdf0e10cSrcweir return aResult; 346cdf0e10cSrcweir } 347cdf0e10cSrcweir 348cdf0e10cSrcweir //***************************************************************************************************************** 349cdf0e10cSrcweir // public method 350cdf0e10cSrcweir //***************************************************************************************************************** 351cdf0e10cSrcweir SvtExtendedSecurityOptions::OpenHyperlinkMode SvtExtendedSecurityOptions_Impl::GetOpenHyperlinkMode() 352cdf0e10cSrcweir { 353cdf0e10cSrcweir return m_eOpenHyperlinkMode; 354cdf0e10cSrcweir } 355cdf0e10cSrcweir /* -----------------09.07.2003 11:26----------------- 356cdf0e10cSrcweir 357cdf0e10cSrcweir --------------------------------------------------*/ 358cdf0e10cSrcweir sal_Bool SvtExtendedSecurityOptions_Impl::IsOpenHyperlinkModeReadOnly() const 359cdf0e10cSrcweir { 360cdf0e10cSrcweir return m_bROOpenHyperlinkMode; 361cdf0e10cSrcweir } 362cdf0e10cSrcweir 363cdf0e10cSrcweir //***************************************************************************************************************** 364cdf0e10cSrcweir // public method 365cdf0e10cSrcweir //***************************************************************************************************************** 366cdf0e10cSrcweir void SvtExtendedSecurityOptions_Impl::SetOpenHyperlinkMode( SvtExtendedSecurityOptions::OpenHyperlinkMode eNewMode ) 367cdf0e10cSrcweir { 368cdf0e10cSrcweir m_eOpenHyperlinkMode = eNewMode; 369cdf0e10cSrcweir SetModified(); 370cdf0e10cSrcweir } 371cdf0e10cSrcweir 372cdf0e10cSrcweir //***************************************************************************************************************** 373cdf0e10cSrcweir // private method 374cdf0e10cSrcweir //***************************************************************************************************************** 375cdf0e10cSrcweir void SvtExtendedSecurityOptions_Impl::FillExtensionHashMap( ExtensionHashMap& aHashMap ) 376cdf0e10cSrcweir { 377cdf0e10cSrcweir // Get sequence with secure extensions from configuration 378cdf0e10cSrcweir Sequence< OUString > seqNodes = GetNodeNames( m_aSecureExtensionsSetName ); 379cdf0e10cSrcweir 380cdf0e10cSrcweir OUString aValue; 381cdf0e10cSrcweir Sequence< Any > aValues; 382cdf0e10cSrcweir Sequence< OUString > aPropSeq( 1 ); 383cdf0e10cSrcweir for ( int i = 0; i < seqNodes.getLength(); i++ ) 384cdf0e10cSrcweir { 385cdf0e10cSrcweir // Create access name for property 386cdf0e10cSrcweir OUStringBuffer aExtEntryProp( m_aSecureExtensionsSetName ); 387cdf0e10cSrcweir aExtEntryProp.appendAscii( "/" ); 388cdf0e10cSrcweir aExtEntryProp.append( seqNodes[i] ); 389cdf0e10cSrcweir aExtEntryProp.append( m_aExtensionPropName ); 390cdf0e10cSrcweir 391cdf0e10cSrcweir aPropSeq[0] = aExtEntryProp.makeStringAndClear(); 392cdf0e10cSrcweir aValues = GetProperties( aPropSeq ); 393cdf0e10cSrcweir if ( aValues.getLength() == 1 ) 394cdf0e10cSrcweir { 395cdf0e10cSrcweir // Don't use value if sequence has not the correct length 396cdf0e10cSrcweir if ( aValues[0] >>= aValue ) 397cdf0e10cSrcweir // Add extension into secure extensions hash map 398cdf0e10cSrcweir aHashMap.insert( ExtensionHashMap::value_type( aValue.toAsciiLowerCase(), 1 ) ); 399cdf0e10cSrcweir else 400cdf0e10cSrcweir { 401cdf0e10cSrcweir DBG_ERRORFILE( "SvtExtendedSecurityOptions_Impl::FillExtensionHashMap(): not string value?" ); 402cdf0e10cSrcweir } 403cdf0e10cSrcweir } 404cdf0e10cSrcweir } 405cdf0e10cSrcweir } 406cdf0e10cSrcweir 407cdf0e10cSrcweir //***************************************************************************************************************** 408cdf0e10cSrcweir // private method (currently not used) 409cdf0e10cSrcweir //***************************************************************************************************************** 410cdf0e10cSrcweir Sequence< OUString > SvtExtendedSecurityOptions_Impl::GetPropertyNames() 411cdf0e10cSrcweir { 412cdf0e10cSrcweir // Build static list of configuration key names. 413cdf0e10cSrcweir static const OUString pProperties[] = 414cdf0e10cSrcweir { 415cdf0e10cSrcweir PROPERTYNAME_HYPERLINKS_OPEN 416cdf0e10cSrcweir }; 417cdf0e10cSrcweir // Initialize return sequence with these list ... 418cdf0e10cSrcweir static const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT ); 419cdf0e10cSrcweir // ... and return it. 420cdf0e10cSrcweir return seqPropertyNames; 421cdf0e10cSrcweir } 422cdf0e10cSrcweir 423cdf0e10cSrcweir //***************************************************************************************************************** 424cdf0e10cSrcweir // initialize static member 425cdf0e10cSrcweir // DON'T DO IT IN YOUR HEADER! 426cdf0e10cSrcweir // see definition for further informations 427cdf0e10cSrcweir //***************************************************************************************************************** 428cdf0e10cSrcweir SvtExtendedSecurityOptions_Impl* SvtExtendedSecurityOptions::m_pDataContainer = NULL ; 429cdf0e10cSrcweir sal_Int32 SvtExtendedSecurityOptions::m_nRefCount = 0 ; 430cdf0e10cSrcweir 431cdf0e10cSrcweir //***************************************************************************************************************** 432cdf0e10cSrcweir // constructor 433cdf0e10cSrcweir //***************************************************************************************************************** 434cdf0e10cSrcweir SvtExtendedSecurityOptions::SvtExtendedSecurityOptions() 435cdf0e10cSrcweir { 436cdf0e10cSrcweir // Global access, must be guarded (multithreading!). 437cdf0e10cSrcweir MutexGuard aGuard( GetInitMutex() ); 438*6b5a962bSmseidel // Increase our refcount ... 439cdf0e10cSrcweir ++m_nRefCount; 440*6b5a962bSmseidel // ... and initialize our data container only if it not already exist! 441cdf0e10cSrcweir if( m_pDataContainer == NULL ) 442cdf0e10cSrcweir { 443cdf0e10cSrcweir RTL_LOGFILE_CONTEXT(aLog, "unotools ( ??? ) ::SvtExtendedSecurityOptions_Impl::ctor()"); 444cdf0e10cSrcweir m_pDataContainer = new SvtExtendedSecurityOptions_Impl; 445cdf0e10cSrcweir 446cdf0e10cSrcweir ItemHolder1::holdConfigItem(E_EXTENDEDSECURITYOPTIONS); 447cdf0e10cSrcweir } 448cdf0e10cSrcweir } 449cdf0e10cSrcweir 450cdf0e10cSrcweir //***************************************************************************************************************** 451cdf0e10cSrcweir // destructor 452cdf0e10cSrcweir //***************************************************************************************************************** 453cdf0e10cSrcweir SvtExtendedSecurityOptions::~SvtExtendedSecurityOptions() 454cdf0e10cSrcweir { 455cdf0e10cSrcweir // Global access, must be guarded (multithreading!) 456cdf0e10cSrcweir MutexGuard aGuard( GetInitMutex() ); 457*6b5a962bSmseidel // Decrease our refcount. 458cdf0e10cSrcweir --m_nRefCount; 459cdf0e10cSrcweir // If last instance was deleted ... 460*6b5a962bSmseidel // we must destroy our static data container! 461cdf0e10cSrcweir if( m_nRefCount <= 0 ) 462cdf0e10cSrcweir { 463cdf0e10cSrcweir delete m_pDataContainer; 464cdf0e10cSrcweir m_pDataContainer = NULL; 465cdf0e10cSrcweir } 466cdf0e10cSrcweir } 467cdf0e10cSrcweir 468cdf0e10cSrcweir //***************************************************************************************************************** 469cdf0e10cSrcweir // public method 470cdf0e10cSrcweir //***************************************************************************************************************** 471cdf0e10cSrcweir sal_Bool SvtExtendedSecurityOptions::IsSecureHyperlink( const rtl::OUString& aURL ) const 472cdf0e10cSrcweir { 473cdf0e10cSrcweir MutexGuard aGuard( GetInitMutex() ); 474cdf0e10cSrcweir return m_pDataContainer->IsSecureHyperlink( aURL ); 475cdf0e10cSrcweir } 476cdf0e10cSrcweir 477cdf0e10cSrcweir //***************************************************************************************************************** 478cdf0e10cSrcweir // public method 479cdf0e10cSrcweir //***************************************************************************************************************** 480cdf0e10cSrcweir Sequence< rtl::OUString > SvtExtendedSecurityOptions::GetSecureExtensionList() const 481cdf0e10cSrcweir { 482cdf0e10cSrcweir MutexGuard aGuard( GetInitMutex() ); 483cdf0e10cSrcweir return m_pDataContainer->GetSecureExtensionList(); 484cdf0e10cSrcweir } 485cdf0e10cSrcweir 486cdf0e10cSrcweir //***************************************************************************************************************** 487cdf0e10cSrcweir // public method 488cdf0e10cSrcweir //***************************************************************************************************************** 489cdf0e10cSrcweir SvtExtendedSecurityOptions::OpenHyperlinkMode SvtExtendedSecurityOptions::GetOpenHyperlinkMode() 490cdf0e10cSrcweir { 491cdf0e10cSrcweir MutexGuard aGuard( GetInitMutex() ); 492cdf0e10cSrcweir return m_pDataContainer->GetOpenHyperlinkMode(); 493cdf0e10cSrcweir } 494cdf0e10cSrcweir /* -----------------09.07.2003 11:26----------------- 495cdf0e10cSrcweir 496cdf0e10cSrcweir --------------------------------------------------*/ 497cdf0e10cSrcweir sal_Bool SvtExtendedSecurityOptions::IsOpenHyperlinkModeReadOnly() const 498cdf0e10cSrcweir { 499cdf0e10cSrcweir return m_pDataContainer->IsOpenHyperlinkModeReadOnly(); 500cdf0e10cSrcweir } 501cdf0e10cSrcweir 502cdf0e10cSrcweir //***************************************************************************************************************** 503cdf0e10cSrcweir // public method 504cdf0e10cSrcweir //***************************************************************************************************************** 505cdf0e10cSrcweir void SvtExtendedSecurityOptions::SetOpenHyperlinkMode( SvtExtendedSecurityOptions::OpenHyperlinkMode eMode ) 506cdf0e10cSrcweir { 507cdf0e10cSrcweir MutexGuard aGuard( GetInitMutex() ); 508cdf0e10cSrcweir m_pDataContainer->SetOpenHyperlinkMode( eMode ); 509cdf0e10cSrcweir } 510cdf0e10cSrcweir 511cdf0e10cSrcweir //***************************************************************************************************************** 512cdf0e10cSrcweir // private method 513cdf0e10cSrcweir //***************************************************************************************************************** 514cdf0e10cSrcweir Mutex& SvtExtendedSecurityOptions::GetInitMutex() 515cdf0e10cSrcweir { 516cdf0e10cSrcweir // Initialize static mutex only for one time! 517cdf0e10cSrcweir static Mutex* pMutex = NULL; 518cdf0e10cSrcweir // If these method first called (Mutex not already exist!) ... 519cdf0e10cSrcweir if( pMutex == NULL ) 520cdf0e10cSrcweir { 521cdf0e10cSrcweir // ... we must create a new one. Protect follow code with the global mutex - 522cdf0e10cSrcweir // It must be - we create a static variable! 523cdf0e10cSrcweir MutexGuard aGuard( Mutex::getGlobalMutex() ); 524*6b5a962bSmseidel // We must check our pointer again - because it can be that another instance of our class will be faster than these! 525cdf0e10cSrcweir if( pMutex == NULL ) 526cdf0e10cSrcweir { 527cdf0e10cSrcweir // Create the new mutex and set it for return on static variable. 528cdf0e10cSrcweir static Mutex aMutex; 529cdf0e10cSrcweir pMutex = &aMutex; 530cdf0e10cSrcweir } 531cdf0e10cSrcweir } 532cdf0e10cSrcweir // Return new created or already existing mutex object. 533cdf0e10cSrcweir return *pMutex; 534cdf0e10cSrcweir } 535