merged tag LIBREOFFICE_3_2_99_3
[LibreOffice.git] / scripting / source / storage / ScriptSecurityManager.hxx
blob525d1a4eb8d9ef4e8c61559437c997e891153820
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #ifndef _FRAMEWORK_SCRIPT_SCRIPTSECURITYMANAGER_HXX_
31 #define _FRAMEWORK_SCRIPT_SCRIPTSECURITYMANAGER_HXX_
33 #include <hash_map>
34 #include <rtl/ustring.hxx>
35 #include <com/sun/star/uno/XComponentContext.hpp>
36 #include <com/sun/star/uno/RuntimeException.hpp>
37 #include <com/sun/star/lang/IllegalArgumentException.hpp>
38 #include <com/sun/star/security/AccessControlException.hpp>
39 #include <drafts/com/sun/star/script/framework/storage/XScriptInfo.hpp>
41 namespace scripting_securitymgr
43 // for simplification
44 #define css ::com::sun::star
45 #define dcsssf ::drafts::com::sun::star::script::framework
47 struct StoragePerm {
48 rtl::OUString scriptStorageURL;
49 sal_Int32 storageID;
50 sal_Bool execPermission;
53 typedef ::std::hash_map< ::rtl::OUString, StoragePerm, ::rtl::OUStringHash,
54 ::std::equal_to< ::rtl::OUString > > Permission_Hash;
55 /**
56 * Class responsible for managing the ScriptSecurity.
58 class ScriptSecurityManager
60 public:
61 explicit ScriptSecurityManager(
62 const css::uno::Reference< css::uno::XComponentContext > & xContext )
63 throw ( css::uno::RuntimeException );
64 ~ScriptSecurityManager();
65 void addScriptStorage( rtl::OUString scriptStorageURL, sal_Int32 storageID)
66 throw ( css::uno::RuntimeException );
67 /**
68 * checks to see if the requested permission can be granted
69 * checks to see whether the requested ScriptPeremission is allowed.
71 void checkPermission( const rtl::OUString & scriptStorageURL,
72 const rtl::OUString & permissionRequest )
73 throw ( css::uno::RuntimeException, css::lang::IllegalArgumentException,
74 css::security::AccessControlException );
75 void removePermissionSettings ( ::rtl::OUString & scriptStorageURL );
76 private:
77 void readConfiguration() throw (css::uno::RuntimeException);
79 short executeDialog ( const rtl::OUString & path )
80 throw (css::uno::RuntimeException);
81 short executeStandardDialog()
82 throw ( css::uno::RuntimeException );
83 short executePathDialog(const rtl::OUString & path)
84 throw ( css::uno::RuntimeException );
86 void addToSecurePaths ( const rtl::OUString & path )
87 throw (css::uno::RuntimeException);
88 bool isSecureURL( const rtl::OUString & path );
89 css::uno::Reference< css::uno::XComponentContext > m_xContext;
90 sal_Bool m_confirmationRequired;
91 sal_Bool m_warning;
92 sal_Int32 m_runMacroSetting;
93 css::uno::Reference< css::lang::XMultiServiceFactory > m_xConfigProvFactory;
94 css::uno::Sequence< rtl::OUString > m_secureURL;
95 Permission_Hash m_permissionSettings;
98 } // scripting_securitymgr
100 #endif //_FRAMEWORK_SCRIPT_SCRIPTSECURITYMANAGER_HXX_
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */