#88919# ac implementation and bootstrapping

This commit is contained in:
Daniel Boelzle
2002-01-11 09:06:02 +00:00
parent 875da5e113
commit 6c2d3c9860
6 changed files with 316 additions and 209 deletions

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: access_control.hxx,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -58,12 +58,18 @@
* *
* *
************************************************************************/ ************************************************************************/
#ifndef _CPPUHELPER_SECURITY_HXX_ #ifndef _CPPUHELPER_ACCESS_CONTROL_HXX_
#define _CPPUHELPER_SECURITY_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> #include <com/sun/star/uno/XComponentContext.hpp>
#endif
#ifndef _COM_SUN_STAR_SECURITY_XACCESSCONTROLLER_HPP_
#include <com/sun/star/security/XAccessController.hpp> #include <com/sun/star/security/XAccessController.hpp>
#endif
#define AC_SINGLETON "/singletons/com.sun.star.security.theAccessController" #define AC_SINGLETON "/singletons/com.sun.star.security.theAccessController"
@@ -71,169 +77,122 @@
namespace cppu namespace cppu
{ {
//================================================================================================== /** Helper class retriving access controller singleton from component context.
*/
class AccessControl class AccessControl
{ {
::com::sun::star::uno::Reference< ::com::sun::star::security::XAccessController > m_xController; ::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: public:
inline AccessControl( /** Ctor.
::com::sun::star::uno::Reference<
::com::sun::star::security::XAccessController > const & xController ) @param xContext component context to retrieve access controller singleton
SAL_THROW( () ); */
inline AccessControl( AccessControl(
::com::sun::star::uno::Reference< ::com::sun::star::uno::Reference<
::com::sun::star::uno::XComponentContext > const & xContext ) ::com::sun::star::uno::XComponentContext > const & xContext )
SAL_THROW( (::com::sun::star::uno::RuntimeException) ); SAL_THROW( (::com::sun::star::uno::RuntimeException) );
/** Ctor.
// checkPermission() @param xController access controller
inline void SAL_CALL checkPermission( */
::com::sun::star::security::Permission const & perm ) AccessControl(
::com::sun::star::uno::Reference<
::com::sun::star::security::XAccessController > const & xController )
SAL_THROW( (::com::sun::star::uno::RuntimeException) ); SAL_THROW( (::com::sun::star::uno::RuntimeException) );
inline void SAL_CALL checkPermission( /** Copy ctor.
::rtl::OUString const & permType,
::rtl::OUString const & permTarget, @param another object
::rtl::OUString const & permActions ) */
AccessControl( ::cppu::AccessControl const & ac )
SAL_THROW( (::com::sun::star::uno::RuntimeException) ); SAL_THROW( (::com::sun::star::uno::RuntimeException) );
inline void SAL_CALL checkFilePermission( /** Returns access to the access controller reference being used.
::rtl::OUString const & permTarget,
::rtl::OUString const & permActions ) @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) ); SAL_THROW( (::com::sun::star::uno::RuntimeException) );
// doRestricted() /** A com.sun.star.io.FilePermission represents access to a file or directory.
inline ::com::sun::star::uno::Any SAL_CALL doRestricted( A FilePermission consists of a file url and a set of actions valid for that pathname.
::com::sun::star::uno::Reference<
::com::sun::star::security::XAction > const & xAction, @param url file url
::com::sun::star::uno::Reference< @param actions actions list
::com::sun::star::security::XAccessControlContext > const & xRestriction ) */
SAL_THROW( (::com::sun::star::uno::Exception) ); void SAL_CALL checkFilePermission(
// doPrivileged() ::rtl::OUString const & url,
inline ::com::sun::star::uno::Any SAL_CALL doPrivileged( ::rtl::OUString const & actions )
::com::sun::star::uno::Reference< SAL_THROW( (::com::sun::star::uno::RuntimeException) );
::com::sun::star::security::XAction > const & xAction,
::com::sun::star::uno::Reference< /** A com.sun.star.connection.SocketPermission represents access to a network via sockets.
::com::sun::star::security::XAccessControlContext > const & xRestriction ) A SocketPermission consists of a host specification and a set of "actions"
SAL_THROW( (::com::sun::star::uno::Exception) ); specifying ways to connect to that host.
// getContext()
inline ::com::sun::star::uno::Reference< @param host host and optional portrange
::com::sun::star::security::XAccessControlContext > SAL_CALL getContext() @param actions actions list
*/
void SAL_CALL checkSocketPermission(
::rtl::OUString const & host,
::rtl::OUString const & actions )
SAL_THROW( (::com::sun::star::uno::RuntimeException) ); 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(
::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 );
}
//__________________________________________________________________________________________________
inline ::com::sun::star::uno::Any AccessControl::doRestricted( /** 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::XCurrentContext > const & xCurrentContext )
SAL_THROW( (::com::sun::star::uno::RuntimeException) );
/** 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::uno::Reference<
::com::sun::star::security::XAction > const & xAction, ::com::sun::star::security::XAction > const & xAction,
::com::sun::star::uno::Reference< ::com::sun::star::uno::Reference<
::com::sun::star::security::XAccessControlContext > const & xRestriction ) ::com::sun::star::security::XAccessControlContext > const & xRestriction,
SAL_THROW( (::com::sun::star::uno::Exception) ) ::com::sun::star::uno::Reference<
{ ::com::sun::star::uno::XCurrentContext > const & xCurrentContext )
if (m_xController.is()) SAL_THROW( (::com::sun::star::uno::Exception) );
{
return m_xController->doRestricted( xAction, xRestriction ); /** Default implementation performed a privileged action.
}
else @param xAction action to be performed
{ @param xRestriction (the one and only) restriction to be in effect
return xAction->run(); @param xCurrentContext current context
} */
} ::com::sun::star::uno::Any SAL_CALL
//__________________________________________________________________________________________________ ac_defimpl_doPrivileged(
inline ::com::sun::star::uno::Any AccessControl::doPrivileged(
::com::sun::star::uno::Reference< ::com::sun::star::uno::Reference<
::com::sun::star::security::XAction > const & xAction, ::com::sun::star::security::XAction > const & xAction,
::com::sun::star::uno::Reference< ::com::sun::star::uno::Reference<
::com::sun::star::security::XAccessControlContext > const & xRestriction ) ::com::sun::star::security::XAccessControlContext > const & xRestriction,
SAL_THROW( (::com::sun::star::uno::Exception) ) ::com::sun::star::uno::Reference<
{ ::com::sun::star::uno::XCurrentContext > const & xCurrentContext )
if (m_xController.is()) SAL_THROW( (::com::sun::star::uno::Exception) );
{
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 >();
}
}
} }

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: access_control.cxx,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -65,14 +65,19 @@
#include <cppuhelper/implbase1.hxx> #include <cppuhelper/implbase1.hxx>
#include <cppuhelper/factory.hxx> #include <cppuhelper/factory.hxx>
#include <cppuhelper/access_control.hxx>
#include <com/sun/star/uno/XCurrentContext.hpp> #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/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 OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
#define AC_RESTRICTION "access-control.restriction" #define AC_RESTRICTION "access-control.restriction"
#define AC_SERVICE "com.sun.star.security.AccessController"
using namespace ::rtl; using namespace ::rtl;
@@ -80,7 +85,6 @@ using namespace ::osl;
using namespace ::com::sun::star; using namespace ::com::sun::star;
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
namespace cppu namespace cppu
{ {
@@ -104,12 +108,12 @@ public:
// XAccessControlContext impl // XAccessControlContext impl
virtual void SAL_CALL checkPermission( virtual void SAL_CALL checkPermission(
security::Permission const & perm ) Any const & perm )
throw (RuntimeException); throw (RuntimeException);
}; };
//__________________________________________________________________________________________________ //__________________________________________________________________________________________________
void acc_Combiner::checkPermission( void acc_Combiner::checkPermission(
security::Permission const & perm ) Any const & perm )
throw (RuntimeException) throw (RuntimeException)
{ {
m_x1->checkPermission( perm ); 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 ) Reference< XCurrentContext > const & xContext )
SAL_THROW( (RuntimeException) ) 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: public:
// XAccessController impl // XAccessController impl
virtual void SAL_CALL checkPermission( virtual void SAL_CALL checkPermission(
security::Permission const & perm ) Any const & perm )
throw (RuntimeException); throw (RuntimeException);
virtual Any SAL_CALL doRestricted( virtual Any SAL_CALL doRestricted(
Reference< security::XAction > const & xAction, Reference< security::XAction > const & xAction,
@@ -295,7 +299,7 @@ public:
}; };
//__________________________________________________________________________________________________ //__________________________________________________________________________________________________
void DefaultAccessController::checkPermission( void DefaultAccessController::checkPermission(
security::Permission const & perm ) Any const & perm )
throw (RuntimeException) throw (RuntimeException)
{ {
// only dynamic checks of ac contexts, no static checks concerning credentials // 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 ); return ac_defimpl_getRestriction( xContext );
} }
//--------------------------------------------------------------------------------------------------
static Reference< XInterface > SAL_CALL create_default_ac(
Reference< XComponentContext > const & )
SAL_THROW( (Exception) )
{
return (OWeakObject *)new DefaultAccessController();
}
//=== run on bootstrapping ========================================================================= //=== run on bootstrapping =========================================================================
Reference< lang::XSingleComponentFactory > createDefaultAccessController() Reference< security::XAccessController > createDefaultAccessController()
SAL_THROW( () ) SAL_THROW( () )
{ {
OUString serviceName( RTL_CONSTASCII_USTRINGPARAM(AC_SERVICE) ); return new DefaultAccessController();
return createSingleComponentFactory( }
create_default_ac,
OUSTR("com.sun.star.comp.security.DummyAccessController"), //##################################################################################################
Sequence< OUString >( &serviceName, 1 ) ); //### 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
//--------------------------------------------------------------------------------------------------
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) )
{
__checkPermission(
m_xController,
::getCppuType( (security::RuntimePermission *)0 ), name.pData, 0 );
}
//__________________________________________________________________________________________________
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) )
{
__checkPermission(
m_xController,
::getCppuType( (connection::SocketPermission *)0 ), host.pData, actions.pData );
} }
} }

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: bootstrap.cxx,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -62,12 +62,6 @@
#include <vector> #include <vector>
// #include <string.h> // #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/process.h>
#include <rtl/bootstrap.hxx> #include <rtl/bootstrap.hxx>
#include <rtl/string.hxx> #include <rtl/string.hxx>
@@ -76,11 +70,21 @@
#include <rtl/strbuf.hxx> #include <rtl/strbuf.hxx>
#endif #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/shlib.hxx>
#include <cppuhelper/bootstrap.hxx> #include <cppuhelper/bootstrap.hxx>
#include <cppuhelper/component_context.hxx> #include <cppuhelper/component_context.hxx>
#include <cppuhelper/access_control.hxx>
#include <com/sun/star/uno/XComponentContext.hpp> #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/XSingleServiceFactory.hpp>
#include <com/sun/star/lang/XSingleComponentFactory.hpp> #include <com/sun/star/lang/XSingleComponentFactory.hpp>
@@ -102,6 +106,28 @@ using namespace ::com::sun::star::uno;
namespace cppu 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( void addFactories(
char const * const * ppNames /* lib, implname, ..., 0 */, char const * const * ppNames /* lib, implname, ..., 0 */,
@@ -168,7 +194,7 @@ Reference< XComponentContext > bootstrapInitialContext(
Reference< lang::XMultiComponentFactory > const & xSF, Reference< lang::XMultiComponentFactory > const & xSF,
Reference< registry::XSimpleRegistry > const & types_xRegistry, Reference< registry::XSimpleRegistry > const & types_xRegistry,
Reference< registry::XSimpleRegistry > const & services_xRegistry, Reference< registry::XSimpleRegistry > const & services_xRegistry,
OUString const & rBootstrapPath ) OUString const & rBootstrapPath, Bootstrap const & bootstrap )
SAL_THROW( (Exception) ); SAL_THROW( (Exception) );
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -345,6 +371,8 @@ Reference< XComponentContext > SAL_CALL defaultBootstrap_InitialComponentContext
OUString const & iniFile ) OUString const & iniFile )
SAL_THROW( (Exception) ) SAL_THROW( (Exception) )
{ {
// osl_registerThreadCallbacks( parentThreadCallback, childThreadCallback );
OUString bootstrapPath; OUString bootstrapPath;
OUString iniDir; OUString iniDir;
Bootstrap bootstrap( iniFile ); 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 // xxx todo: when moving down cfgmgr+interfaces to udk, code from cfg_registry_wrapper
// is used. Now not supported... // is used. Now not supported...
OUString cfg_url; 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 ==== // ==== bootstrap from configuration ====
@@ -469,7 +497,8 @@ Reference< XComponentContext > SAL_CALL defaultBootstrap_InitialComponentContext
// layer into two contexts // layer into two contexts
Reference< XComponentContext > xContext( bootstrapInitialContext( Reference< XComponentContext > xContext( bootstrapInitialContext(
smgr_XMultiComponentFactory, types_xRegistry, smgr_XMultiComponentFactory, types_xRegistry,
Reference< registry::XSimpleRegistry >(), bootstrapPath ) ); Reference< registry::XSimpleRegistry >(),
bootstrapPath, bootstrap ) );
xContext = createInitialCfgComponentContext( xContext = createInitialCfgComponentContext(
&context_values[ 0 ], context_values.size(), xContext ); &context_values[ 0 ], context_values.size(), xContext );
@@ -503,7 +532,8 @@ Reference< XComponentContext > SAL_CALL defaultBootstrap_InitialComponentContext
!fallenBackWriteRegistry, bFallenback_services ); !fallenBackWriteRegistry, bFallenback_services );
Reference< XComponentContext > xContext( bootstrapInitialContext( Reference< XComponentContext > xContext( bootstrapInitialContext(
smgr_XMultiComponentFactory, types_xRegistry, services_xRegistry, bootstrapPath ) ); smgr_XMultiComponentFactory, types_xRegistry, services_xRegistry,
bootstrapPath, bootstrap ) );
// initialize sf // initialize sf
Reference< lang::XInitialization > xInit( smgr_XMultiComponentFactory, UNO_QUERY ); Reference< lang::XInitialization > xInit( smgr_XMultiComponentFactory, UNO_QUERY );
@@ -516,12 +546,12 @@ Reference< XComponentContext > SAL_CALL defaultBootstrap_InitialComponentContext
return xContext; return xContext;
} }
} }
static void MyDummySymbolWithinLibrary(){} static void MyDummySymbolWithinLibrary(){}
//================================================================================================== //==================================================================================================
Reference< XComponentContext > SAL_CALL defaultBootstrap_InitialComponentContext() Reference< XComponentContext > SAL_CALL defaultBootstrap_InitialComponentContext()
SAL_THROW( (Exception) ) SAL_THROW( (Exception) )
{ {
OSL_TRACE("vcl/source/app/unohelp.cxx: trying rc file...");
OUString libraryFileUrl; OUString libraryFileUrl;
Module::getUrlFromAddress((void*)MyDummySymbolWithinLibrary, libraryFileUrl); Module::getUrlFromAddress((void*)MyDummySymbolWithinLibrary, libraryFileUrl);

View File

@@ -2,9 +2,9 @@
# #
# $RCSfile: makefile.mk,v $ # $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 # The Contents of this file are made available subject to the terms of
# either of the following licenses # either of the following licenses
@@ -121,7 +121,10 @@ UNOTYPES= \
com.sun.star.registry.XRegistryKey \ com.sun.star.registry.XRegistryKey \
com.sun.star.loader.XImplementationLoader \ com.sun.star.loader.XImplementationLoader \
com.sun.star.lang.XTypeProvider \ 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)" != "" .IF "$(debug)" != ""
# msvc++: no inlining for debugging # msvc++: no inlining for debugging

View File

@@ -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_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; ?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: local:
*; *;
}; };

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: servicefactory.cxx,v $ * $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 * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -61,30 +61,22 @@
#include <vector> #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> #include <rtl/process.h>
#endif
#ifndef _RTL_STRING_HXX_
#include <rtl/string.hxx> #include <rtl/string.hxx>
#endif
#ifndef _RTL_USTRBUF_HXX_
#include <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/shlib.hxx>
#include <cppuhelper/factory.hxx> #include <cppuhelper/factory.hxx>
#include <cppuhelper/component_context.hxx> #include <cppuhelper/component_context.hxx>
#include <cppuhelper/servicefactory.hxx> #include <cppuhelper/servicefactory.hxx>
#include <cppuhelper/bootstrap.hxx> #include <cppuhelper/bootstrap.hxx>
#include <cppuhelper/access_control.hxx>
#include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/lang/XInitialization.hpp>
@@ -94,6 +86,7 @@
#include <com/sun/star/container/XHierarchicalNameAccess.hpp> #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
#include <com/sun/star/registry/XSimpleRegistry.hpp> #include <com/sun/star/registry/XSimpleRegistry.hpp>
#include <com/sun/star/registry/XImplementationRegistration.hpp> #include <com/sun/star/registry/XImplementationRegistration.hpp>
#include <com/sun/star/security/XAccessController.hpp>
#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) ) #define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
@@ -118,8 +111,11 @@ void addFactories(
Reference< registry::XRegistryKey > const & xKey ) Reference< registry::XRegistryKey > const & xKey )
SAL_THROW( (Exception) ); SAL_THROW( (Exception) );
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
Reference< lang::XSingleComponentFactory > createDefaultAccessController() Reference< security::XAccessController > createDefaultAccessController() SAL_THROW( () );
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( static Reference< XInterface > SAL_CALL createInstance(
@@ -216,7 +212,8 @@ Reference< XComponentContext > bootstrapInitialContext(
Reference< lang::XMultiComponentFactory > const & xSF, Reference< lang::XMultiComponentFactory > const & xSF,
Reference< registry::XSimpleRegistry > const & types_xRegistry, Reference< registry::XSimpleRegistry > const & types_xRegistry,
Reference< registry::XSimpleRegistry > const & services_xRegistry, Reference< registry::XSimpleRegistry > const & services_xRegistry,
OUString const & rBootstrapPath ) OUString const & rBootstrapPath,
Bootstrap const & bootstrap )
SAL_THROW( (Exception) ) SAL_THROW( (Exception) )
{ {
Reference< lang::XInitialization > xSFInit( xSF, UNO_QUERY ); Reference< lang::XInitialization > xSFInit( xSF, UNO_QUERY );
@@ -280,8 +277,8 @@ Reference< XComponentContext > bootstrapInitialContext(
context_values.push_back( entry ); context_values.push_back( entry );
// ac // ac
entry.bLateInitService = true; entry.bLateInitService = false;
entry.name = OUSTR("/singletons/com.sun.star.security.theAccessController"); entry.name = OUSTR(AC_SINGLETON);
entry.value <<= createDefaultAccessController(); entry.value <<= createDefaultAccessController();
context_values.push_back( entry ); context_values.push_back( entry );
@@ -352,6 +349,18 @@ Reference< XComponentContext > bootstrapInitialContext(
installTypeDescriptionManager( xTDMgr ); 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; return xContext;
} }
@@ -363,6 +372,8 @@ static Reference< lang::XMultiComponentFactory > createImplServiceFactory(
const OUString & rBootstrapPath ) const OUString & rBootstrapPath )
SAL_THROW( (Exception) ) SAL_THROW( (Exception) )
{ {
// osl_registerThreadCallbacks( parentThreadCallback, childThreadCallback );
Reference< lang::XMultiComponentFactory > xSF( bootstrapInitialSF( rBootstrapPath ) ); Reference< lang::XMultiComponentFactory > xSF( bootstrapInitialSF( rBootstrapPath ) );
Reference< registry::XSimpleRegistry > xRegistry; Reference< registry::XSimpleRegistry > xRegistry;
@@ -436,8 +447,9 @@ static Reference< lang::XMultiComponentFactory > createImplServiceFactory(
Reference< XInterface >() ); Reference< XInterface >() );
} }
Bootstrap bootstrap;
Reference< XComponentContext > xContext( Reference< XComponentContext > xContext(
bootstrapInitialContext( xSF, xRegistry, xRegistry, rBootstrapPath ) ); bootstrapInitialContext( xSF, xRegistry, xRegistry, rBootstrapPath, bootstrap ) );
// initialize sf // initialize sf
Reference< lang::XInitialization > xInit( xSF, UNO_QUERY ); Reference< lang::XInitialization > xInit( xSF, UNO_QUERY );
@@ -456,7 +468,7 @@ Reference< lang::XMultiServiceFactory > SAL_CALL createRegistryServiceFactory(
const OUString & rReadRegistry, const OUString & rReadRegistry,
sal_Bool bReadOnly, sal_Bool bReadOnly,
const OUString & rBootstrapPath ) const OUString & rBootstrapPath )
SAL_THROW( (::com::sun::star::uno::Exception) ) SAL_THROW( (Exception) )
{ {
return Reference< lang::XMultiServiceFactory >( createImplServiceFactory( return Reference< lang::XMultiServiceFactory >( createImplServiceFactory(
rWriteRegistry, rReadRegistry, bReadOnly, rBootstrapPath ), UNO_QUERY ); rWriteRegistry, rReadRegistry, bReadOnly, rBootstrapPath ), UNO_QUERY );
@@ -468,10 +480,14 @@ Reference< XComponentContext > SAL_CALL bootstrap_InitialComponentContext(
OUString const & rBootstrapPath ) OUString const & rBootstrapPath )
SAL_THROW( (Exception) ) SAL_THROW( (Exception) )
{ {
Bootstrap bootstrap;
// osl_registerThreadCallbacks( parentThreadCallback, childThreadCallback );
Reference< lang::XMultiComponentFactory > xSF( Reference< lang::XMultiComponentFactory > xSF(
bootstrapInitialSF( rBootstrapPath ) ); bootstrapInitialSF( rBootstrapPath ) );
Reference< XComponentContext > xContext( Reference< XComponentContext > xContext(
bootstrapInitialContext( xSF, xRegistry, xRegistry, rBootstrapPath ) ); bootstrapInitialContext( xSF, xRegistry, xRegistry, rBootstrapPath, bootstrap ) );
// initialize sf // initialize sf
Reference< lang::XInitialization > xInit( xSF, UNO_QUERY ); Reference< lang::XInitialization > xInit( xSF, UNO_QUERY );