diff options
author | Daniel Boelzle <dbo@openoffice.org> | 2002-01-11 09:06:02 +0000 |
---|---|---|
committer | Daniel Boelzle <dbo@openoffice.org> | 2002-01-11 09:06:02 +0000 |
commit | 6c2d3c98609e7ffa944b3f5289ffadc47d2637a9 (patch) | |
tree | aab53b5a9cd7fc72a3ae260ab830a092c8e6627a /cppuhelper | |
parent | 875da5e1130830a8602be2ca85bfa739f459ff4d (diff) |
#88919# ac implementation and bootstrapping
Diffstat (limited to 'cppuhelper')
-rwxr-xr-x | cppuhelper/inc/cppuhelper/access_control.hxx | 247 | ||||
-rw-r--r-- | cppuhelper/source/access_control.cxx | 136 | ||||
-rw-r--r-- | cppuhelper/source/bootstrap.cxx | 56 | ||||
-rw-r--r-- | cppuhelper/source/makefile.mk | 9 | ||||
-rw-r--r-- | cppuhelper/source/msvc_win32_intel.map | 7 | ||||
-rw-r--r-- | cppuhelper/source/servicefactory.cxx | 66 |
6 files changed, 314 insertions, 207 deletions
diff --git a/cppuhelper/inc/cppuhelper/access_control.hxx b/cppuhelper/inc/cppuhelper/access_control.hxx index 6fa97ac84965..34b90b784087 100755 --- a/cppuhelper/inc/cppuhelper/access_control.hxx +++ b/cppuhelper/inc/cppuhelper/access_control.hxx @@ -2,9 +2,9 @@ * * $RCSfile: access_control.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: dbo $ $Date: 2001-12-17 14:37:52 $ + * last change: $Author: dbo $ $Date: 2002-01-11 10:06:02 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -58,12 +58,18 @@ * * ************************************************************************/ -#ifndef _CPPUHELPER_SECURITY_HXX_ -#define _CPPUHELPER_SECURITY_HXX_ +#ifndef _CPPUHELPER_ACCESS_CONTROL_HXX_ +#define _CPPUHELPER_ACCESS_CONTROL_HXX_ -#include <osl/diagnose.h> +#ifndef _COM_SUN_STAR_UNO_XCURRENTCONTEXT_HPP_ +#include <com/sun/star/uno/XCurrentContext.hpp> +#endif +#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_ #include <com/sun/star/uno/XComponentContext.hpp> +#endif +#ifndef _COM_SUN_STAR_SECURITY_XACCESSCONTROLLER_HPP_ #include <com/sun/star/security/XAccessController.hpp> +#endif #define AC_SINGLETON "/singletons/com.sun.star.security.theAccessController" @@ -71,169 +77,122 @@ namespace cppu { -//================================================================================================== +/** Helper class retriving access controller singleton from component context. +*/ class AccessControl { ::com::sun::star::uno::Reference< ::com::sun::star::security::XAccessController > m_xController; -#ifdef SAL_W32 -#pragma pack(push, 8) -#endif - // binary comp. version of Permission - struct __permission - { - rtl_uString * m_permType; - rtl_uString * m_permTarget; - rtl_uString * m_permActions; - }; -#ifdef SAL_W32 -#pragma pack(pop) -#endif - public: - inline AccessControl( - ::com::sun::star::uno::Reference< - ::com::sun::star::security::XAccessController > const & xController ) - SAL_THROW( () ); - inline AccessControl( + /** Ctor. + + @param xContext component context to retrieve access controller singleton + */ + AccessControl( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext ) SAL_THROW( (::com::sun::star::uno::RuntimeException) ); + /** Ctor. + + @param xController access controller + */ + AccessControl( + ::com::sun::star::uno::Reference< + ::com::sun::star::security::XAccessController > const & xController ) + SAL_THROW( (::com::sun::star::uno::RuntimeException) ); + /** Copy ctor. - // checkPermission() - inline void SAL_CALL checkPermission( - ::com::sun::star::security::Permission const & perm ) + @param another object + */ + AccessControl( ::cppu::AccessControl const & ac ) SAL_THROW( (::com::sun::star::uno::RuntimeException) ); - inline void SAL_CALL checkPermission( - ::rtl::OUString const & permType, - ::rtl::OUString const & permTarget, - ::rtl::OUString const & permActions ) + + /** Returns access to the access controller reference being used. + + @return access controller + */ + inline ::com::sun::star::uno::Reference< ::com::sun::star::security::XAccessController > const & + get() SAL_THROW( () ) + { return m_xController; } + + + /** A com.sun.star.security.RuntimePermission is for runtime permissions. + A RuntimePermission contains a name (also referred to as a "target name") but no + actions list; you either have the named permission or you don't. + + @param name name of permission + */ + void SAL_CALL checkRuntimePermission( + ::rtl::OUString const & name ) SAL_THROW( (::com::sun::star::uno::RuntimeException) ); - inline void SAL_CALL checkFilePermission( - ::rtl::OUString const & permTarget, - ::rtl::OUString const & permActions ) + /** A com.sun.star.io.FilePermission represents access to a file or directory. + A FilePermission consists of a file url and a set of actions valid for that pathname. + + @param url file url + @param actions actions list + */ + void SAL_CALL checkFilePermission( + ::rtl::OUString const & url, + ::rtl::OUString const & actions ) SAL_THROW( (::com::sun::star::uno::RuntimeException) ); - // doRestricted() - inline ::com::sun::star::uno::Any SAL_CALL doRestricted( - ::com::sun::star::uno::Reference< - ::com::sun::star::security::XAction > const & xAction, - ::com::sun::star::uno::Reference< - ::com::sun::star::security::XAccessControlContext > const & xRestriction ) - SAL_THROW( (::com::sun::star::uno::Exception) ); - // doPrivileged() - inline ::com::sun::star::uno::Any SAL_CALL doPrivileged( - ::com::sun::star::uno::Reference< - ::com::sun::star::security::XAction > const & xAction, - ::com::sun::star::uno::Reference< - ::com::sun::star::security::XAccessControlContext > const & xRestriction ) - SAL_THROW( (::com::sun::star::uno::Exception) ); - // getContext() - inline ::com::sun::star::uno::Reference< - ::com::sun::star::security::XAccessControlContext > SAL_CALL getContext() + /** A com.sun.star.connection.SocketPermission represents access to a network via sockets. + A SocketPermission consists of a host specification and a set of "actions" + specifying ways to connect to that host. + + @param host host and optional portrange + @param actions actions list + */ + void SAL_CALL checkSocketPermission( + ::rtl::OUString const & host, + ::rtl::OUString const & actions ) SAL_THROW( (::com::sun::star::uno::RuntimeException) ); }; -//__________________________________________________________________________________________________ -inline AccessControl::AccessControl( - ::com::sun::star::uno::Reference< - ::com::sun::star::security::XAccessController > const & xController ) - SAL_THROW( () ) - : m_xController( xController ) -{ -} -//__________________________________________________________________________________________________ -inline AccessControl::AccessControl( + + +/** Default implementation retieving the current access control restriction. + + @param xCurrentContext current context + @return current access control restriction +*/ +::com::sun::star::uno::Reference< ::com::sun::star::security::XAccessControlContext > SAL_CALL +ac_defimpl_getRestriction( ::com::sun::star::uno::Reference< - ::com::sun::star::uno::XComponentContext > const & xContext ) - SAL_THROW( (::com::sun::star::uno::RuntimeException) ) -{ - xContext->getValueByName( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(AC_SINGLETON) ) ) >>= m_xController; -} -//__________________________________________________________________________________________________ -inline void AccessControl::checkPermission( - ::com::sun::star::security::Permission const & perm ) - SAL_THROW( (::com::sun::star::uno::RuntimeException) ) -{ - if (m_xController.is()) - { - m_xController->checkPermission( perm ); - } -} -//__________________________________________________________________________________________________ -inline void AccessControl::checkPermission( - ::rtl::OUString const & permType, - ::rtl::OUString const & permTarget, - ::rtl::OUString const & permActions ) - SAL_THROW( (::com::sun::star::uno::RuntimeException) ) -{ - __permission perm; - perm.m_permType = permType.pData; - perm.m_permTarget = permTarget.pData; - perm.m_permActions = permActions.pData; - checkPermission( - * reinterpret_cast< ::com::sun::star::security::Permission const * >( &perm ) ); -} -//__________________________________________________________________________________________________ -inline void AccessControl::checkFilePermission( - ::rtl::OUString const & permTarget, - ::rtl::OUString const & permActions ) - SAL_THROW( (::com::sun::star::uno::RuntimeException) ) -{ - ::rtl::OUString permType( RTL_CONSTASCII_USTRINGPARAM("java.io.FilePermission") ); - checkPermission( permType, permTarget, permActions ); -} + ::com::sun::star::uno::XCurrentContext > const & xCurrentContext ) + SAL_THROW( (::com::sun::star::uno::RuntimeException) ); -//__________________________________________________________________________________________________ -inline ::com::sun::star::uno::Any AccessControl::doRestricted( +/** Default implementation performing a restricted action. + + @param xAction action to be performed + @param xRestriction additional restriction to be in effect + @param xCurrentContext current context +*/ +::com::sun::star::uno::Any SAL_CALL +ac_defimpl_doRestricted( ::com::sun::star::uno::Reference< ::com::sun::star::security::XAction > const & xAction, ::com::sun::star::uno::Reference< - ::com::sun::star::security::XAccessControlContext > const & xRestriction ) - SAL_THROW( (::com::sun::star::uno::Exception) ) -{ - if (m_xController.is()) - { - return m_xController->doRestricted( xAction, xRestriction ); - } - else - { - return xAction->run(); - } -} -//__________________________________________________________________________________________________ -inline ::com::sun::star::uno::Any AccessControl::doPrivileged( + ::com::sun::star::security::XAccessControlContext > const & xRestriction, + ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XCurrentContext > const & xCurrentContext ) + SAL_THROW( (::com::sun::star::uno::Exception) ); + +/** Default implementation performed a privileged action. + + @param xAction action to be performed + @param xRestriction (the one and only) restriction to be in effect + @param xCurrentContext current context +*/ +::com::sun::star::uno::Any SAL_CALL +ac_defimpl_doPrivileged( ::com::sun::star::uno::Reference< ::com::sun::star::security::XAction > const & xAction, ::com::sun::star::uno::Reference< - ::com::sun::star::security::XAccessControlContext > const & xRestriction ) - SAL_THROW( (::com::sun::star::uno::Exception) ) -{ - if (m_xController.is()) - { - return m_xController->doPrivileged( xAction, xRestriction ); - } - else - { - return xAction->run(); - } -} -//__________________________________________________________________________________________________ -inline ::com::sun::star::uno::Reference< - ::com::sun::star::security::XAccessControlContext > AccessControl::getContext() - SAL_THROW( (::com::sun::star::uno::RuntimeException) ) -{ - if (m_xController.is()) - { - return m_xController->getContext(); - } - else - { - return ::com::sun::star::uno::Reference< - ::com::sun::star::security::XAccessControlContext >(); - } -} + ::com::sun::star::security::XAccessControlContext > const & xRestriction, + ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XCurrentContext > const & xCurrentContext ) + SAL_THROW( (::com::sun::star::uno::Exception) ); } diff --git a/cppuhelper/source/access_control.cxx b/cppuhelper/source/access_control.cxx index 15cf55e03b67..4b9c901fdd6e 100644 --- a/cppuhelper/source/access_control.cxx +++ b/cppuhelper/source/access_control.cxx @@ -2,9 +2,9 @@ * * $RCSfile: access_control.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: dbo $ $Date: 2001-12-14 14:52:32 $ + * last change: $Author: dbo $ $Date: 2002-01-11 10:06:02 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -65,14 +65,19 @@ #include <cppuhelper/implbase1.hxx> #include <cppuhelper/factory.hxx> +#include <cppuhelper/access_control.hxx> #include <com/sun/star/uno/XCurrentContext.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/security/XAccessController.hpp> +#include <com/sun/star/security/RuntimePermission.hpp> +#include <com/sun/star/io/FilePermission.hpp> +#include <com/sun/star/connection/SocketPermission.hpp> + #define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) ) #define AC_RESTRICTION "access-control.restriction" -#define AC_SERVICE "com.sun.star.security.AccessController" using namespace ::rtl; @@ -80,7 +85,6 @@ using namespace ::osl; using namespace ::com::sun::star; using namespace ::com::sun::star::uno; - namespace cppu { @@ -104,12 +108,12 @@ public: // XAccessControlContext impl virtual void SAL_CALL checkPermission( - security::Permission const & perm ) + Any const & perm ) throw (RuntimeException); }; //__________________________________________________________________________________________________ void acc_Combiner::checkPermission( - security::Permission const & perm ) + Any const & perm ) throw (RuntimeException) { m_x1->checkPermission( perm ); @@ -184,7 +188,7 @@ Any acc_CurrentContext::getValueByName( OUString const & name ) } //-------------------------------------------------------------------------------------------------- -Reference< security::XAccessControlContext > ac_defimpl_getRestriction( +Reference< security::XAccessControlContext > SAL_CALL ac_defimpl_getRestriction( Reference< XCurrentContext > const & xContext ) SAL_THROW( (RuntimeException) ) { @@ -270,7 +274,7 @@ Any SAL_CALL ac_defimpl_doPrivileged( //################################################################################################## -//### default service impl ######################################################################### +//### default service impl: does not check for static permissions! ################################# //################################################################################################## //================================================================================================== @@ -280,7 +284,7 @@ class DefaultAccessController public: // XAccessController impl virtual void SAL_CALL checkPermission( - security::Permission const & perm ) + Any const & perm ) throw (RuntimeException); virtual Any SAL_CALL doRestricted( Reference< security::XAction > const & xAction, @@ -295,7 +299,7 @@ public: }; //__________________________________________________________________________________________________ void DefaultAccessController::checkPermission( - security::Permission const & perm ) + Any const & perm ) throw (RuntimeException) { // only dynamic checks of ac contexts, no static checks concerning credentials @@ -336,22 +340,110 @@ Reference< security::XAccessControlContext > DefaultAccessController::getContext return ac_defimpl_getRestriction( xContext ); } +//=== run on bootstrapping ========================================================================= +Reference< security::XAccessController > createDefaultAccessController() + SAL_THROW( () ) +{ + return new DefaultAccessController(); +} + +//################################################################################################## +//### helper class ################################################################################# +//################################################################################################## + +static OUString str_ac_singleton = OUSTR(AC_SINGLETON); + +//__________________________________________________________________________________________________ +AccessControl::AccessControl( Reference< XComponentContext > const & xContext ) + SAL_THROW( (RuntimeException) ) +{ + if (! (xContext->getValueByName( str_ac_singleton ) >>= m_xController)) + { + throw SecurityException( + OUSTR("no access controller!"), Reference< XInterface >() ); + } +} +//__________________________________________________________________________________________________ +AccessControl::AccessControl( + Reference< security::XAccessController > const & xController ) + SAL_THROW( (RuntimeException) ) + : m_xController( xController ) +{ + if (! m_xController.is()) + { + throw SecurityException( + OUSTR("no access controller!"), Reference< XInterface >() ); + } +} +//__________________________________________________________________________________________________ +AccessControl::AccessControl( AccessControl const & ac ) + SAL_THROW( (RuntimeException) ) + : m_xController( ac.m_xController ) +{ + if (! m_xController.is()) + { + throw SecurityException( + OUSTR("no access controller!"), Reference< XInterface >() ); + } +} + +#ifdef SAL_W32 +#pragma pack(push, 8) +#endif + // binary comp. to all Permission structs + struct __permission + { + rtl_uString * m_str1; + rtl_uString * m_str2; + }; +#ifdef SAL_W32 +#pragma pack(pop) +#endif + //-------------------------------------------------------------------------------------------------- -static Reference< XInterface > SAL_CALL create_default_ac( - Reference< XComponentContext > const & ) - SAL_THROW( (Exception) ) +inline __checkPermission( + Reference< security::XAccessController > const & xController, + Type const & type, rtl_uString * str1, rtl_uString * str2 ) + SAL_THROW( (RuntimeException) ) +{ + __permission perm; + perm.m_str1 = str1; + perm.m_str2 = str2; + + uno_Any a; + a.pType = type.getTypeLibType(); + a.pData = &perm; + + xController->checkPermission( * reinterpret_cast< Any const * >( &a ) ); +} +//__________________________________________________________________________________________________ +void AccessControl::checkRuntimePermission( + OUString const & name ) + SAL_THROW( (RuntimeException) ) { - return (OWeakObject *)new DefaultAccessController(); + __checkPermission( + m_xController, + ::getCppuType( (security::RuntimePermission *)0 ), name.pData, 0 ); } -//=== run on bootstrapping ========================================================================= -Reference< lang::XSingleComponentFactory > createDefaultAccessController() - SAL_THROW( () ) +//__________________________________________________________________________________________________ +void AccessControl::checkFilePermission( + OUString const & url, + OUString const & actions ) + SAL_THROW( (RuntimeException) ) +{ + __checkPermission( + m_xController, + ::getCppuType( (io::FilePermission *)0 ), url.pData, actions.pData ); +} +//__________________________________________________________________________________________________ +void AccessControl::checkSocketPermission( + OUString const & host, + OUString const & actions ) + SAL_THROW( (RuntimeException) ) { - OUString serviceName( RTL_CONSTASCII_USTRINGPARAM(AC_SERVICE) ); - return createSingleComponentFactory( - create_default_ac, - OUSTR("com.sun.star.comp.security.DummyAccessController"), - Sequence< OUString >( &serviceName, 1 ) ); + __checkPermission( + m_xController, + ::getCppuType( (connection::SocketPermission *)0 ), host.pData, actions.pData ); } } diff --git a/cppuhelper/source/bootstrap.cxx b/cppuhelper/source/bootstrap.cxx index aca06eefd74a..105df381d3e9 100644 --- a/cppuhelper/source/bootstrap.cxx +++ b/cppuhelper/source/bootstrap.cxx @@ -2,9 +2,9 @@ * * $RCSfile: bootstrap.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: jbu $ $Date: 2001-12-03 16:24:48 $ + * last change: $Author: dbo $ $Date: 2002-01-11 10:06:02 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -62,12 +62,6 @@ #include <vector> // #include <string.h> -#include <osl/diagnose.h> -#include <osl/file.hxx> -#include <osl/module.h> -#include <osl/module.hxx> -#include <osl/security.hxx> - #include <rtl/process.h> #include <rtl/bootstrap.hxx> #include <rtl/string.hxx> @@ -76,11 +70,21 @@ #include <rtl/strbuf.hxx> #endif +#include <osl/diagnose.h> +#include <osl/file.hxx> +#include <osl/module.hxx> +#include <osl/security.hxx> +#include <osl/thread.h> + +#include <uno/current_context.h> + #include <cppuhelper/shlib.hxx> #include <cppuhelper/bootstrap.hxx> #include <cppuhelper/component_context.hxx> +#include <cppuhelper/access_control.hxx> #include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/uno/XCurrentContext.hpp> #include <com/sun/star/lang/XSingleServiceFactory.hpp> #include <com/sun/star/lang/XSingleComponentFactory.hpp> @@ -102,6 +106,28 @@ using namespace ::com::sun::star::uno; namespace cppu { +static OUString str_envType = OUSTR(CPPU_CURRENT_LANGUAGE_BINDING_NAME); + +//================================================================================================== +void * SAL_CALL parentThreadCallback(void) SAL_THROW_EXTERN_C() +{ + OSL_TRACE( "+> thread creation..." ); + XCurrentContext * xContext = 0; + ::uno_getCurrentContext( (void **)&xContext, str_envType.pData, 0 ); + return xContext; // return acquired context +} +//================================================================================================== +void SAL_CALL childThreadCallback( void * pParentData ) SAL_THROW_EXTERN_C() +{ + OSL_TRACE( "++> child thread running." ); + XCurrentContext * xContext = (XCurrentContext *)pParentData; + if (xContext) + { + ::uno_setCurrentContext( xContext, str_envType.pData, 0 ); + xContext->release(); + } +} + //================================================================================================== void addFactories( char const * const * ppNames /* lib, implname, ..., 0 */, @@ -168,7 +194,7 @@ Reference< XComponentContext > bootstrapInitialContext( Reference< lang::XMultiComponentFactory > const & xSF, Reference< registry::XSimpleRegistry > const & types_xRegistry, Reference< registry::XSimpleRegistry > const & services_xRegistry, - OUString const & rBootstrapPath ) + OUString const & rBootstrapPath, Bootstrap const & bootstrap ) SAL_THROW( (Exception) ); //-------------------------------------------------------------------------------------------------- @@ -345,6 +371,8 @@ Reference< XComponentContext > SAL_CALL defaultBootstrap_InitialComponentContext OUString const & iniFile ) SAL_THROW( (Exception) ) { +// osl_registerThreadCallbacks( parentThreadCallback, childThreadCallback ); + OUString bootstrapPath; OUString iniDir; Bootstrap bootstrap( iniFile ); @@ -386,7 +414,7 @@ Reference< XComponentContext > SAL_CALL defaultBootstrap_InitialComponentContext // xxx todo: when moving down cfgmgr+interfaces to udk, code from cfg_registry_wrapper // is used. Now not supported... OUString cfg_url; - if (bootstrap.getFrom( OUString( RTL_CONSTASCII_USTRINGPARAM("UNO_CFG_URL") ), cfg_url )) + if (bootstrap.getFrom( OUSTR("UNO_CFG_URL"), cfg_url )) { // ==== bootstrap from configuration ==== @@ -469,7 +497,8 @@ Reference< XComponentContext > SAL_CALL defaultBootstrap_InitialComponentContext // layer into two contexts Reference< XComponentContext > xContext( bootstrapInitialContext( smgr_XMultiComponentFactory, types_xRegistry, - Reference< registry::XSimpleRegistry >(), bootstrapPath ) ); + Reference< registry::XSimpleRegistry >(), + bootstrapPath, bootstrap ) ); xContext = createInitialCfgComponentContext( &context_values[ 0 ], context_values.size(), xContext ); @@ -503,7 +532,8 @@ Reference< XComponentContext > SAL_CALL defaultBootstrap_InitialComponentContext !fallenBackWriteRegistry, bFallenback_services ); Reference< XComponentContext > xContext( bootstrapInitialContext( - smgr_XMultiComponentFactory, types_xRegistry, services_xRegistry, bootstrapPath ) ); + smgr_XMultiComponentFactory, types_xRegistry, services_xRegistry, + bootstrapPath, bootstrap ) ); // initialize sf Reference< lang::XInitialization > xInit( smgr_XMultiComponentFactory, UNO_QUERY ); @@ -516,12 +546,12 @@ Reference< XComponentContext > SAL_CALL defaultBootstrap_InitialComponentContext return xContext; } } + static void MyDummySymbolWithinLibrary(){} //================================================================================================== Reference< XComponentContext > SAL_CALL defaultBootstrap_InitialComponentContext() SAL_THROW( (Exception) ) { - OSL_TRACE("vcl/source/app/unohelp.cxx: trying rc file..."); OUString libraryFileUrl; Module::getUrlFromAddress((void*)MyDummySymbolWithinLibrary, libraryFileUrl); diff --git a/cppuhelper/source/makefile.mk b/cppuhelper/source/makefile.mk index 0c1b4cf117bd..ef61dd2a2d6e 100644 --- a/cppuhelper/source/makefile.mk +++ b/cppuhelper/source/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.21 $ +# $Revision: 1.22 $ # -# last change: $Author: dbo $ $Date: 2001-12-14 13:19:51 $ +# last change: $Author: dbo $ $Date: 2002-01-11 10:06:02 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -121,7 +121,10 @@ UNOTYPES= \ com.sun.star.registry.XRegistryKey \ com.sun.star.loader.XImplementationLoader \ com.sun.star.lang.XTypeProvider \ - com.sun.star.lang.XComponent + com.sun.star.lang.XComponent \ + com.sun.star.security.RuntimePermission \ + com.sun.star.io.FilePermission \ + com.sun.star.connection.SocketPermission .IF "$(debug)" != "" # msvc++: no inlining for debugging diff --git a/cppuhelper/source/msvc_win32_intel.map b/cppuhelper/source/msvc_win32_intel.map index 5120430c2439..9c13dc86dce1 100644 --- a/cppuhelper/source/msvc_win32_intel.map +++ b/cppuhelper/source/msvc_win32_intel.map @@ -197,6 +197,13 @@ component_getDescriptionFunc; ?ac_defimpl_doRestricted@cppu@@YA?AVAny@uno@star@sun@com@@ABV?$Reference@VXAction@security@star@sun@com@@@3456@ABV?$Reference@VXAccessControlContext@security@star@sun@com@@@3456@ABV?$Reference@VXCurrentContext@uno@star@sun@com@@@3456@@Z; ?ac_defimpl_doPrivileged@cppu@@YA?AVAny@uno@star@sun@com@@ABV?$Reference@VXAction@security@star@sun@com@@@3456@ABV?$Reference@VXAccessControlContext@security@star@sun@com@@@3456@ABV?$Reference@VXCurrentContext@uno@star@sun@com@@@3456@@Z; +??0AccessControl@cppu@@QAE@ABV?$Reference@VXComponentContext@uno@star@sun@com@@@uno@star@sun@com@@@Z; +??0AccessControl@cppu@@QAE@ABV?$Reference@VXAccessController@security@star@sun@com@@@uno@star@sun@com@@@Z; +??0AccessControl@cppu@@QAE@ABV01@@Z; +?checkRuntimePermission@AccessControl@cppu@@QAAXABVOUString@rtl@@@Z; +?checkFilePermission@AccessControl@cppu@@QAAXABVOUString@rtl@@0@Z; +?checkSocketPermission@AccessControl@cppu@@QAAXABVOUString@rtl@@0@Z; + local: *; }; diff --git a/cppuhelper/source/servicefactory.cxx b/cppuhelper/source/servicefactory.cxx index 352679b70db7..9cb3378c773d 100644 --- a/cppuhelper/source/servicefactory.cxx +++ b/cppuhelper/source/servicefactory.cxx @@ -2,9 +2,9 @@ * * $RCSfile: servicefactory.cxx,v $ * - * $Revision: 1.27 $ + * $Revision: 1.28 $ * - * last change: $Author: dbo $ $Date: 2001-12-14 13:19:51 $ + * last change: $Author: dbo $ $Date: 2002-01-11 10:06:02 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -61,30 +61,22 @@ #include <vector> -#ifndef _OSL_DIAGNOSE_H_ -#include <osl/diagnose.h> -#endif -#ifndef _OSL_FILE_HXX_ -#include <osl/file.hxx> -#endif -#ifndef _OSL_MODULE_H_ -#include <osl/module.h> -#endif -#ifndef _RTL_PROCESS_H #include <rtl/process.h> -#endif -#ifndef _RTL_STRING_HXX_ #include <rtl/string.hxx> -#endif -#ifndef _RTL_USTRBUF_HXX_ #include <rtl/ustrbuf.hxx> -#endif +#include <rtl/bootstrap.hxx> + +#include <osl/diagnose.h> +#include <osl/file.hxx> +#include <osl/module.h> +#include <osl/thread.h> #include <cppuhelper/shlib.hxx> #include <cppuhelper/factory.hxx> #include <cppuhelper/component_context.hxx> #include <cppuhelper/servicefactory.hxx> #include <cppuhelper/bootstrap.hxx> +#include <cppuhelper/access_control.hxx> #include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/lang/XInitialization.hpp> @@ -94,6 +86,7 @@ #include <com/sun/star/container/XHierarchicalNameAccess.hpp> #include <com/sun/star/registry/XSimpleRegistry.hpp> #include <com/sun/star/registry/XImplementationRegistration.hpp> +#include <com/sun/star/security/XAccessController.hpp> #define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) ) @@ -118,8 +111,11 @@ void addFactories( Reference< registry::XRegistryKey > const & xKey ) SAL_THROW( (Exception) ); //-------------------------------------------------------------------------------------------------- -Reference< lang::XSingleComponentFactory > createDefaultAccessController() - SAL_THROW( () ); +Reference< security::XAccessController > createDefaultAccessController() SAL_THROW( () ); +//-------------------------------------------------------------------------------------------------- +void * SAL_CALL parentThreadCallback(void) SAL_THROW_EXTERN_C(); +//-------------------------------------------------------------------------------------------------- +void SAL_CALL childThreadCallback( void * xParentContext ) SAL_THROW_EXTERN_C(); //================================================================================================== static Reference< XInterface > SAL_CALL createInstance( @@ -216,7 +212,8 @@ Reference< XComponentContext > bootstrapInitialContext( Reference< lang::XMultiComponentFactory > const & xSF, Reference< registry::XSimpleRegistry > const & types_xRegistry, Reference< registry::XSimpleRegistry > const & services_xRegistry, - OUString const & rBootstrapPath ) + OUString const & rBootstrapPath, + Bootstrap const & bootstrap ) SAL_THROW( (Exception) ) { Reference< lang::XInitialization > xSFInit( xSF, UNO_QUERY ); @@ -280,8 +277,8 @@ Reference< XComponentContext > bootstrapInitialContext( context_values.push_back( entry ); // ac - entry.bLateInitService = true; - entry.name = OUSTR("/singletons/com.sun.star.security.theAccessController"); + entry.bLateInitService = false; + entry.name = OUSTR(AC_SINGLETON); entry.value <<= createDefaultAccessController(); context_values.push_back( entry ); @@ -352,6 +349,18 @@ Reference< XComponentContext > bootstrapInitialContext( installTypeDescriptionManager( xTDMgr ); } + // wrap ac for subsequent services + OUString ac_service; + if (bootstrap.getFrom( OUSTR("UNO_AC"), ac_service ) && ac_service.getLength()) + { + // wrap ac + ContextEntry_Init entry; + entry.bLateInitService = true; + entry.name = OUSTR(AC_SINGLETON); + entry.value <<= ac_service; + xContext = createComponentContext( &entry, 1, xContext ); + } + return xContext; } @@ -363,6 +372,8 @@ static Reference< lang::XMultiComponentFactory > createImplServiceFactory( const OUString & rBootstrapPath ) SAL_THROW( (Exception) ) { +// osl_registerThreadCallbacks( parentThreadCallback, childThreadCallback ); + Reference< lang::XMultiComponentFactory > xSF( bootstrapInitialSF( rBootstrapPath ) ); Reference< registry::XSimpleRegistry > xRegistry; @@ -436,8 +447,9 @@ static Reference< lang::XMultiComponentFactory > createImplServiceFactory( Reference< XInterface >() ); } + Bootstrap bootstrap; Reference< XComponentContext > xContext( - bootstrapInitialContext( xSF, xRegistry, xRegistry, rBootstrapPath ) ); + bootstrapInitialContext( xSF, xRegistry, xRegistry, rBootstrapPath, bootstrap ) ); // initialize sf Reference< lang::XInitialization > xInit( xSF, UNO_QUERY ); @@ -456,7 +468,7 @@ Reference< lang::XMultiServiceFactory > SAL_CALL createRegistryServiceFactory( const OUString & rReadRegistry, sal_Bool bReadOnly, const OUString & rBootstrapPath ) - SAL_THROW( (::com::sun::star::uno::Exception) ) + SAL_THROW( (Exception) ) { return Reference< lang::XMultiServiceFactory >( createImplServiceFactory( rWriteRegistry, rReadRegistry, bReadOnly, rBootstrapPath ), UNO_QUERY ); @@ -468,10 +480,14 @@ Reference< XComponentContext > SAL_CALL bootstrap_InitialComponentContext( OUString const & rBootstrapPath ) SAL_THROW( (Exception) ) { + Bootstrap bootstrap; + +// osl_registerThreadCallbacks( parentThreadCallback, childThreadCallback ); + Reference< lang::XMultiComponentFactory > xSF( bootstrapInitialSF( rBootstrapPath ) ); Reference< XComponentContext > xContext( - bootstrapInitialContext( xSF, xRegistry, xRegistry, rBootstrapPath ) ); + bootstrapInitialContext( xSF, xRegistry, xRegistry, rBootstrapPath, bootstrap ) ); // initialize sf Reference< lang::XInitialization > xInit( xSF, UNO_QUERY ); |