summaryrefslogtreecommitdiff
path: root/cppuhelper
diff options
context:
space:
mode:
authorDaniel Boelzle <dbo@openoffice.org>2002-01-25 08:36:50 +0000
committerDaniel Boelzle <dbo@openoffice.org>2002-01-25 08:36:50 +0000
commit579c0285a7675cb27f151b708dfa7cc96a23b5e5 (patch)
tree4b57e3cfe68c1b323f547c3ef0dc82a40292f9a4 /cppuhelper
parentd85311bf15e1ab9848ca25d0ac57043c64cc4276 (diff)
#88919# bootstrapping native ac; removed ac_defimpl functions
Diffstat (limited to 'cppuhelper')
-rwxr-xr-xcppuhelper/inc/cppuhelper/access_control.hxx53
-rw-r--r--cppuhelper/source/access_control.cxx280
-rw-r--r--cppuhelper/source/bootstrap.cxx5
-rwxr-xr-xcppuhelper/source/cc5_solaris_sparc.map4
-rw-r--r--cppuhelper/source/component_context.cxx7
-rw-r--r--cppuhelper/source/makefile.mk8
-rw-r--r--cppuhelper/source/msvc_win32_intel.map4
-rw-r--r--cppuhelper/source/servicefactory.cxx165
8 files changed, 148 insertions, 378 deletions
diff --git a/cppuhelper/inc/cppuhelper/access_control.hxx b/cppuhelper/inc/cppuhelper/access_control.hxx
index 6d1e993b5..84cdbad18 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.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: dbo $ $Date: 2002-01-11 10:06:02 $
+ * last change: $Author: dbo $ $Date: 2002-01-25 09:36:50 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,9 +61,6 @@
#ifndef _CPPUHELPER_ACCESS_CONTROL_HXX_
#define _CPPUHELPER_ACCESS_CONTROL_HXX_
-#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
@@ -71,8 +68,6 @@
#include <com/sun/star/security/XAccessController.hpp>
#endif
-#define AC_SINGLETON "/singletons/com.sun.star.security.theAccessController"
-
namespace cppu
{
@@ -150,50 +145,6 @@ public:
SAL_THROW( (::com::sun::star::uno::RuntimeException) );
};
-
-/** 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::security::XAction > const & xAction,
- ::com::sun::star::uno::Reference<
- ::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,
- ::com::sun::star::uno::Reference<
- ::com::sun::star::uno::XCurrentContext > const & xCurrentContext )
- SAL_THROW( (::com::sun::star::uno::Exception) );
-
}
#endif
diff --git a/cppuhelper/source/access_control.cxx b/cppuhelper/source/access_control.cxx
index 4fb831c20..1055eb0be 100644
--- a/cppuhelper/source/access_control.cxx
+++ b/cppuhelper/source/access_control.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: access_control.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: dbo $ $Date: 2002-01-11 10:15:50 $
+ * last change: $Author: dbo $ $Date: 2002-01-25 09:36:50 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -59,26 +59,15 @@
*
************************************************************************/
-#include <osl/diagnose.h>
-#include <osl/interlck.h>
-#include <uno/current_context.h>
-
-#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"
-
using namespace ::rtl;
using namespace ::osl;
@@ -89,269 +78,7 @@ namespace cppu
{
static OUString str_envType = OUSTR(CPPU_CURRENT_LANGUAGE_BINDING_NAME);
-static OUString str_acRestriction = OUSTR(AC_RESTRICTION);
-
-//==================================================================================================
-class acc_Combiner
- : public WeakImplHelper1< security::XAccessControlContext >
-{
- Reference< security::XAccessControlContext > m_x1, m_x2;
-
-public:
- inline acc_Combiner(
- Reference< security::XAccessControlContext > const & x1,
- Reference< security::XAccessControlContext > const & x2 )
- SAL_THROW( () )
- : m_x1( x1 )
- , m_x2( x2 )
- {}
-
- // XAccessControlContext impl
- virtual void SAL_CALL checkPermission(
- Any const & perm )
- throw (RuntimeException);
-};
-//__________________________________________________________________________________________________
-void acc_Combiner::checkPermission(
- Any const & perm )
- throw (RuntimeException)
-{
- m_x1->checkPermission( perm );
- m_x2->checkPermission( perm );
-}
-//==================================================================================================
-class acc_CurrentContext
- : public ImplHelper1< XCurrentContext >
-{
- oslInterlockedCount m_refcount;
-
- Reference< XCurrentContext > m_xDelegate;
- Any m_restriction;
-
-public:
- inline acc_CurrentContext(
- Reference< XCurrentContext > const & xDelegate,
- Reference< security::XAccessControlContext > const & xRestriction )
- SAL_THROW( () );
-
- // XInterface impl
- virtual void SAL_CALL acquire()
- throw ();
- virtual void SAL_CALL release()
- throw ();
-
- // XCurrentContext
- virtual Any SAL_CALL getValueByName( OUString const & name )
- throw (RuntimeException);
-};
-//__________________________________________________________________________________________________
-inline acc_CurrentContext::acc_CurrentContext(
- Reference< XCurrentContext > const & xDelegate,
- Reference< security::XAccessControlContext > const & xRestriction )
- SAL_THROW( () )
- : m_refcount( 0 )
- , m_xDelegate( xDelegate )
-{
- if (xRestriction.is())
- {
- m_restriction = makeAny( xRestriction );
- }
- // return empty any otherwise on getValueByName(), not null interface
-}
-//__________________________________________________________________________________________________
-void acc_CurrentContext::acquire()
- throw ()
-{
- ::osl_incrementInterlockedCount( &m_refcount );
-}
-//__________________________________________________________________________________________________
-void acc_CurrentContext::release()
- throw ()
-{
- if (! ::osl_decrementInterlockedCount( &m_refcount ))
- {
- delete this;
- }
-}
-//__________________________________________________________________________________________________
-Any acc_CurrentContext::getValueByName( OUString const & name )
- throw (RuntimeException)
-{
- if (name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(AC_RESTRICTION) ))
- {
- return m_restriction;
- }
- else
- {
- return m_xDelegate->getValueByName( name );
- }
-}
-
-//--------------------------------------------------------------------------------------------------
-Reference< security::XAccessControlContext > SAL_CALL ac_defimpl_getRestriction(
- Reference< XCurrentContext > const & xContext )
- SAL_THROW( (RuntimeException) )
-{
- if (xContext.is())
- {
- Any acc( xContext->getValueByName( str_acRestriction ) );
- if (typelib_TypeClass_INTERFACE == acc.pType->eTypeClass)
- {
- OUString const & typeName =
- * reinterpret_cast< OUString const * >( &acc.pType->pTypeName );
- if (typeName.equalsAsciiL(
- RTL_CONSTASCII_STRINGPARAM("com.sun.star.security.XAccessControlContext") ))
- {
- return Reference< security::XAccessControlContext >(
- * reinterpret_cast< security::XAccessControlContext * * const >( acc.pData ) );
- }
- else // try to query
- {
- return Reference< security::XAccessControlContext >::query(
- * reinterpret_cast< XInterface * * const >( acc.pData ) );
- }
- }
- }
- return Reference< security::XAccessControlContext >();
-}
-//==================================================================================================
-struct __cc_reset
-{
- void * m_cc;
- inline __cc_reset( void * cc ) SAL_THROW( () )
- : m_cc( cc ) {}
- inline ~__cc_reset() SAL_THROW( () )
- { ::uno_setCurrentContext( m_cc, str_envType.pData, 0 ); }
-};
-//==================================================================================================
-Any SAL_CALL ac_defimpl_doRestricted(
- Reference< security::XAction > const & xAction,
- Reference< security::XAccessControlContext > const & xRestriction,
- Reference< XCurrentContext > const & xContext )
- SAL_THROW( (Exception) )
-{
- if (xRestriction.is())
- {
- Reference< security::XAccessControlContext > xOldRestr(
- ac_defimpl_getRestriction( xContext ) );
-
- if (xOldRestr.is())
- {
- Reference< XCurrentContext > xNewContext( new acc_CurrentContext(
- xContext, new acc_Combiner( xRestriction, xOldRestr ) ) );
- ::uno_setCurrentContext( xNewContext.get(), str_envType.pData, 0 );
- }
- else
- {
- Reference< XCurrentContext > xNewContext( new acc_CurrentContext(
- xContext, xRestriction ) );
- ::uno_setCurrentContext( xNewContext.get(), str_envType.pData, 0 );
- }
-
- __cc_reset reset( xContext.get() );
- return xAction->run();
- }
- else
- {
- return xAction->run();
- }
-}
-//==================================================================================================
-Any SAL_CALL ac_defimpl_doPrivileged(
- Reference< security::XAction > const & xAction,
- Reference< security::XAccessControlContext > const & xRestriction,
- Reference< XCurrentContext > const & xContext )
- SAL_THROW( (Exception) )
-{
- // override AC_RESTRICTION
- Reference< XCurrentContext > xNewContext( new acc_CurrentContext(
- xContext, xRestriction ) );
- ::uno_setCurrentContext( xNewContext.get(), str_envType.pData, 0 );
-
- __cc_reset reset( xContext.get() );
- return xAction->run();
-}
-
-
-//##################################################################################################
-//### default service impl: does not check for static permissions! #################################
-//##################################################################################################
-
-//==================================================================================================
-class DefaultAccessController
- : public WeakImplHelper1< security::XAccessController >
-{
-public:
- // XAccessController impl
- virtual void SAL_CALL checkPermission(
- Any const & perm )
- throw (RuntimeException);
- virtual Any SAL_CALL doRestricted(
- Reference< security::XAction > const & xAction,
- Reference< security::XAccessControlContext > const & xRestriction )
- throw (Exception);
- virtual Any SAL_CALL doPrivileged(
- Reference< security::XAction > const & xAction,
- Reference< security::XAccessControlContext > const & xRestriction )
- throw (Exception);
- virtual Reference< security::XAccessControlContext > SAL_CALL getContext()
- throw (RuntimeException);
-};
-//__________________________________________________________________________________________________
-void DefaultAccessController::checkPermission(
- Any const & perm )
- throw (RuntimeException)
-{
- // only dynamic checks of ac contexts, no static checks concerning credentials
- Reference< XCurrentContext > xContext;
- ::uno_getCurrentContext( (void **)&xContext, str_envType.pData, 0 );
- Reference< security::XAccessControlContext > xACC( ac_defimpl_getRestriction( xContext ) );
- if (xACC.is())
- {
- xACC->checkPermission( perm );
- }
-}
-//__________________________________________________________________________________________________
-Any DefaultAccessController::doRestricted(
- Reference< security::XAction > const & xAction,
- Reference< security::XAccessControlContext > const & xRestriction )
- throw (Exception)
-{
- Reference< XCurrentContext > xContext;
- ::uno_getCurrentContext( (void **)&xContext, str_envType.pData, 0 );
- return ac_defimpl_doRestricted( xAction, xRestriction, xContext );
-}
-//__________________________________________________________________________________________________
-Any DefaultAccessController::doPrivileged(
- Reference< security::XAction > const & xAction,
- Reference< security::XAccessControlContext > const & xRestriction )
- throw (Exception)
-{
- Reference< XCurrentContext > xContext;
- ::uno_getCurrentContext( (void **)&xContext, str_envType.pData, 0 );
- return ac_defimpl_doPrivileged( xAction, xRestriction, xContext );
-}
-//__________________________________________________________________________________________________
-Reference< security::XAccessControlContext > DefaultAccessController::getContext()
- throw (RuntimeException)
-{
- Reference< XCurrentContext > xContext;
- ::uno_getCurrentContext( (void **)&xContext, str_envType.pData, 0 );
- 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);
+static OUString str_ac_singleton = OUSTR("/singletons/com.sun.star.security.theAccessController");
//__________________________________________________________________________________________________
AccessControl::AccessControl( Reference< XComponentContext > const & xContext )
@@ -447,4 +174,3 @@ void AccessControl::checkSocketPermission(
}
}
-
diff --git a/cppuhelper/source/bootstrap.cxx b/cppuhelper/source/bootstrap.cxx
index c6ad0c438..d21eac997 100644
--- a/cppuhelper/source/bootstrap.cxx
+++ b/cppuhelper/source/bootstrap.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: bootstrap.cxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: jbu $ $Date: 2002-01-16 16:24:14 $
+ * last change: $Author: dbo $ $Date: 2002-01-25 09:36:50 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -60,7 +60,6 @@
************************************************************************/
#include <vector>
-// #include <string.h>
#include <rtl/process.h>
#include <rtl/bootstrap.hxx>
diff --git a/cppuhelper/source/cc5_solaris_sparc.map b/cppuhelper/source/cc5_solaris_sparc.map
index 6a8497159..dbf618fbf 100755
--- a/cppuhelper/source/cc5_solaris_sparc.map
+++ b/cppuhelper/source/cc5_solaris_sparc.map
@@ -246,10 +246,6 @@ __1cEcppubJWeakAggComponentImplHelper_getTypes6Fpn0AKclass_data__nDcomDsunEstarD
__1cEcppubEImplHelper_getImplementationId6Fpn0AKclass_data__nDcomDsunEstarDunoISequence4CW___;
__1cEcppubOdefaultBootstrap_InitialComponentContext6FrknDrtlIOUString__nDcomDsunEstarDunoJReference4n0GRXComponentContext____;
-__1cEcppuXac_defimpl_doPrivileged6FrknDcomDsunEstarDunoJReference4n0DIsecurityHXAction___rkn0EJReference4n0FVXAccessControlContext___rkn0EJReference4n0EPXCurrentContext____n0EDAny__;
-__1cEcppuXac_defimpl_doRestricted6FrknDcomDsunEstarDunoJReference4n0DIsecurityHXAction___rkn0EJReference4n0FVXAccessControlContext___rkn0EJReference4n0EPXCurrentContext____n0EDAny__;
-__1cEcppuZac_defimpl_getRestriction6FrknDcomDsunEstarDunoJReference4n0EPXCurrentContext____n0EJReference4n0DIsecurityVXAccessControlContext____;
-
__1cEcppuNAccessControl2t5B6MrknDcomDsunEstarDunoJReference4n0EIsecurityRXAccessController____v_;
__1cEcppuNAccessControl2t5B6MrknDcomDsunEstarDunoJReference4n0FRXComponentContext____v_;
__1cEcppuNAccessControl2t5B6Mrk1_v_;
diff --git a/cppuhelper/source/component_context.cxx b/cppuhelper/source/component_context.cxx
index 84f304409..f35531074 100644
--- a/cppuhelper/source/component_context.cxx
+++ b/cppuhelper/source/component_context.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: component_context.cxx,v $
*
- * $Revision: 1.13 $
+ * $Revision: 1.14 $
*
- * last change: $Author: dbo $ $Date: 2001-12-17 12:25:55 $
+ * last change: $Author: dbo $ $Date: 2002-01-25 09:36:50 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -76,7 +76,6 @@
#include <cppuhelper/implbase1.hxx>
#include <cppuhelper/compbase1.hxx>
#include <cppuhelper/component_context.hxx>
-#include <cppuhelper/access_control.hxx>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <com/sun/star/lang/XMultiComponentFactory.hpp>
@@ -90,7 +89,7 @@
#define SMGR_SINGLETON "/singletons/com.sun.star.lang.theServiceManager"
#define TDMGR_SINGLETON "/singletons/com.sun.star.reflection.theTypeDescriptionManager"
-
+#define AC_SINGLETON "/singletons/com.sun.star.security.theAccessController"
#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
diff --git a/cppuhelper/source/makefile.mk b/cppuhelper/source/makefile.mk
index d5e68728c..003a9a0f0 100644
--- a/cppuhelper/source/makefile.mk
+++ b/cppuhelper/source/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.23 $
+# $Revision: 1.24 $
#
-# last change: $Author: dbo $ $Date: 2002-01-11 11:08:58 $
+# last change: $Author: dbo $ $Date: 2002-01-25 09:36:50 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -90,7 +90,6 @@ UNOTYPES= \
com.sun.star.uno.XAggregation \
com.sun.star.uno.XComponentContext \
com.sun.star.uno.XUnloadingPreference \
- com.sun.star.uno.XCurrentContext \
com.sun.star.lang.XMultiServiceFactory \
com.sun.star.lang.XSingleServiceFactory \
com.sun.star.lang.XMultiComponentFactory \
@@ -98,7 +97,6 @@ UNOTYPES= \
com.sun.star.lang.XServiceInfo \
com.sun.star.lang.XInitialization \
com.sun.star.lang.XEventListener \
- com.sun.star.security.XAccessController \
com.sun.star.reflection.XIdlReflection \
com.sun.star.reflection.XIdlClass \
com.sun.star.reflection.XIdlClassProvider \
@@ -123,6 +121,8 @@ UNOTYPES= \
com.sun.star.loader.XImplementationLoader \
com.sun.star.lang.XTypeProvider \
com.sun.star.lang.XComponent \
+ com.sun.star.uno.XCurrentContext \
+ com.sun.star.security.XAccessController \
com.sun.star.security.RuntimePermission \
com.sun.star.io.FilePermission \
com.sun.star.connection.SocketPermission
diff --git a/cppuhelper/source/msvc_win32_intel.map b/cppuhelper/source/msvc_win32_intel.map
index 9c13dc86d..2afa27120 100644
--- a/cppuhelper/source/msvc_win32_intel.map
+++ b/cppuhelper/source/msvc_win32_intel.map
@@ -193,10 +193,6 @@ component_getDescriptionFunc;
?WeakComponentImplHelper_getTypes@cppu@@YA?AV?$Sequence@VType@uno@star@sun@com@@@uno@star@sun@com@@PAUclass_data@1@@Z;
?defaultBootstrap_InitialComponentContext@cppu@@YA?AV?$Reference@VXComponentContext@uno@star@sun@com@@@uno@star@sun@com@@ABVOUString@rtl@@@Z;
-?ac_defimpl_getRestriction@cppu@@YA?AV?$Reference@VXAccessControlContext@security@star@sun@com@@@uno@star@sun@com@@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;
-
??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;
diff --git a/cppuhelper/source/servicefactory.cxx b/cppuhelper/source/servicefactory.cxx
index 31811d733..be5a5b248 100644
--- a/cppuhelper/source/servicefactory.cxx
+++ b/cppuhelper/source/servicefactory.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: servicefactory.cxx,v $
*
- * $Revision: 1.28 $
+ * $Revision: 1.29 $
*
- * last change: $Author: dbo $ $Date: 2002-01-11 10:06:02 $
+ * last change: $Author: dbo $ $Date: 2002-01-25 09:36:50 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -59,6 +59,9 @@
*
************************************************************************/
+#ifdef _DEBUG
+#include <stdio.h>
+#endif
#include <vector>
#include <rtl/process.h>
@@ -67,16 +70,16 @@
#include <rtl/bootstrap.hxx>
#include <osl/diagnose.h>
-#include <osl/file.hxx>
+#include <osl/file.h>
#include <osl/module.h>
#include <osl/thread.h>
+#include <osl/process.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>
@@ -171,7 +174,9 @@ Reference< registry::XSimpleRegistry > SAL_CALL createNestedRegistry(
createInstance( loadSharedLibComponentFactory(
OUString( RTL_CONSTASCII_USTRINGPARAM("defreg") ), rBootstrapPath,
OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.stoc.NestedRegistry") ),
- Reference< lang::XMultiServiceFactory >(), Reference< registry::XRegistryKey >() ) ), UNO_QUERY );
+ Reference< lang::XMultiServiceFactory >(),
+ Reference< registry::XRegistryKey >() ) ),
+ UNO_QUERY );
}
catch (Exception &)
{
@@ -181,6 +186,116 @@ Reference< registry::XSimpleRegistry > SAL_CALL createNestedRegistry(
return Reference< registry::XSimpleRegistry >();
}
+
+/** bootstrap variables:
+
+ UNO_AC=<mode> [mandatory]
+ -- mode := { on, off, dynamic-only, single-user, single-default-user }
+ UNO_AC_SERVICE=<service_name> [optional]
+ -- override ac singleton service name
+ UNO_AC_SINGLEUSER=<user-id|nothing> [optional]
+ -- run with this user id or with default user policy (<nothing>)
+ set UNO_AC=single-[default-]user
+
+ UNO_AC_POLICYSERVICE=<service_name> [optional]
+ -- override policy singleton service name
+ UNO_AC_POLICYFILE=<file_url> [optional]
+ -- read policy out of simple text file
+*/
+static void add_access_control_entries(
+ ::std::vector< ContextEntry_Init > * values,
+ Bootstrap const & bootstrap )
+ SAL_THROW( (Exception) )
+{
+ ContextEntry_Init entry;
+ ::std::vector< ContextEntry_Init > & context_values = *values;
+
+ OUString ac_policy;
+ if (bootstrap.getFrom( OUSTR("UNO_AC_POLICYSERVICE"), ac_policy )) // overridden service name
+ {
+ // - policy singleton
+ entry.bLateInitService = true;
+ entry.name = OUSTR("/singletons/com.sun.star.security.thePolicy");
+ entry.value <<= ac_policy;
+ context_values.push_back( entry );
+ }
+ else if (bootstrap.getFrom( OUSTR("UNO_AC_POLICYFILE"), ac_policy )) // check for file policy
+ {
+ // - file policy prop: file-name
+ if (0 != ac_policy.compareToAscii( RTL_CONSTASCII_STRINGPARAM("file:///") )) // no file url
+ {
+ OUString baseDir;
+ oslProcessError prc = ::osl_getProcessWorkingDir(
+ &baseDir.pData );
+ OSL_ASSERT( osl_Process_E_None == prc );
+ OUString fileURL;
+ oslFileError frc = ::osl_getAbsoluteFileURL(
+ baseDir.pData, ac_policy.pData, &fileURL.pData );
+ OSL_ASSERT( osl_File_E_None == frc );
+ ac_policy = fileURL;
+ }
+
+ entry.bLateInitService = false;
+ entry.name = OUSTR("/implementations/com.sun.star.security.comp.stoc.FilePolicy/file-name");
+ entry.value <<= ac_policy;
+ context_values.push_back( entry );
+ // - policy singleton
+ entry.bLateInitService = true;
+ entry.name = OUSTR("/singletons/com.sun.star.security.thePolicy");
+ entry.value <<= OUSTR("com.sun.star.security.comp.stoc.FilePolicy");
+ context_values.push_back( entry );
+ } // else policy singleton comes from storage
+
+ OUString ac_mode;
+ if (! bootstrap.getFrom( OUSTR("UNO_AC"), ac_mode ))
+ {
+ ac_mode = OUSTR("off"); // default
+ }
+ OUString ac_user;
+ if (bootstrap.getFrom( OUSTR("UNO_AC_SINGLEUSER"), ac_user )) // ac in single-user mode
+ {
+ if (ac_user.getLength())
+ {
+ // - ac prop: single-user-id
+ entry.bLateInitService = false;
+ entry.name = OUSTR("/services/com.sun.star.security.AccessController/single-user-id");
+ entry.value <<= ac_user;
+ context_values.push_back( entry );
+ if (! ac_mode.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("single-user") ))
+ {
+ throw SecurityException(
+ OUSTR("set UNO_AC=single-user if you set UNO_AC_SINGLEUSER=<user-id>!"),
+ Reference< XInterface >() );
+ }
+ }
+ else
+ {
+ if (! ac_mode.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("single-default-user") ))
+ {
+ throw SecurityException(
+ OUSTR("set UNO_AC=single-default-user if you set UNO_AC_SINGLEUSER=<nothing>!"),
+ Reference< XInterface >() );
+ }
+ }
+ }
+ OUString ac_service;
+ if (! bootstrap.getFrom( OUSTR("UNO_AC_SERVICE"), ac_service )) // override service name
+ {
+ ac_service = OUSTR("com.sun.star.security.AccessController"); // default
+// ac = OUSTR("com.sun.star.security.comp.stoc.AccessController");
+ }
+
+ // - ac prop: mode { "off", "on", "dynamic-only", "single-user", "single-default-user" }
+ entry.bLateInitService = false;
+ entry.name = OUSTR("/services/com.sun.star.security.AccessController/mode");
+ entry.value <<= ac_mode;
+ context_values.push_back( entry );
+ // - ac singleton
+ entry.bLateInitService = true;
+ entry.name = OUSTR("/singletons/com.sun.star.security.theAccessController");
+ entry.value <<= ac_service;
+ context_values.push_back( entry );
+}
//--------------------------------------------------------------------------------------------------
Reference< lang::XMultiComponentFactory > bootstrapInitialSF(
OUString const & rBootstrapPath )
@@ -198,6 +313,8 @@ Reference< lang::XMultiComponentFactory > bootstrapInitialSF(
"defreg", "com.sun.star.comp.stoc.NestedRegistry",
"tdmgr", "com.sun.star.comp.stoc.TypeDescriptionManager",
"impreg", "com.sun.star.comp.stoc.ImplementationRegistration",
+ "sec", "com.sun.star.security.comp.stoc.AccessController",
+ "sec", "com.sun.star.security.comp.stoc.FilePolicy",
0
};
addFactories(
@@ -227,7 +344,7 @@ Reference< XComponentContext > bootstrapInitialContext(
// basic context values
ContextEntry_Init entry;
::std::vector< ContextEntry_Init > context_values;
- context_values.reserve( 6 );
+ context_values.reserve( 12 );
// read out singleton infos from registry
if (services_xRegistry.is())
@@ -270,28 +387,26 @@ Reference< XComponentContext > bootstrapInitialContext(
}
}
- // smgr
+ // smgr:
+ // - smgr singleton
entry.bLateInitService = false;
entry.name = OUSTR("/singletons/com.sun.star.lang.theServiceManager");
entry.value <<= xSF;
context_values.push_back( entry );
+
+ // ac, policy:
+ add_access_control_entries( &context_values, bootstrap );
- // ac
+ // tdmgr:
+ // - tdmgr prop: cache size
entry.bLateInitService = false;
- entry.name = OUSTR(AC_SINGLETON);
- entry.value <<= createDefaultAccessController();
+ entry.name = OUSTR("/implementations/com.sun.star.comp.stoc.TypeDescriptionManager/CacheSize");
+ entry.value <<= (sal_Int32)512;
context_values.push_back( entry );
-
- // tdmgr
+ // - tdmgr singleton
entry.bLateInitService = true;
entry.name = OUSTR("/singletons/com.sun.star.reflection.theTypeDescriptionManager");
- entry.value <<= OUSTR("com.sun.star.reflection.TypeDescriptionManager");
- context_values.push_back( entry );
-
- // tdmgr: cache size
- entry.bLateInitService = false;
- entry.name = OUSTR("/implementations/com.sun.star.comp.stoc.TypeDescriptionManager/CacheSize");
- entry.value <<= (sal_Int32)512;
+ entry.value <<= OUSTR("com.sun.star.comp.stoc.TypeDescriptionManager");
context_values.push_back( entry );
Reference< XComponentContext > xContext;
@@ -349,18 +464,6 @@ 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;
}