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