xref: /trunk/main/stoc/source/security/permissions.h (revision 2123d757)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _STOC_SEC_PERMISSIONS_H_
24 #define _STOC_SEC_PERMISSIONS_H_
25 
26 #include <rtl/unload.h>
27 #include <rtl/ref.hxx>
28 #include <rtl/ustring.hxx>
29 #include <salhelper/simplereferenceobject.hxx>
30 
31 #include <com/sun/star/uno/Any.hxx>
32 #include <com/sun/star/uno/Sequence.hxx>
33 #include <com/sun/star/uno/RuntimeException.hpp>
34 
35 extern ::rtl_StandardModuleCount g_moduleCount;
36 
37 namespace stoc_sec
38 {
39 //==================================================================================================
40 class Permission : public ::salhelper::SimpleReferenceObject
41 {
42 public:
43     ::rtl::Reference< Permission > m_next;
44     // mode
45     enum t_type { ALL, RUNTIME, SOCKET, FILE } m_type;
46 
Permission(t_type type,::rtl::Reference<Permission> const & next=::rtl::Reference<Permission> ())47     inline Permission(
48         t_type type,
49         ::rtl::Reference< Permission > const & next = ::rtl::Reference< Permission >() )
50         SAL_THROW( () )
51         : m_next( next )
52         , m_type( type )
53         {}
54 
55     virtual bool implies( Permission const & perm ) const SAL_THROW( () ) = 0;
56     virtual ::rtl::OUString toString() const SAL_THROW( () ) = 0;
57 };
58 //==================================================================================================
59 class AllPermission : public Permission
60 {
61 public:
62     inline AllPermission(
63         ::rtl::Reference< Permission > const & next = ::rtl::Reference< Permission >() )
64         SAL_THROW( () )
65         : Permission( ALL, next )
66         {}
67 
68     virtual bool implies( Permission const & ) const SAL_THROW( () );
69     virtual ::rtl::OUString toString() const SAL_THROW( () );
70 };
71 
72 //==================================================================================================
73 class PermissionCollection
74 {
75     ::rtl::Reference< Permission > m_head;
76 public:
77     inline PermissionCollection() SAL_THROW( () )
78         {}
79     inline PermissionCollection( PermissionCollection const & collection ) SAL_THROW( () )
80         : m_head( collection.m_head )
81         {}
82     inline PermissionCollection( ::rtl::Reference< Permission > const & single ) SAL_THROW( () )
83         : m_head( single )
84         {}
85     PermissionCollection(
86         ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > const & permissions,
87         PermissionCollection const & addition = PermissionCollection() )
88         SAL_THROW( (::com::sun::star::uno::RuntimeException) );
89 #ifdef __DIAGNOSE
90     ::com::sun::star::uno::Sequence< ::rtl::OUString > toStrings() const SAL_THROW( () );
91 #endif
92     void checkPermission( ::com::sun::star::uno::Any const & perm ) const
93         SAL_THROW( (::com::sun::star::uno::RuntimeException) );
94 };
95 
96 }
97 
98 #endif
99