xref: /trunk/main/stoc/source/security/permissions.h (revision cdf0e10c)
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 #ifndef _STOC_SEC_PERMISSIONS_H_
28 #define _STOC_SEC_PERMISSIONS_H_
29 
30 #include <rtl/unload.h>
31 #include <rtl/ref.hxx>
32 #include <rtl/ustring.hxx>
33 #include <salhelper/simplereferenceobject.hxx>
34 
35 #include <com/sun/star/uno/Any.hxx>
36 #include <com/sun/star/uno/Sequence.hxx>
37 #include <com/sun/star/uno/RuntimeException.hpp>
38 
39 extern ::rtl_StandardModuleCount g_moduleCount;
40 
41 namespace stoc_sec
42 {
43 //==================================================================================================
44 class Permission : public ::salhelper::SimpleReferenceObject
45 {
46 public:
47     ::rtl::Reference< Permission > m_next;
48     // mode
49     enum t_type { ALL, RUNTIME, SOCKET, FILE } m_type;
50 
51     inline Permission(
52         t_type type,
53         ::rtl::Reference< Permission > const & next = ::rtl::Reference< Permission >() )
54         SAL_THROW( () )
55         : m_next( next )
56         , m_type( type )
57         {}
58 
59     virtual bool implies( Permission const & perm ) const SAL_THROW( () ) = 0;
60     virtual ::rtl::OUString toString() const SAL_THROW( () ) = 0;
61 };
62 //==================================================================================================
63 class AllPermission : public Permission
64 {
65 public:
66     inline AllPermission(
67         ::rtl::Reference< Permission > const & next = ::rtl::Reference< Permission >() )
68         SAL_THROW( () )
69         : Permission( ALL, next )
70         {}
71 
72     virtual bool implies( Permission const & ) const SAL_THROW( () );
73     virtual ::rtl::OUString toString() const SAL_THROW( () );
74 };
75 
76 //==================================================================================================
77 class PermissionCollection
78 {
79     ::rtl::Reference< Permission > m_head;
80 public:
81     inline PermissionCollection() SAL_THROW( () )
82         {}
83     inline PermissionCollection( PermissionCollection const & collection ) SAL_THROW( () )
84         : m_head( collection.m_head )
85         {}
86     inline PermissionCollection( ::rtl::Reference< Permission > const & single ) SAL_THROW( () )
87         : m_head( single )
88         {}
89     PermissionCollection(
90         ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > const & permissions,
91         PermissionCollection const & addition = PermissionCollection() )
92         SAL_THROW( (::com::sun::star::uno::RuntimeException) );
93 #ifdef __DIAGNOSE
94     ::com::sun::star::uno::Sequence< ::rtl::OUString > toStrings() const SAL_THROW( () );
95 #endif
96     void checkPermission( ::com::sun::star::uno::Any const & perm ) const
97         SAL_THROW( (::com::sun::star::uno::RuntimeException) );
98 };
99 
100 }
101 
102 #endif
103