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 _CPPUHELPER_ACCESS_CONTROL_HXX_ 24 #define _CPPUHELPER_ACCESS_CONTROL_HXX_ 25 26 #include <com/sun/star/uno/XComponentContext.hpp> 27 #include <com/sun/star/security/XAccessController.hpp> 28 29 #include "cppuhelper/cppuhelperdllapi.h" 30 31 32 namespace cppu 33 { 34 35 /** Helper class retriving access controller singleton from component context. 36 */ 37 class CPPUHELPER_DLLPUBLIC AccessControl 38 { 39 ::com::sun::star::uno::Reference< ::com::sun::star::security::XAccessController > m_xController; 40 41 public: 42 /** Ctor. 43 44 @param xContext component context to retrieve access controller singleton 45 */ 46 AccessControl( 47 ::com::sun::star::uno::Reference< 48 ::com::sun::star::uno::XComponentContext > const & xContext ); 49 /** Ctor. 50 51 @param xController access controller 52 */ 53 AccessControl( 54 ::com::sun::star::uno::Reference< 55 ::com::sun::star::security::XAccessController > const & xController ); 56 /** Copy ctor. 57 58 @param another object 59 */ 60 AccessControl( ::cppu::AccessControl const & ac ); 61 62 /** Clears the access controller reference being used. 63 */ clear()64 inline void SAL_CALL clear() SAL_THROW( () ) 65 { m_xController.clear(); } 66 67 /** Returns access to the access controller reference being used. 68 69 @return access controller 70 */ 71 inline ::com::sun::star::uno::Reference< get() const72 ::com::sun::star::security::XAccessController > const & SAL_CALL get() const SAL_THROW( () ) 73 { return m_xController; } 74 75 /** Returns access to the access controller reference being used. 76 77 @return access controller 78 */ operator ->() const79 inline ::com::sun::star::security::XAccessController * SAL_CALL operator -> () const SAL_THROW( () ) 80 { return m_xController.get(); } 81 82 83 /** A com.sun.star.security.RuntimePermission is for runtime permissions. 84 A RuntimePermission contains a name (also referred to as a "target name") but no 85 actions list; you either have the named permission or you don't. 86 87 @param name name of permission 88 */ 89 void SAL_CALL checkRuntimePermission( 90 ::rtl::OUString const & name ); 91 92 /** A com.sun.star.io.FilePermission represents access to a file or directory. 93 A FilePermission consists of a file url and a set of actions valid for that pathname. 94 95 @param url file url 96 @param actions actions list 97 */ 98 void SAL_CALL checkFilePermission( 99 ::rtl::OUString const & url, 100 ::rtl::OUString const & actions ); 101 102 /** A com.sun.star.connection.SocketPermission represents access to a network via sockets. 103 A SocketPermission consists of a host specification and a set of "actions" 104 specifying ways to connect to that host. 105 106 @param host host and optional portrange 107 @param actions actions list 108 */ 109 void SAL_CALL checkSocketPermission( 110 ::rtl::OUString const & host, 111 ::rtl::OUString const & actions ); 112 }; 113 114 } 115 116 #endif 117