1*6998d047SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*6998d047SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*6998d047SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*6998d047SAndrew Rist * distributed with this work for additional information 6*6998d047SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*6998d047SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*6998d047SAndrew Rist * "License"); you may not use this file except in compliance 9*6998d047SAndrew Rist * with the License. You may obtain a copy of the License at 10*6998d047SAndrew Rist * 11*6998d047SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*6998d047SAndrew Rist * 13*6998d047SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*6998d047SAndrew Rist * software distributed under the License is distributed on an 15*6998d047SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*6998d047SAndrew Rist * KIND, either express or implied. See the License for the 17*6998d047SAndrew Rist * specific language governing permissions and limitations 18*6998d047SAndrew Rist * under the License. 19*6998d047SAndrew Rist * 20*6998d047SAndrew Rist *************************************************************/ 21*6998d047SAndrew Rist 22*6998d047SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir 25cdf0e10cSrcweir #ifndef _FRAMEWORK_SCRIPT_SCRIPTSECURITYMANAGER_HXX_ 26cdf0e10cSrcweir #define _FRAMEWORK_SCRIPT_SCRIPTSECURITYMANAGER_HXX_ 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include <hash_map> 29cdf0e10cSrcweir #include <rtl/ustring.hxx> 30cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp> 31cdf0e10cSrcweir #include <com/sun/star/uno/RuntimeException.hpp> 32cdf0e10cSrcweir #include <com/sun/star/lang/IllegalArgumentException.hpp> 33cdf0e10cSrcweir #include <com/sun/star/security/AccessControlException.hpp> 34cdf0e10cSrcweir #include <drafts/com/sun/star/script/framework/storage/XScriptInfo.hpp> 35cdf0e10cSrcweir 36cdf0e10cSrcweir namespace scripting_securitymgr 37cdf0e10cSrcweir { 38cdf0e10cSrcweir // for simplification 39cdf0e10cSrcweir #define css ::com::sun::star 40cdf0e10cSrcweir #define dcsssf ::drafts::com::sun::star::script::framework 41cdf0e10cSrcweir 42cdf0e10cSrcweir struct StoragePerm { 43cdf0e10cSrcweir rtl::OUString scriptStorageURL; 44cdf0e10cSrcweir sal_Int32 storageID; 45cdf0e10cSrcweir sal_Bool execPermission; 46cdf0e10cSrcweir }; 47cdf0e10cSrcweir 48cdf0e10cSrcweir typedef ::std::hash_map< ::rtl::OUString, StoragePerm, ::rtl::OUStringHash, 49cdf0e10cSrcweir ::std::equal_to< ::rtl::OUString > > Permission_Hash; 50cdf0e10cSrcweir /** 51cdf0e10cSrcweir * Class responsible for managing the ScriptSecurity. 52cdf0e10cSrcweir */ 53cdf0e10cSrcweir class ScriptSecurityManager 54cdf0e10cSrcweir { 55cdf0e10cSrcweir public: 56cdf0e10cSrcweir explicit ScriptSecurityManager( 57cdf0e10cSrcweir const css::uno::Reference< css::uno::XComponentContext > & xContext ) 58cdf0e10cSrcweir throw ( css::uno::RuntimeException ); 59cdf0e10cSrcweir ~ScriptSecurityManager(); 60cdf0e10cSrcweir void addScriptStorage( rtl::OUString scriptStorageURL, sal_Int32 storageID) 61cdf0e10cSrcweir throw ( css::uno::RuntimeException ); 62cdf0e10cSrcweir /** 63cdf0e10cSrcweir * checks to see if the requested permission can be granted 64cdf0e10cSrcweir * checks to see whether the requested ScriptPeremission is allowed. 65cdf0e10cSrcweir */ 66cdf0e10cSrcweir void checkPermission( const rtl::OUString & scriptStorageURL, 67cdf0e10cSrcweir const rtl::OUString & permissionRequest ) 68cdf0e10cSrcweir throw ( css::uno::RuntimeException, css::lang::IllegalArgumentException, 69cdf0e10cSrcweir css::security::AccessControlException ); 70cdf0e10cSrcweir void removePermissionSettings ( ::rtl::OUString & scriptStorageURL ); 71cdf0e10cSrcweir private: 72cdf0e10cSrcweir void readConfiguration() throw (css::uno::RuntimeException); 73cdf0e10cSrcweir 74cdf0e10cSrcweir short executeDialog ( const rtl::OUString & path ) 75cdf0e10cSrcweir throw (css::uno::RuntimeException); 76cdf0e10cSrcweir short executeStandardDialog() 77cdf0e10cSrcweir throw ( css::uno::RuntimeException ); 78cdf0e10cSrcweir short executePathDialog(const rtl::OUString & path) 79cdf0e10cSrcweir throw ( css::uno::RuntimeException ); 80cdf0e10cSrcweir 81cdf0e10cSrcweir void addToSecurePaths ( const rtl::OUString & path ) 82cdf0e10cSrcweir throw (css::uno::RuntimeException); 83cdf0e10cSrcweir bool isSecureURL( const rtl::OUString & path ); 84cdf0e10cSrcweir css::uno::Reference< css::uno::XComponentContext > m_xContext; 85cdf0e10cSrcweir sal_Bool m_confirmationRequired; 86cdf0e10cSrcweir sal_Bool m_warning; 87cdf0e10cSrcweir sal_Int32 m_runMacroSetting; 88cdf0e10cSrcweir css::uno::Reference< css::lang::XMultiServiceFactory > m_xConfigProvFactory; 89cdf0e10cSrcweir css::uno::Sequence< rtl::OUString > m_secureURL; 90cdf0e10cSrcweir Permission_Hash m_permissionSettings; 91cdf0e10cSrcweir 92cdf0e10cSrcweir }; 93cdf0e10cSrcweir } // scripting_securitymgr 94cdf0e10cSrcweir 95cdf0e10cSrcweir #endif //_FRAMEWORK_SCRIPT_SCRIPTSECURITYMANAGER_HXX_ 96