Update ooo320-m1
[ooovba.git] / scripting / source / storage / ScriptSecurityManager.hxx
blob22227204594de28b34e4d7adc0ba52fb217bf1aa
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ScriptSecurityManager.hxx,v $
10 * $Revision: 1.13 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 #ifndef _FRAMEWORK_SCRIPT_SCRIPTSECURITYMANAGER_HXX_
33 #define _FRAMEWORK_SCRIPT_SCRIPTSECURITYMANAGER_HXX_
35 #include <hash_map>
36 #include <rtl/ustring.hxx>
37 #include <com/sun/star/uno/XComponentContext.hpp>
38 #include <com/sun/star/uno/RuntimeException.hpp>
39 #include <com/sun/star/lang/IllegalArgumentException.hpp>
40 #include <com/sun/star/security/AccessControlException.hpp>
41 #include <drafts/com/sun/star/script/framework/storage/XScriptInfo.hpp>
43 namespace scripting_securitymgr
45 // for simplification
46 #define css ::com::sun::star
47 #define dcsssf ::drafts::com::sun::star::script::framework
49 struct StoragePerm {
50 rtl::OUString scriptStorageURL;
51 sal_Int32 storageID;
52 sal_Bool execPermission;
55 typedef ::std::hash_map< ::rtl::OUString, StoragePerm, ::rtl::OUStringHash,
56 ::std::equal_to< ::rtl::OUString > > Permission_Hash;
57 /**
58 * Class responsible for managing the ScriptSecurity.
60 class ScriptSecurityManager
62 public:
63 explicit ScriptSecurityManager(
64 const css::uno::Reference< css::uno::XComponentContext > & xContext )
65 throw ( css::uno::RuntimeException );
66 ~ScriptSecurityManager();
67 void addScriptStorage( rtl::OUString scriptStorageURL, sal_Int32 storageID)
68 throw ( css::uno::RuntimeException );
69 /**
70 * checks to see if the requested permission can be granted
71 * checks to see whether the requested ScriptPeremission is allowed.
73 void checkPermission( const rtl::OUString & scriptStorageURL,
74 const rtl::OUString & permissionRequest )
75 throw ( css::uno::RuntimeException, css::lang::IllegalArgumentException,
76 css::security::AccessControlException );
77 void removePermissionSettings ( ::rtl::OUString & scriptStorageURL );
78 private:
79 void readConfiguration() throw (css::uno::RuntimeException);
81 short executeDialog ( const rtl::OUString & path )
82 throw (css::uno::RuntimeException);
83 short executeStandardDialog()
84 throw ( css::uno::RuntimeException );
85 short executePathDialog(const rtl::OUString & path)
86 throw ( css::uno::RuntimeException );
88 void addToSecurePaths ( const rtl::OUString & path )
89 throw (css::uno::RuntimeException);
90 bool isSecureURL( const rtl::OUString & path );
91 css::uno::Reference< css::uno::XComponentContext > m_xContext;
92 sal_Bool m_confirmationRequired;
93 sal_Bool m_warning;
94 sal_Int32 m_runMacroSetting;
95 css::uno::Reference< css::lang::XMultiServiceFactory > m_xConfigProvFactory;
96 css::uno::Sequence< rtl::OUString > m_secureURL;
97 Permission_Hash m_permissionSettings;
100 } // scripting_securitymgr
102 #endif //_FRAMEWORK_SCRIPT_SCRIPTSECURITYMANAGER_HXX_