summaryrefslogtreecommitdiff
path: root/cppuhelper/inc
diff options
context:
space:
mode:
authorDaniel Boelzle <dbo@openoffice.org>2002-01-11 09:06:02 +0000
committerDaniel Boelzle <dbo@openoffice.org>2002-01-11 09:06:02 +0000
commit6c2d3c98609e7ffa944b3f5289ffadc47d2637a9 (patch)
treeaab53b5a9cd7fc72a3ae260ab830a092c8e6627a /cppuhelper/inc
parent875da5e1130830a8602be2ca85bfa739f459ff4d (diff)
#88919# ac implementation and bootstrapping
Diffstat (limited to 'cppuhelper/inc')
-rwxr-xr-xcppuhelper/inc/cppuhelper/access_control.hxx247
1 files changed, 103 insertions, 144 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) );
}